## org.jscience.mathematics Class SpecialMathUtils

```java.lang.Object
org.jscience.mathematics.SpecialMathUtils
```

`public final class SpecialMathUtilsextends java.lang.Object`

The special function math library. This class cannot be subclassed or instantiated because all methods are static.

Field Summary
`static double` `GAMMA_X_MAX_VALUE`
The largest argument for which `gamma(x)` is representable in the machine.
`static double` `LOG_GAMMA_X_MAX_VALUE`
The largest argument for which `logGamma(x)` is representable in the machine.

Method Summary
`static double` `airy(double x)`
Airy function.
`static double` `besselFirstOne(double x)`
Bessel function of first kind, order one.
`static double` `besselFirstZero(double x)`
Bessel function of first kind, order zero.
`static double` `besselSecondOne(double x)`
Bessel function of second kind, order one.
`static double` `besselSecondZero(double x)`
Bessel function of second kind, order zero.
`static double` ```beta(double p, double q)```
Beta function.
`static double` ```chebyshev(double x, double[] series)```
Evaluates a Chebyshev series.
`static double` `complementaryError(double x)`
Complementary error function.
`static double` `error(double x)`
Error function.
`static double` `gamma(double x)`
Gamma function.
`static double` ```incompleteBeta(double x, double p, double q)```
Incomplete beta function.
`static double` ```incompleteGamma(double a, double x)```
Incomplete gamma function.
`static double` ```logBeta(double p, double q)```
The natural logarithm of the beta function.
`static double` `logGamma(double x)`
The natural logarithm of the gamma function.
`static double` `modBesselFirstOne(double x)`
Modified Bessel function of first kind, order one.
`static double` `modBesselFirstZero(double x)`
Modified Bessel function of first kind, order zero.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### GAMMA_X_MAX_VALUE

`public static final double GAMMA_X_MAX_VALUE`
The largest argument for which `gamma(x)` is representable in the machine.

Constant Field Values

### LOG_GAMMA_X_MAX_VALUE

`public static final double LOG_GAMMA_X_MAX_VALUE`
The largest argument for which `logGamma(x)` is representable in the machine.

Constant Field Values
Method Detail

### chebyshev

```public static double chebyshev(double x,
double[] series)```
Evaluates a Chebyshev series.

Parameters:
`x` - value at which to evaluate series
`series` - the coefficients of the series

### airy

`public static double airy(double x)`
Airy function. Based on the NETLIB Fortran function ai written by W. Fullerton.

### besselFirstZero

`public static double besselFirstZero(double x)`
Bessel function of first kind, order zero. Based on the NETLIB Fortran function besj0 written by W. Fullerton.

### modBesselFirstZero

`public static double modBesselFirstZero(double x)`
Modified Bessel function of first kind, order zero. Based on the NETLIB Fortran function besi0 written by W. Fullerton.

### besselFirstOne

`public static double besselFirstOne(double x)`
Bessel function of first kind, order one. Based on the NETLIB Fortran function besj1 written by W. Fullerton.

### modBesselFirstOne

`public static double modBesselFirstOne(double x)`
Modified Bessel function of first kind, order one. Based on the NETLIB Fortran function besi1 written by W. Fullerton.

### besselSecondZero

`public static double besselSecondZero(double x)`
Bessel function of second kind, order zero. Based on the NETLIB Fortran function besy0 written by W. Fullerton.

### besselSecondOne

`public static double besselSecondOne(double x)`
Bessel function of second kind, order one. Based on the NETLIB Fortran function besy1 written by W. Fullerton.

### gamma

`public static double gamma(double x)`
Gamma function. Based on public domain NETLIB (Fortran) code by W. J. Cody and L. Stoltz
Applied Mathematics Division
Argonne National Laboratory
Argonne, IL 60439

References:

1. "An Overview of Software Development for Special Functions", W. J. Cody, Lecture Notes in Mathematics, 506, Numerical Analysis Dundee, 1975, G. A. Watson (ed.), Springer Verlag, Berlin, 1976.
2. Computer Approximations, Hart, Et. Al., Wiley and sons, New York, 1968.

From the original documentation:

This routine calculates the GAMMA function for a real argument X. Computation is based on an algorithm outlined in reference 1. The program uses rational functions that approximate the GAMMA function to at least 20 significant decimal digits. Coefficients for the approximation over the interval (1,2) are unpublished. Those for the approximation for X .GE. 12 are from reference 2. The accuracy achieved depends on the arithmetic system, the compiler, the intrinsic functions, and proper selection of the machine-dependent constants.

Error returns:
The program returns the value XINF for singularities or when overflow would occur. The computation is believed to be free of underflow and overflow.

Returns:
Double.MAX_VALUE if overflow would occur, i.e. if abs(x) > 171.624

### logGamma

`public static double logGamma(double x)`
The natural logarithm of the gamma function. Based on public domain NETLIB (Fortran) code by W. J. Cody and L. Stoltz
Applied Mathematics Division
Argonne National Laboratory
Argonne, IL 60439

References:

1. W. J. Cody and K. E. Hillstrom, 'Chebyshev Approximations for the Natural Logarithm of the Gamma Function,' Math. Comp. 21, 1967, pp. 198-203.
2. K. E. Hillstrom, ANL/AMD Program ANLC366S, DGAMMA/DLGAMA, May, 1969.
3. Hart, Et. Al., Computer Approximations, Wiley and sons, New York, 1968.

From the original documentation:

This routine calculates the LOG(GAMMA) function for a positive real argument X. Computation is based on an algorithm outlined in references 1 and 2. The program uses rational functions that theoretically approximate LOG(GAMMA) to at least 18 significant decimal digits. The approximation for X > 12 is from reference 3, while approximations for X < 12.0 are similar to those in reference 1, but are unpublished. The accuracy achieved depends on the arithmetic system, the compiler, the intrinsic functions, and proper selection of the machine-dependent constants.

Error returns:
The program returns the value XINF for X .LE. 0.0 or when overflow would occur. The computation is believed to be free of underflow and overflow.

Returns:
Double.MAX_VALUE for x < 0.0 or when overflow would occur, i.e. x > 2.55E305

### incompleteGamma

```public static double incompleteGamma(double a,
double x)```
Incomplete gamma function. The computation is based on approximations presented in Numerical Recipes, Chapter 6.2 (W.H. Press et al, 1992).

Parameters:
`a` - require a>=0
`x` - require x>=0
Returns:
0 if x<0, a<=0 or a>2.55E305 to avoid errors and over/underflow

### beta

```public static double beta(double p,
double q)```
Beta function.

Parameters:
`p` - require p>0
`q` - require q>0
Returns:
0 if p<=0, q<=0 or p+q>2.55E305 to avoid errors and over/underflow

### logBeta

```public static double logBeta(double p,
double q)```
The natural logarithm of the beta function.

Parameters:
`p` - require p>0
`q` - require q>0
Returns:
0 if p<=0, q<=0 or p+q>2.55E305 to avoid errors and over/underflow

### incompleteBeta

```public static double incompleteBeta(double x,
double p,
double q)```
Incomplete beta function. The computation is based on formulas from Numerical Recipes, Chapter 6.4 (W.H. Press et al, 1992).

Parameters:
`x` - require 0<=x<=1
`p` - require p>0
`q` - require q>0
Returns:
0 if x<0, p<=0, q<=0 or p+q>2.55E305 and 1 if x>1 to avoid errors and over/underflow

### error

`public static double error(double x)`
Error function. Based on C-code for the error function developed at Sun Microsystems.

### complementaryError

`public static double complementaryError(double x)`
Complementary error function. Based on C-code for the error function developed at Sun Microsystems.