Class ExtendedPrecision
Extended precision computation is delegated to the DD class. The methods here
verify the arguments to the computations will not overflow.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final doubleThreshold for a big number that may overflow when squared.private static final intApproximate x squared value whereexp(-0.5*x*x) == 0.private static final intX squared value whereexp(-0.5*x*x)cannot increase accuracy using the round-off from x squared.private static final doubleScale down by 2^600.private static final doubleScale up by 2^600.private static final doubleThreshold for a small number that may underflow when squared.(package private) static final org.apache.commons.numbers.core.DDsqrt(2 pi) as a double-double number. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static doublecomputeSqrt2aa(double a) Computesqrt(2 * a * a).private static doublecomputeXsqrt2pi(double a) Computea * sqrt(2 * pi).(package private) static doubleexpmhxx(double x) Computeexp(-0.5*x*x)with high accuracy.private static doubleexpxx(double a, double b) Computeexp(a+b)with high accuracy assuminga+b = a.(package private) static doublesqrt2xx(double x) Computesqrt(2 * x * x).(package private) static doublexsqrt2pi(double x) Multiply the term by sqrt(2 pi).
-
Field Details
-
SQRT2PI
static final org.apache.commons.numbers.core.DD SQRT2PIsqrt(2 pi) as a double-double number. Divided into two parts from the value sqrt(2 pi) computed to 64 decimal digits. -
BIG
private static final double BIGThreshold for a big number that may overflow when squared. 2^500.- See Also:
-
SMALL
private static final double SMALLThreshold for a small number that may underflow when squared. 2^-500.- See Also:
-
SCALE_UP
private static final double SCALE_UPScale up by 2^600.- See Also:
-
SCALE_DOWN
private static final double SCALE_DOWNScale down by 2^600.- See Also:
-
EXP_M_HALF_XX_MIN_VALUE
private static final int EXP_M_HALF_XX_MIN_VALUEX squared value whereexp(-0.5*x*x)cannot increase accuracy using the round-off from x squared.- See Also:
-
EXP_M_HALF_XX_MAX_VALUE
private static final int EXP_M_HALF_XX_MAX_VALUEApproximate x squared value whereexp(-0.5*x*x) == 0. This is above-2 * ln(2^-1074)due to rounding performed within the exp function.- See Also:
-
-
Constructor Details
-
ExtendedPrecision
private ExtendedPrecision()No instances.
-
-
Method Details
-
xsqrt2pi
static double xsqrt2pi(double x) Multiply the term by sqrt(2 pi).- Parameters:
x- Value (assumed to be positive)- Returns:
- x * sqrt(2 pi)
-
computeXsqrt2pi
private static double computeXsqrt2pi(double a) Computea * sqrt(2 * pi).- Parameters:
a- Value- Returns:
- the result
-
sqrt2xx
static double sqrt2xx(double x) Computesqrt(2 * x * x).The result is computed using a high precision computation of
sqrt(2 * x * x)avoiding underflow or overflow ofxsquared.- Parameters:
x- Value (assumed to be positive)- Returns:
sqrt(2 * x * x)
-
computeSqrt2aa
private static double computeSqrt2aa(double a) Computesqrt(2 * a * a).- Parameters:
a- Value- Returns:
- the result
-
expmhxx
static double expmhxx(double x) Computeexp(-0.5*x*x)with high accuracy. This is performed using information in the round-off fromx*x.This is accurate at large x to 1 ulp until exp(-0.5*x*x) is close to sub-normal. For very small exp(-0.5*x*x) the adjustment is sub-normal and bits can be lost in the adjustment for a max observed error of
< 2ulp.At small x the accuracy cannot be improved over using exp(-0.5*x*x). This occurs at
x <= sqrt(2).- Parameters:
x- Value- Returns:
- exp(-0.5*x*x)
- See Also:
-
expxx
private static double expxx(double a, double b) Computeexp(a+b)with high accuracy assuminga+b = a.This is accurate at large positive a to 1 ulp. If a is negative and exp(a) is close to sub-normal a bit of precision may be lost when adjusting result as the adjustment is sub-normal (max observed error
< 2ulp). For the use case of multiplication of a number less than 1 by exp(-x*x), a = -x*x, the result will be sub-normal and the rounding error is lost.At small |a| the accuracy cannot be improved over using exp(a) as the round-off is too small to create terms that can adjust the standard result by more than 0.5 ulp. This occurs at
|a| <= 1.- Parameters:
a- High bits of a split numberb- Low bits of a split number- Returns:
- exp(a+b)
- See Also:
-