Class DecimalFunctions

java.lang.Object
  |
  +--Functions
        |
        +--DecimalFunctions

public class DecimalFunctions
extends Functions


Fields inherited from class Functions
acc, accuracy, Eight, epsilon, Five, Four, Half, m1, m2, m3, m4, m5, m6, m7, m8, mm2, mm4, mm6, mm8, Nine, One, Six, Three, Twentyfour, Two, Zero
 
Constructor Summary
DecimalFunctions()
           
 
Method Summary
(package private) static BigDecimal arctanh(BigDecimal x)
           
(package private) static boolean badArgument(BigDecimal q)
          A method used to detect that a BigDecimal argument q is bigger than MAX_INTEGER or that it is not non-negative integer.
(package private) static BigDecimal Binomial(BigDecimal n, BigDecimal k)
          Calculates the binomial coefficient nCk, and expresses the result as a BigDecimal.
private static BigInteger Ceiling_i(BigDecimal n)
           
(package private) static BigDecimal ceiling(BigDecimal n)
           
(package private) static BigDecimal cos(BigDecimal x)
          Calculates cos(x).
(package private) static BigDecimal cosRestricted(BigDecimal x)
          Calculates cos(x).
(package private) static BigDecimal exp(BigDecimal x)
           
private static BigDecimal expRestricted(BigDecimal x)
          Calculates exponential, but is supposed to be called only for 0
(package private) static BigDecimal factorial(BigDecimal n)
           
(package private) static BigDecimal fibonacci(BigDecimal q)
           
private static BigInteger floor_i(BigDecimal n)
           
(package private) static BigDecimal floor(BigDecimal n)
           
(package private) static BigDecimal harmonics(BigDecimal n)
           
(package private) static BigDecimal isPrime(BigDecimal n)
           
(package private) static BigDecimal ln(BigDecimal x)
          Calculates the natural logarithm of a number.
private static BigDecimal ln2()
          Calculates the natural logarithm of 2 in a very fast way.
private static BigDecimal lnFast(BigDecimal x)
          Calculates the function ln((1+x)/(1-x)).
(package private) static BigDecimal lnFast251()
           
(package private) static BigDecimal lnFast449()
           
(package private) static BigDecimal lnFast4801()
           
(package private) static BigDecimal lnFast8749()
           
static void main(String[] args)
           
(package private) static BigDecimal mdx(BigDecimal m, BigDecimal x)
           
(package private) static BigDecimal mod(BigDecimal n, BigDecimal m)
           
(package private) static BigDecimal pi()
           
(package private) static BigDecimal pow(BigDecimal n, BigDecimal p)
          Calculates n^p.
(package private) static BigDecimal pow(BigDecimal x, int n)
          Calculates x^n, when n is an int.
(package private) static BigDecimal powSmall(BigDecimal x, BigDecimal alpha)
          Calculates (1+x)^alpha.
(package private) static BigDecimal sin(BigDecimal x)
          Calculates sin(x).
(package private) static BigDecimal sqrt(BigDecimal x)
          Returns the square root of x, when x is a non-negative real number.
(package private) static BigDecimal sqrt2(BigDecimal x)
          Calculates the square root of x.
(package private) static BigDecimal tan(BigDecimal x)
          Calculates tan(x).
 
Methods inherited from class Functions
, Binomial_i, factorial_i, fibonacci_i
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Constructor Detail

DecimalFunctions

public DecimalFunctions()
Method Detail

badArgument

static boolean badArgument(BigDecimal q)
                    throws VeryLongComputationException,
                           WrongArgumentException
A method used to detect that a BigDecimal argument q is bigger than MAX_INTEGER or that it is not non-negative integer. This is useful for functions where the argument must be a non-negative integer and cannot be very big as it is the case of the harmonic fibonacci functions.
Throws:
VeryLongComputationException -  
WrongArgumentException -  

factorial

static BigDecimal factorial(BigDecimal n)
                     throws VeryLongComputationException,
                            WrongArgumentException
Parameters:
n - BigDecimal.
Returns:
n! (n factorial) expressed as a BigDecimal.
Throws:
VeryLongComputationException - when n is greater than Integer.MAX_VALUE (2147483647).

mod

static BigDecimal mod(BigDecimal n,
                      BigDecimal m)
               throws WrongArgumentException
Parameters:
n - Integer represented as BigDecimal
m - Integer represented as as BigDecimal
Returns:
BigDecimal n mod m

harmonics

static BigDecimal harmonics(BigDecimal n)
                     throws VeryLongComputationException,
                            WrongArgumentException

sqrt

static BigDecimal sqrt(BigDecimal x)
                throws ImaginaryNumberException
Returns the square root of x, when x is a non-negative real number.
Throws:
ImaginaryNumberException. -  

sqrt2

static BigDecimal sqrt2(BigDecimal x)
Calculates the square root of x. It assumes x>=0. When x >= 0, it is called by sqrt(String x)

cosRestricted

static BigDecimal cosRestricted(BigDecimal x)
Calculates cos(x). It is designed to accept x such that 0 < x < pi/2.
Parameters:
BigDecimal - x
Returns:
BigDecimal representation of cos(x), with the given accuracy.

cos

static BigDecimal cos(BigDecimal x)
Calculates cos(x).
Parameters:
BigDecimal - x
Returns:
BigDecimal representation of cos(x), with the given accuracy.

sin

static BigDecimal sin(BigDecimal x)
Calculates sin(x).
Parameters:
BigDecimal - x
Returns:
BigDecimal representation of tan(x), with the given accuracy.

tan

static BigDecimal tan(BigDecimal x)
               throws InfinityException
Calculates tan(x).
Parameters:
BigDecimal - x
Returns:
BigDecimal representation of tan(x), with the given accuracy.
Throws:
InfintiyException -  

fibonacci

static BigDecimal fibonacci(BigDecimal q)
                     throws VeryLongComputationException,
                            WrongArgumentException
Parameters:
BigDecimal - q.
Returns:
The n-th term of the Fibonacci sequence expressed as a BigDecimal.
Throws:
VeryLongComputationException - when q is greater than Integer.MAX_VALUE (2147483647).

floor

static BigDecimal floor(BigDecimal n)

ceiling

static BigDecimal ceiling(BigDecimal n)
Parameters:
BigDecimal - n.
Returns:
The smallest integer (represented as a BigDecimal) bigger than the BigDecimal n.

floor_i

private static BigInteger floor_i(BigDecimal n)
Parameters:
BigDecimal - n.
Returns:
The greatest integer (represented as a BigInteger) smaller than the BigDecimal n.

Ceiling_i

private static BigInteger Ceiling_i(BigDecimal n)
Parameters:
BigDecimal - n.
Returns:
The smallest integer (represented as a BigInteger) bigger than the BigDecimal n.

Binomial

static BigDecimal Binomial(BigDecimal n,
                           BigDecimal k)
                    throws WrongArgumentException
Calculates the binomial coefficient nCk, and expresses the result as a BigDecimal. throws Wrong Argument Exception when k is not an integer

isPrime

static BigDecimal isPrime(BigDecimal n)

pi

static BigDecimal pi()

pow

static BigDecimal pow(BigDecimal n,
                      BigDecimal p)
               throws VeryLongComputationException
Calculates n^p.
Parameters:
BigDecimal - n.
BigDecimal - alpha which corresponds to the exponent.
Returns:
The BigDecimal representation of n^p.
Throws:
VeryLongComputationException -  

powSmall

static BigDecimal powSmall(BigDecimal x,
                           BigDecimal alpha)
Calculates (1+x)^alpha. It is intended to work for small values of the base (|x|< 1).
Parameters:
BigDecimal - x.
BigDecimal - alpha which corresponds to the exponent.
Returns:
The BigDecimal representation of (1+x)^alpha.

expRestricted

private static BigDecimal expRestricted(BigDecimal x)
Calculates exponential, but is supposed to be called only for 0

pow

static BigDecimal pow(BigDecimal x,
                      int n)
Calculates x^n, when n is an int.
Parameters:
BigDecimal - x.
int - n which corresponds to the exponent.
Returns:
The BigDecimal representation of x^n.

exp

static BigDecimal exp(BigDecimal x)

lnFast

private static BigDecimal lnFast(BigDecimal x)
Calculates the function ln((1+x)/(1-x)). It is assumed 0 < x < 1..

lnFast251

static BigDecimal lnFast251()

lnFast449

static BigDecimal lnFast449()

lnFast4801

static BigDecimal lnFast4801()

lnFast8749

static BigDecimal lnFast8749()

arctanh

static BigDecimal arctanh(BigDecimal x)

ln

static BigDecimal ln(BigDecimal x)
              throws ImaginaryNumberException,
                     InfinityException
Calculates the natural logarithm of a number.
Throws:
ImaginaryNumberException -  
InfinityException -  

mdx

static BigDecimal mdx(BigDecimal m,
                      BigDecimal x)

ln2

private static BigDecimal ln2()
Calculates the natural logarithm of 2 in a very fast way.

main

public static void main(String[] args)