5 Special Functions

5.1 Overview

The special package of Commons-Math gathers several useful special functions not provided by java.lang.Math.

5.2 Erf functions

Erf contains several useful functions involving the Error Function, Erf.

FunctionMethodReference
Error FunctionerfSee Erf from MathWorld

5.3 Gamma functions

Class Gamma contains several useful functions involving the Gamma Function.

Gamma

Gamma.gamma(x) computes the Gamma function, Γ(x) (see MathWorld, DLMF). The accuracy of the Commons-Math implementation is assessed by comparaison with high precision values computed with the Maxima Computer Algebra System.

IntervalValues testedAverage errorStandard deviationMaximum error
-5 < x < -4x[i] = i / 1024, i = -5119, ..., -40970.49 ulps0.57 ulps3.0 ulps
-4 < x < -3x[i] = i / 1024, i = -4095, ..., -30730.36 ulps0.51 ulps2.0 ulps
-3 < x < -2x[i] = i / 1024, i = -3071, ..., -20490.41 ulps0.53 ulps2.0 ulps
-2 < x < -1x[i] = i / 1024, i = -2047, ..., -10250.37 ulps0.50 ulps2.0 ulps
-1 < x < 0x[i] = i / 1024, i = -1023, ..., -10.46 ulps0.54 ulps2.0 ulps
0 < x ≤ 8x[i] = i / 1024, i = 1, ..., 81920.33 ulps0.48 ulps2.0 ulps
8 < x ≤ 141x[i] = i / 64, i = 513, ..., 90241.32 ulps1.19 ulps7.0 ulps

Log Gamma

Gamma.logGamma(x) computes the natural logarithm of the Gamma function, log Γ(x), for x > 0 (see MathWorld, DLMF). The accuracy of the Commons-Math implementation is assessed by comparaison with high precision values computed with the Maxima Computer Algebra System.

IntervalValues testedAverage errorStandard deviationMaximum error
0 < x ≤ 8x[i] = i / 1024, i = 1, ..., 81920.32 ulps0.50 ulps4.0 ulps
8 < x ≤ 1024x[i] = i / 8, i = 65, ..., 81920.43 ulps0.53 ulps3.0 ulps
1024 < x ≤ 8192x[i], i = 1025, ..., 81920.53 ulps0.56 ulps3.0 ulps
8933.439345993791 ≤ x ≤ 1.75555970201398e+305x[i] = 2**(i / 8), i = 105, ..., 81120.35 ulps0.49 ulps2.0 ulps

Regularized Gamma

Gamma.regularizedGammaP(a, x) computes the value of the regularized Gamma function, P(a, x) (see MathWorld).

5.4 Beta functions

Beta contains several useful functions involving the Beta Function.

Log Beta

Beta.logBeta(a, b) computes the value of the natural logarithm of the Beta function, log B(a, b). (see MathWorld, DLMF). The accuracy of the Commons-Math implementation is assessed by comparaison with high precision values computed with the Maxima Computer Algebra System.

IntervalValues testedAverage errorStandard deviationMaximum error
0 < x ≤ 8 
0 < y ≤ 8
x[i] = i / 32, i = 1, ..., 256 
y[j] = j / 32, j = 1, ..., 256
1.80 ulps81.08 ulps14031.0 ulps
0 < x ≤ 8 
8 < y ≤ 16
x[i] = i / 32, i = 1, ..., 256 
y[j] = j / 32, j = 257, ..., 512
0.50 ulps3.64 ulps694.0 ulps
0 < x ≤ 8 
16 < y ≤ 256
x[i] = i / 32, i = 1, ..., 256 
y[j] = j, j = 17, ..., 256
1.04 ulps139.32 ulps34509.0 ulps
8 < x ≤ 16 
8 < y ≤ 16
x[i] = i / 32, i = 257, ..., 512 
y[j] = j / 32, j = 257, ..., 512
0.35 ulps0.48 ulps2.0 ulps
8 < x ≤ 16 
16 < y ≤ 256
x[i] = i / 32, i = 257, ..., 512 
y[j] = j, j = 17, ..., 256
0.31 ulps0.47 ulps2.0 ulps
16 < x ≤ 256 
16 < y ≤ 256
x[i] = i, i = 17, ..., 256 
y[j] = j, j = 17, ..., 256
0.35 ulps0.49 ulps2.0 ulps

Regularized Beta

(see MathWorld)