Class SpecialMathUtils
- Version:
- 1.1
- Author:
- Mark Hale
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final doubleThe largest argument for whichgamma(x)is representable in the machine.static final doubleThe largest argument for whichlogGamma(x)is representable in the machine. -
Method Summary
Modifier and TypeMethodDescriptionstatic doubleairy(double x) Airy function.static doublebesselFirstOne(double x) Bessel function of first kind, order one.static doublebesselFirstZero(double x) Bessel function of first kind, order zero.static doublebesselSecondOne(double x) Bessel function of second kind, order one.static doublebesselSecondZero(double x) Bessel function of second kind, order zero.static doublebeta(double p, double q) Beta function.static doublechebyshev(double x, double[] series) Evaluates a Chebyshev series.static doublecomplementaryError(double x) Complementary error function.static doubleerror(double x) Error function.static doublegamma(double x) Gamma function.static doubleincompleteBeta(double x, double p, double q) Incomplete beta function.static doubleincompleteGamma(double a, double x) Incomplete gamma function.static doublelogBeta(double p, double q) The natural logarithm of the beta function.static doublelogGamma(double x) The natural logarithm of the gamma function.static doublemodBesselFirstOne(double x) Modified Bessel function of first kind, order one.static doublemodBesselFirstZero(double x) Modified Bessel function of first kind, order zero.
-
Field Details
-
GAMMA_X_MAX_VALUE
public static final double GAMMA_X_MAX_VALUEThe largest argument for whichgamma(x)is representable in the machine.- See Also:
-
LOG_GAMMA_X_MAX_VALUE
public static final double LOG_GAMMA_X_MAX_VALUEThe largest argument for whichlogGamma(x)is representable in the machine.- See Also:
-
-
Method Details
-
chebyshev
public static double chebyshev(double x, double[] series) Evaluates a Chebyshev series.- Parameters:
x- value at which to evaluate seriesseries- 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:- "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.
- 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:- W. J. Cody and K. E. Hillstrom, 'Chebyshev Approximations for the Natural Logarithm of the Gamma Function,' Math. Comp. 21, 1967, pp. 198-203.
- K. E. Hillstrom, ANL/AMD Program ANLC366S, DGAMMA/DLGAMA, May, 1969.
- 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 invalid input: '<' 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 invalid input: '<' 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>=0x- require x>=0- Returns:
- 0 if xinvalid input: '<'0, ainvalid input: '<'=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>0q- require q>0- Returns:
- 0 if pinvalid input: '<'=0, qinvalid input: '<'=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>0q- require q>0- Returns:
- 0 if pinvalid input: '<'=0, qinvalid input: '<'=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 0invalid input: '<'=xinvalid input: '<'=1p- require p>0q- require q>0- Returns:
- 0 if xinvalid input: '<'0, pinvalid input: '<'=0, qinvalid input: '<'=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.
-