org.apache.commons.math3.special
public class Erf extends Object
Modifier and Type | Field and Description |
---|---|
private static double |
X_CRIT
The number
X_CRIT is used by erf(double, double) internally. |
Modifier | Constructor and Description |
---|---|
private |
Erf()
Default constructor.
|
private static final double X_CRIT
X_CRIT
is used by erf(double, double)
internally.
This number solves erf(x)=0.5
within 1ulp.
More precisely, the current implementations of
erf(double)
and erfc(double)
satisfy:erf(X_CRIT) < 0.5
,erf(Math.nextUp(X_CRIT) > 0.5
,erfc(X_CRIT) = 0.5
, anderfc(Math.nextUp(X_CRIT) < 0.5
public static double erf(double x)
erf(x) = 2/√π 0∫x e-t2dt
This implementation computes erf(x) using the
regularized gamma function
,
following Erf, equation (3)
The value returned is always between -1 and 1 (inclusive).
If abs(x) > 40
, then erf(x)
is indistinguishable from
either 1 or -1 as a double, so the appropriate extreme value is returned.
x
- the value.MaxCountExceededException
- if the algorithm fails to converge.Gamma.regularizedGammaP(double, double, double, int)
public static double erfc(double x)
erfc(x) = 2/√π x∫∞ e-t2dt
= 1 - erf(x)
This implementation computes erfc(x) using the
regularized gamma function
,
following Erf, equation (3).
The value returned is always between 0 and 2 (inclusive).
If abs(x) > 40
, then erf(x)
is indistinguishable from
either 0 or 2 as a double, so the appropriate extreme value is returned.
x
- the valueMaxCountExceededException
- if the algorithm fails to converge.Gamma.regularizedGammaQ(double, double, double, int)
public static double erf(double x1, double x2)
x1
- the first valuex2
- the second valueCopyright (c) 2003-2013 Apache Software Foundation