org.apache.commons.math.util

## Class FastMath

- java.lang.Object
- - org.apache.commons.math.util.FastMath

    public class FastMath
    extends Object

Faster, more accurate, portable alternative to `StrictMath`.

Additionally implements the following methods not found in StrictMath:

- `asinh(double)`
- `acosh(double)`
- `atanh(double)`

The following methods are found in StrictMath since 1.6 only

- `copySign(double, double)`
- `getExponent(double)`
- `nextAfter(double,double)`
- `nextUp(double)`
- `scalb(double, int)`
- `copySign(float, float)`
- `getExponent(float)`
- `nextAfter(float,double)`
- `nextUp(float)`
- `scalb(float, int)`

Since:
  2.2
Version:
  $Revision: 1074294 $ $Date: 2011-02-24 22:18:59 +0100 (jeu. 24 févr. 2011) $

### Field Summary

Fields
`private static double[]` `CBRTTWO` Table of 2^((n+2)/3)
`private static double[]` `COSINE_TABLE_A` Cosine table (high bits).
`private static double[]` `COSINE_TABLE_B` Cosine table (low bits).
`static double` `E` Napier's constant e, base of the natural logarithm.
`private static double[]` `EIGHTHS` Eighths.
`private static double[]` `EXP_FRAC_TABLE_A` Exponential over the range of 0 - 1 in increments of 2^-10 exp(x/1024) = expFracTableA[x] + expFracTableB[x].
`private static double[]` `EXP_FRAC_TABLE_B` Exponential over the range of 0 - 1 in increments of 2^-10 exp(x/1024) = expFracTableA[x] + expFracTableB[x].
`private static double[]` `EXP_INT_TABLE_A` Exponential evaluated at integer values, exp(x) = expIntTableA[x + 750] + expIntTableB[x+750].
`private static double[]` `EXP_INT_TABLE_B` Exponential evaluated at integer values, exp(x) = expIntTableA[x + 750] + expIntTableB[x+750]
`private static double[]` `FACT` Factorial table, for Taylor series expansions.
`private static long` `HEX_40000000` 0x40000000 - used to split a double into two parts, both with the low order bits cleared.
`private static double` `LN_2_A` log(2) (high bits).
`private static double` `LN_2_B` log(2) (low bits).
`private static double[][]` `LN_HI_PREC_COEF` Coefficients for log in the range of 1.0 < x < 1.0 + 2^-10.
`private static double[][]` `LN_MANT` Extended precision logarithm table over the range 1 - 2 in increments of 2^-10.
`private static double[][]` `LN_QUICK_COEF` Coefficients for log, when input 0.99 < x < 1.01.
`private static double[][]` `LN_SPLIT_COEF` Coefficients for slowLog.
`private static long` `MASK_30BITS` Mask used to clear low order 30 bits
`static double` `PI` Archimede's constant PI, ratio of circle circumference to diameter.
`private static long[]` `PI_O_4_BITS` Bits of pi/4, need for reducePayneHanek().
`private static long[]` `RECIP_2PI` Bits of 1/(2*pi), need for reducePayneHanek().
`private static double[]` `SINE_TABLE_A` Sine table (high bits).
`private static double[]` `SINE_TABLE_B` Sine table (low bits).
`private static double[]` `TANGENT_TABLE_A` Tangent table, used by atan() (high bits).
`private static double[]` `TANGENT_TABLE_B` Tangent table, used by atan() (low bits).
`private static double` `TWO_POWER_52` 2^52 - double numbers this large must be integral (no fraction) or NaN or Infinite

### Constructor Summary

Constructors
`private` `FastMath()` Private Constructor

### Method Summary

Methods
`static double` `abs(double x)` Absolute value.
`static float` `abs(float x)` Absolute value.
`static int` `abs(int x)` Absolute value.
`static long` `abs(long x)` Absolute value.
`static double` `acos(double x)` Compute the arc cosine of a number.
`static double` `acosh(double a)` Compute the inverse hyperbolic cosine of a number.
`static double` `asin(double x)` Compute the arc sine of a number.
`static double` `asinh(double a)` Compute the inverse hyperbolic sine of a number.
`static double` `atan(double x)` Arctangent function
`private static double` `atan(double xa, double xb, boolean leftPlane)` Internal helper function to compute arctangent.
`static double` `atan2(double y, double x)` Two arguments arctangent function
`static double` `atanh(double a)` Compute the inverse hyperbolic tangent of a number.
`private static void` `buildSinCosTables()` Build the sine and cosine tables.
`static double` `cbrt(double x)` Compute the cubic root of a number.
`static double` `ceil(double x)` Get the smallest whole number larger than x.
`static double` `copySign(double magnitude, double sign)` Returns the first argument with the sign of the second argument.
`static float` `copySign(float magnitude, float sign)` Returns the first argument with the sign of the second argument.
`static double` `cos(double x)` Cosine function
`static double` `cosh(double x)` Compute the hyperbolic cosine of a number.
`private static double` `cosQ(double xa, double xb)` Compute cosine in the first quadrant by subtracting input from PI/2 and then calling sinQ.
`private static double` `doubleHighPart(double d)` Get the high order bits from the mantissa.
`static double` `exp(double x)` Exponential function.
`private static double` `exp(double x, double extra, double[] hiPrec)` Internal helper method for exponential function.
`private static double` `expint(int p, double[] result)` Compute exp(p) for a integer p in extended precision.
`static double` `expm1(double x)` Compute exp(x) - 1
`private static double` `expm1(double x, double[] hiPrecOut)` Internal helper method for expm1
`static double` `floor(double x)` Get the largest whole number smaller than x.
`static int` `getExponent(double d)` Return the exponent of a double number, removing the bias.
`static int` `getExponent(float f)` Return the exponent of a float number, removing the bias.
`static double` `hypot(double x, double y)` Returns the hypotenuse of a triangle with sides `x` and `y` - sqrt(x2 +y2) avoiding intermediate overflow or underflow.
`static double` `IEEEremainder(double dividend, double divisor)` Computes the remainder as prescribed by the IEEE 754 standard.
`static double` `log(double x)` Natural logarithm.
`private static double` `log(double x, double[] hiPrec)` Internal helper method for natural logarithm function.
`static double` `log10(double x)` Compute the base 10 logarithm.
`static double` `log1p(double x)` Compute log(1 + x).
`static double` `max(double a, double b)` Compute the maximum of two values
`static float` `max(float a, float b)` Compute the maximum of two values
`static int` `max(int a, int b)` Compute the maximum of two values
`static long` `max(long a, long b)` Compute the maximum of two values
`static double` `min(double a, double b)` Compute the minimum of two values
`static float` `min(float a, float b)` Compute the minimum of two values
`static int` `min(int a, int b)` Compute the minimum of two values
`static long` `min(long a, long b)` Compute the minimum of two values
`static double` `nextAfter(double d, double direction)` Get the next machine representable number after a number, moving in the direction of another number.
`static float` `nextAfter(float f, double direction)` Get the next machine representable number after a number, moving in the direction of another number.
`static double` `nextUp(double a)` Compute next number towards positive infinity.
`static float` `nextUp(float a)` Compute next number towards positive infinity.
`private static double` `polyCosine(double x)` Computes cos(x) - 1, where |x| < 1/16.
`private static double` `polySine(double x)` Computes sin(x) - x, where |x| < 1/16.
`static double` `pow(double x, double y)` Power function.
`private static void` `quadMult(double[] a, double[] b, double[] result)` Compute (a[0] + a[1]) * (b[0] + b[1]) in extended precision.
`static double` `random()` Returns a pseudo-random number between 0.0 and 1.0.
`private static void` `reducePayneHanek(double x, double[] result)` Reduce the input argument using the Payne and Hanek method.
`private static void` `resplit(double[] a)` Recompute a split.
`static double` `rint(double x)` Get the whole number that is the nearest to x, or the even one if x is exactly half way between two integers.
`static long` `round(double x)` Get the closest long to x.
`static int` `round(float x)` Get the closest int to x.
`static double` `scalb(double d, int n)` Multiply a double number by a power of 2.
`static float` `scalb(float f, int n)` Multiply a float number by a power of 2.
`static double` `signum(double a)` Compute the signum of a number.
`static float` `signum(float a)` Compute the signum of a number.
`static double` `sin(double x)` Sine function.
`static double` `sinh(double x)` Compute the hyperbolic sine of a number.
`private static double` `sinQ(double xa, double xb)` Compute sine over the first quadrant (0 < x < pi/2).
`private static double` `slowCos(double x, double[] result)` For x between 0 and pi/4 compute cosine
`private static double` `slowexp(double x, double[] result)` For x between 0 and 1, returns exp(x), uses extended precision
`private static double[]` `slowLog(double xi)` xi in the range of [1, 2].
`private static double` `slowSin(double x, double[] result)` For x between 0 and pi/4 compute sine.
`private static void` `split(double d, double[] split)` Compute split[0], split[1] such that their sum is equal to d, and split[0] has its 30 least significant bits as zero.
`private static void` `splitAdd(double[] a, double[] b, double[] ans)` Add two numbers in split form.
`private static void` `splitMult(double[] a, double[] b, double[] ans)` Multiply two numbers in split form.
`private static void` `splitReciprocal(double[] in, double[] result)` Compute the reciprocal of in.
`static double` `sqrt(double a)` Compute the square root of a number.
`static double` `tan(double x)` Tangent function
`static double` `tanh(double x)` Compute the hyperbolic tangent of a number.
`private static double` `tanQ(double xa, double xb, boolean cotanFlag)` Compute tangent (or cotangent) over the first quadrant.
`static double` `toDegrees(double x)` Convert radians to degrees, with error of less than 0.5 ULP
`static double` `toRadians(double x)` Convert degrees to radians, with error of less than 0.5 ULP
`static double` `ulp(double x)` Compute least significant bit (Unit in Last Position) for a number.
`static float` `ulp(float x)` Compute least significant bit (Unit in Last Position) for a number.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Field Detail

#### PI

    public static final double PI

Archimede's constant PI, ratio of circle circumference to diameter.

See Also:
  Constant Field Values

#### E

    public static final double E

Napier's constant e, base of the natural logarithm.

See Also:
  Constant Field Values

#### EXP_INT_TABLE_A

    private static final double[] EXP_INT_TABLE_A

Exponential evaluated at integer values, exp(x) = expIntTableA[x + 750] + expIntTableB[x+750].

#### EXP_INT_TABLE_B

    private static final double[] EXP_INT_TABLE_B

Exponential evaluated at integer values, exp(x) = expIntTableA[x + 750] + expIntTableB[x+750]

#### EXP_FRAC_TABLE_A

    private static final double[] EXP_FRAC_TABLE_A

Exponential over the range of 0 - 1 in increments of 2^-10 exp(x/1024) = expFracTableA[x] + expFracTableB[x].

#### EXP_FRAC_TABLE_B

    private static final double[] EXP_FRAC_TABLE_B

Exponential over the range of 0 - 1 in increments of 2^-10 exp(x/1024) = expFracTableA[x] + expFracTableB[x].

#### FACT

    private static final double[] FACT

Factorial table, for Taylor series expansions.

#### LN_MANT

    private static final double[][] LN_MANT

Extended precision logarithm table over the range 1 - 2 in increments of 2^-10.

#### LN_2_A

    private static final double LN_2_A

log(2) (high bits).

See Also:
  Constant Field Values

#### LN_2_B

    private static final double LN_2_B

log(2) (low bits).

See Also:
  Constant Field Values

#### LN_SPLIT_COEF

    private static final double[][] LN_SPLIT_COEF

Coefficients for slowLog.

#### LN_QUICK_COEF

    private static final double[][] LN_QUICK_COEF

Coefficients for log, when input 0.99 < x < 1.01.

#### LN_HI_PREC_COEF

    private static final double[][] LN_HI_PREC_COEF

Coefficients for log in the range of 1.0 < x < 1.0 + 2^-10.

#### SINE_TABLE_A

    private static final double[] SINE_TABLE_A

Sine table (high bits).

#### SINE_TABLE_B

    private static final double[] SINE_TABLE_B

Sine table (low bits).

#### COSINE_TABLE_A

    private static final double[] COSINE_TABLE_A

Cosine table (high bits).

#### COSINE_TABLE_B

    private static final double[] COSINE_TABLE_B

Cosine table (low bits).

#### TANGENT_TABLE_A

    private static final double[] TANGENT_TABLE_A

Tangent table, used by atan() (high bits).

#### TANGENT_TABLE_B

    private static final double[] TANGENT_TABLE_B

Tangent table, used by atan() (low bits).

#### RECIP_2PI

    private static final long[] RECIP_2PI

Bits of 1/(2*pi), need for reducePayneHanek().

#### PI_O_4_BITS

    private static final long[] PI_O_4_BITS

Bits of pi/4, need for reducePayneHanek().

#### EIGHTHS

    private static final double[] EIGHTHS

Eighths. This is used by sinQ, because its faster to do a table lookup than a multiply in this time-critical routine

#### CBRTTWO

    private static final double[] CBRTTWO

Table of 2^((n+2)/3)

#### HEX_40000000

    private static final long HEX_40000000

0x40000000 - used to split a double into two parts, both with the low order bits cleared. Equivalent to 2^30.

See Also:
  Constant Field Values

#### MASK_30BITS

    private static final long MASK_30BITS

Mask used to clear low order 30 bits

See Also:
  Constant Field Values

#### TWO_POWER_52

    private static final double TWO_POWER_52

2^52 - double numbers this large must be integral (no fraction) or NaN or Infinite

See Also:
  Constant Field Values

### Constructor Detail

#### FastMath

    private FastMath()

Private Constructor

### Method Detail

#### doubleHighPart

    private static double doubleHighPart(double d)

Get the high order bits from the mantissa. Equivalent to adding and subtracting HEX_40000 but also works for very large numbers

Parameters:
  `d` - the value to split
Returns:
  the high order part of the mantissa

#### sqrt

    public static double sqrt(double a)

Compute the square root of a number.

Note: this implementation currently delegates to `Math.sqrt(double)`

Parameters:
  `a` - number on which evaluation is done
Returns:
  square root of a

#### cosh

    public static double cosh(double x)

Compute the hyperbolic cosine of a number.

Parameters:
  `x` - number on which evaluation is done
Returns:
  hyperbolic cosine of x

#### sinh

    public static double sinh(double x)

Compute the hyperbolic sine of a number.

Parameters:
  `x` - number on which evaluation is done
Returns:
  hyperbolic sine of x

#### tanh

    public static double tanh(double x)

Compute the hyperbolic tangent of a number.

Parameters:
  `x` - number on which evaluation is done
Returns:
  hyperbolic tangent of x

#### acosh

    public static double acosh(double a)

Compute the inverse hyperbolic cosine of a number.

Parameters:
  `a` - number on which evaluation is done
Returns:
  inverse hyperbolic cosine of a

#### asinh

    public static double asinh(double a)

Compute the inverse hyperbolic sine of a number.

Parameters:
  `a` - number on which evaluation is done
Returns:
  inverse hyperbolic sine of a

#### atanh

    public static double atanh(double a)

Compute the inverse hyperbolic tangent of a number.

Parameters:
  `a` - number on which evaluation is done
Returns:
  inverse hyperbolic tangent of a

#### signum

    public static double signum(double a)

Compute the signum of a number. The signum is -1 for negative numbers, +1 for positive numbers and 0 otherwise

Parameters:
  `a` - number on which evaluation is done
Returns:
  -1.0, -0.0, +0.0, +1.0 or NaN depending on sign of a

#### signum

    public static float signum(float a)

Compute the signum of a number. The signum is -1 for negative numbers, +1 for positive numbers and 0 otherwise

Parameters:
  `a` - number on which evaluation is done
Returns:
  -1.0, -0.0, +0.0, +1.0 or NaN depending on sign of a

#### nextUp

    public static double nextUp(double a)

Compute next number towards positive infinity.

Parameters:
  `a` - number to which neighbor should be computed
Returns:
  neighbor of a towards positive infinity

#### nextUp

    public static float nextUp(float a)

Compute next number towards positive infinity.

Parameters:
  `a` - number to which neighbor should be computed
Returns:
  neighbor of a towards positive infinity

#### random

    public static double random()

Returns a pseudo-random number between 0.0 and 1.0.

Note: this implementation currently delegates to `Math.random()`

Returns:
  a random number between 0.0 and 1.0

#### exp

    public static double exp(double x)

Exponential function. Computes exp(x), function result is nearly rounded. It will be correctly rounded to the theoretical value for 99.9% of input values, otherwise it will have a 1 UPL error. Method: Lookup intVal = exp(int(x)) Lookup fracVal = exp(int(x-int(x) / 1024.0) * 1024.0 ); Compute z as the exponential of the remaining bits by a polynomial minus one exp(x) = intVal * fracVal * (1 + z) Accuracy: Calculation is done with 63 bits of precision, so result should be correctly rounded for 99.9% of input values, with less than 1 ULP error otherwise.

Parameters:
  `x` - a double
Returns:
  double ex

#### exp

    private static double exp(double x,
             double extra,
             double[] hiPrec)

Internal helper method for exponential function.

Parameters:
  `x` - original argument of the exponential function
  `extra` - extra bits of precision on input (To Be Confirmed)
  `hiPrec` - extra bits of precision on output (To Be Confirmed)
Returns:
  exp(x)

#### expm1

    public static double expm1(double x)

Compute exp(x) - 1

Parameters:
  `x` - number to compute shifted exponential
Returns:
  exp(x) - 1

#### expm1

    private static double expm1(double x,
               double[] hiPrecOut)

Internal helper method for expm1

Parameters:
  `x` - number to compute shifted exponential
  `hiPrecOut` - receive high precision result for -1.0 < x < 1.0
Returns:
  exp(x) - 1

#### slowexp

    private static double slowexp(double x,
                 double[] result)

For x between 0 and 1, returns exp(x), uses extended precision

Parameters:
  `x` - argument of exponential
  `result` - placeholder where to place exp(x) split in two terms for extra precision (i.e. exp(x) = result[0] ° result[1]
Returns:
  exp(x)

#### split

    private static void split(double d,
             double[] split)

Compute split[0], split[1] such that their sum is equal to d, and split[0] has its 30 least significant bits as zero.

Parameters:
  `d` - number to split
  `split` - placeholder where to place the result

#### resplit

    private static void resplit(double[] a)

Recompute a split.

Parameters:
  `a` - input/out array containing the split, changed on output

#### splitMult

    private static void splitMult(double[] a,
                 double[] b,
                 double[] ans)

Multiply two numbers in split form.

Parameters:
  `a` - first term of multiplication
  `b` - second term of multiplication
  `ans` - placeholder where to put the result

#### splitAdd

    private static void splitAdd(double[] a,
                double[] b,
                double[] ans)

Add two numbers in split form.

Parameters:
  `a` - first term of addition
  `b` - second term of addition
  `ans` - placeholder where to put the result

#### splitReciprocal

    private static void splitReciprocal(double[] in,
                       double[] result)

Compute the reciprocal of in. Use the following algorithm. in = c + d. want to find x + y such that x+y = 1/(c+d) and x is much larger than y and x has several zero bits on the right. Set b = 1/(2^22), a = 1 - b. Thus (a+b) = 1. Use following identity to compute (a+b)/(c+d) (a+b)/(c+d) = a/c + (bc - ad) / (c^2 + cd) set x = a/c and y = (bc - ad) / (c^2 + cd) This will be close to the right answer, but there will be some rounding in the calculation of X. So by carefully computing 1 - (c+d)(x+y) we can compute an error and add that back in. This is done carefully so that terms of similar size are subtracted first.

Parameters:
  `in` - initial number, in split form
  `result` - placeholder where to put the result

#### quadMult

    private static void quadMult(double[] a,
                double[] b,
                double[] result)

Compute (a[0] + a[1]) * (b[0] + b[1]) in extended precision.

Parameters:
  `a` - first term of the multiplication
  `b` - second term of the multiplication
  `result` - placeholder where to put the result

#### expint

    private static double expint(int p,
                double[] result)

Compute exp(p) for a integer p in extended precision.

Parameters:
  `p` - integer whose exponential is requested
  `result` - placeholder where to put the result in extended precision
Returns:
  exp(p) in standard precision (equal to result[0] + result[1])

#### log

    public static double log(double x)

Natural logarithm.

Parameters:
  `x` - a double
Returns:
  log(x)

#### log

    private static double log(double x,
             double[] hiPrec)

Internal helper method for natural logarithm function.

Parameters:
  `x` - original argument of the natural logarithm function
  `hiPrec` - extra bits of precision on output (To Be Confirmed)
Returns:
  log(x)

#### log1p

    public static double log1p(double x)

Compute log(1 + x).

Parameters:
  `x` - a number
Returns:
  log(1 + x)

#### log10

    public static double log10(double x)

Compute the base 10 logarithm.

Parameters:
  `x` - a number
Returns:
  log10(x)

#### pow

    public static double pow(double x,
             double y)

Power function. Compute x^y.

Parameters:
  `x` - a double
  `y` - a double
Returns:
  double

#### slowLog

    private static double[] slowLog(double xi)

xi in the range of [1, 2]. 3 5 7 x+1 / x x x \ ln ----- = 2 * | x + ---- + ---- + ---- + ... | 1-x \ 3 5 7 / So, compute a Remez approximation of the following function ln ((sqrt(x)+1)/(1-sqrt(x))) / x This will be an even function with only positive coefficents. x is in the range [0 - 1/3]. Transform xi for input to the above function by setting x = (xi-1)/(xi+1). Input to the polynomial is x^2, then the result is multiplied by x.

Parameters:
  `xi` - number from which log is requested
Returns:
  log(xi)

#### slowSin

    private static double slowSin(double x,
                 double[] result)

For x between 0 and pi/4 compute sine.

Parameters:
  `x` - number from which sine is requested
  `result` - placeholder where to put the result in extended precision
Returns:
  sin(x)

#### slowCos

    private static double slowCos(double x,
                 double[] result)

For x between 0 and pi/4 compute cosine

Parameters:
  `x` - number from which cosine is requested
  `result` - placeholder where to put the result in extended precision
Returns:
  cos(x)

#### buildSinCosTables

    private static void buildSinCosTables()

Build the sine and cosine tables.

#### polySine

    private static double polySine(double x)

Computes sin(x) - x, where |x| < 1/16. Use a Remez polynomial approximation.

Parameters:
  `x` - a number smaller than 1/16
Returns:
  sin(x) - x

#### polyCosine

    private static double polyCosine(double x)

Computes cos(x) - 1, where |x| < 1/16. Use a Remez polynomial approximation.

Parameters:
  `x` - a number smaller than 1/16
Returns:
  cos(x) - 1

#### sinQ

    private static double sinQ(double xa,
              double xb)

Compute sine over the first quadrant (0 < x < pi/2). Use combination of table lookup and rational polynomial expansion.

Parameters:
  `xa` - number from which sine is requested
  `xb` - extra bits for x (may be 0.0)
Returns:
  sin(xa + xb)

#### cosQ

    private static double cosQ(double xa,
              double xb)

Compute cosine in the first quadrant by subtracting input from PI/2 and then calling sinQ. This is more accurate as the input approaches PI/2.

Parameters:
  `xa` - number from which cosine is requested
  `xb` - extra bits for x (may be 0.0)
Returns:
  cos(xa + xb)

#### tanQ

    private static double tanQ(double xa,
              double xb,
              boolean cotanFlag)

Compute tangent (or cotangent) over the first quadrant. 0 < x < pi/2 Use combination of table lookup and rational polynomial expansion.

Parameters:
  `xa` - number from which sine is requested
  `xb` - extra bits for x (may be 0.0)
  `cotanFlag` - if true, compute the cotangent instead of the tangent
Returns:
  tan(xa+xb) (or cotangent, depending on cotanFlag)

#### reducePayneHanek

    private static void reducePayneHanek(double x,
                        double[] result)

Reduce the input argument using the Payne and Hanek method. This is good for all inputs 0.0 < x < inf Output is remainder after dividing by PI/2 The result array should contain 3 numbers. result[0] is the integer portion, so mod 4 this gives the quadrant. result[1] is the upper bits of the remainder result[2] is the lower bits of the remainder

Parameters:
  `x` - number to reduce
  `result` - placeholder where to put the result

#### sin

    public static double sin(double x)

Sine function.

Parameters:
  `x` - a number
Returns:
  sin(x)

#### cos

    public static double cos(double x)

Cosine function

Parameters:
  `x` - a number
Returns:
  cos(x)

#### tan

    public static double tan(double x)

Tangent function

Parameters:
  `x` - a number
Returns:
  tan(x)

#### atan

    public static double atan(double x)

Arctangent function

Parameters:
  `x` - a number
Returns:
  atan(x)

#### atan

    private static double atan(double xa,
              double xb,
              boolean leftPlane)

Internal helper function to compute arctangent.

Parameters:
  `xa` - number from which arctangent is requested
  `xb` - extra bits for x (may be 0.0)
  `leftPlane` - if true, result angle must be put in the left half plane
Returns:
  atan(xa + xb) (or angle shifted by `PI` if leftPlane is true)

#### atan2

    public static double atan2(double y,
               double x)

Two arguments arctangent function

Parameters:
  `y` - ordinate
  `x` - abscissa
Returns:
  phase angle of point (x,y) between `-PI` and `PI`

#### asin

    public static double asin(double x)

Compute the arc sine of a number.

Parameters:
  `x` - number on which evaluation is done
Returns:
  arc sine of x

#### acos

    public static double acos(double x)

Compute the arc cosine of a number.

Parameters:
  `x` - number on which evaluation is done
Returns:
  arc cosine of x

#### cbrt

    public static double cbrt(double x)

Compute the cubic root of a number.

Parameters:
  `x` - number on which evaluation is done
Returns:
  cubic root of x

#### toRadians

    public static double toRadians(double x)

Convert degrees to radians, with error of less than 0.5 ULP

Parameters:
  `x` - angle in degrees
Returns:
  x converted into radians

#### toDegrees

    public static double toDegrees(double x)

Convert radians to degrees, with error of less than 0.5 ULP

Parameters:
  `x` - angle in radians
Returns:
  x converted into degrees

#### abs

    public static int abs(int x)

Absolute value.

Parameters:
  `x` - number from which absolute value is requested
Returns:
  abs(x)

#### abs

    public static long abs(long x)

Absolute value.

Parameters:
  `x` - number from which absolute value is requested
Returns:
  abs(x)

#### abs

    public static float abs(float x)

Absolute value.

Parameters:
  `x` - number from which absolute value is requested
Returns:
  abs(x)

#### abs

    public static double abs(double x)

Absolute value.

Parameters:
  `x` - number from which absolute value is requested
Returns:
  abs(x)

#### ulp

    public static double ulp(double x)

Compute least significant bit (Unit in Last Position) for a number.

Parameters:
  `x` - number from which ulp is requested
Returns:
  ulp(x)

#### ulp

    public static float ulp(float x)

Compute least significant bit (Unit in Last Position) for a number.

Parameters:
  `x` - number from which ulp is requested
Returns:
  ulp(x)

#### scalb

    public static double scalb(double d,
               int n)

Multiply a double number by a power of 2.

Parameters:
  `d` - number to multiply
  `n` - power of 2
Returns:
  d × 2n

#### scalb

    public static float scalb(float f,
              int n)

Multiply a float number by a power of 2.

Parameters:
  `f` - number to multiply
  `n` - power of 2
Returns:
  f × 2n

#### nextAfter

    public static double nextAfter(double d,
                   double direction)

Get the next machine representable number after a number, moving in the direction of another number.

The ordering is as follows (increasing):

- -INFINITY
- -MAX_VALUE
- -MIN_VALUE
- -0.0
- +0.0
- +MIN_VALUE
- +MAX_VALUE
- +INFINITY

If arguments compare equal, then the second argument is returned.

If `direction` is greater than `d`, the smallest machine representable number strictly greater than `d` is returned; if less, then the largest representable number strictly less than `d` is returned.

If `d` is infinite and direction does not bring it back to finite numbers, it is returned unchanged.

Parameters:
  `d` - base number
  `direction` - (the only important thing is whether `direction` is greater or smaller than `d`)
Returns:
  the next machine representable number in the specified direction

#### nextAfter

    public static float nextAfter(float f,
                  double direction)

Get the next machine representable number after a number, moving in the direction of another number.

The ordering is as follows (increasing):

- -INFINITY
- -MAX_VALUE
- -MIN_VALUE
- -0.0
- +0.0
- +MIN_VALUE
- +MAX_VALUE
- +INFINITY

If arguments compare equal, then the second argument is returned.

If `direction` is greater than `f`, the smallest machine representable number strictly greater than `f` is returned; if less, then the largest representable number strictly less than `f` is returned.

If `f` is infinite and direction does not bring it back to finite numbers, it is returned unchanged.

Parameters:
  `f` - base number
  `direction` - (the only important thing is whether `direction` is greater or smaller than `f`)
Returns:
  the next machine representable number in the specified direction

#### floor

    public static double floor(double x)

Get the largest whole number smaller than x.

Parameters:
  `x` - number from which floor is requested
Returns:
  a double number f such that f is an integer f <= x < f + 1.0

#### ceil

    public static double ceil(double x)

Get the smallest whole number larger than x.

Parameters:
  `x` - number from which ceil is requested
Returns:
  a double number c such that c is an integer c - 1.0 < x <= c

#### rint

    public static double rint(double x)

Get the whole number that is the nearest to x, or the even one if x is exactly half way between two integers.

Parameters:
  `x` - number from which nearest whole number is requested
Returns:
  a double number r such that r is an integer r - 0.5 <= x <= r + 0.5

#### round

    public static long round(double x)

Get the closest long to x.

Parameters:
  `x` - number from which closest long is requested
Returns:
  closest long to x

#### round

    public static int round(float x)

Get the closest int to x.

Parameters:
  `x` - number from which closest int is requested
Returns:
  closest int to x

#### min

    public static int min(int a,
          int b)

Compute the minimum of two values

Parameters:
  `a` - first value
  `b` - second value
Returns:
  a if a is lesser or equal to b, b otherwise

#### min

    public static long min(long a,
           long b)

Compute the minimum of two values

Parameters:
  `a` - first value
  `b` - second value
Returns:
  a if a is lesser or equal to b, b otherwise

#### min

    public static float min(float a,
            float b)

Compute the minimum of two values

Parameters:
  `a` - first value
  `b` - second value
Returns:
  a if a is lesser or equal to b, b otherwise

#### min

    public static double min(double a,
             double b)

Compute the minimum of two values

Parameters:
  `a` - first value
  `b` - second value
Returns:
  a if a is lesser or equal to b, b otherwise

#### max

    public static int max(int a,
          int b)

Compute the maximum of two values

Parameters:
  `a` - first value
  `b` - second value
Returns:
  b if a is lesser or equal to b, a otherwise

#### max

    public static long max(long a,
           long b)

Compute the maximum of two values

Parameters:
  `a` - first value
  `b` - second value
Returns:
  b if a is lesser or equal to b, a otherwise

#### max

    public static float max(float a,
            float b)

Compute the maximum of two values

Parameters:
  `a` - first value
  `b` - second value
Returns:
  b if a is lesser or equal to b, a otherwise

#### max

    public static double max(double a,
             double b)

Compute the maximum of two values

Parameters:
  `a` - first value
  `b` - second value
Returns:
  b if a is lesser or equal to b, a otherwise

#### hypot

    public static double hypot(double x,
               double y)

Returns the hypotenuse of a triangle with sides `x` and `y` - sqrt(x2 +y2)
avoiding intermediate overflow or underflow.

- If either argument is infinite, then the result is positive infinity.
- else, if either argument is NaN then the result is NaN.

Parameters:
  `x` - a value
  `y` - a value
Returns:
  sqrt(x2 +y2)

#### IEEEremainder

    public static double IEEEremainder(double dividend,
                       double divisor)

Computes the remainder as prescribed by the IEEE 754 standard. The remainder value is mathematically equal to `x - y*n` where `n` is the mathematical integer closest to the exact mathematical value of the quotient `x/y`. If two mathematical integers are equally close to `x/y` then `n` is the integer that is even.

- If either operand is NaN, the result is NaN.
- If the result is not NaN, the sign of the result equals the sign of the dividend.
- If the dividend is an infinity, or the divisor is a zero, or both, the result is NaN.
- If the dividend is finite and the divisor is an infinity, the result equals the dividend.
- If the dividend is a zero and the divisor is finite, the result equals the dividend.

Note: this implementation currently delegates to `StrictMath.IEEEremainder(double, double)`

Parameters:
  `dividend` - the number to be divided
  `divisor` - the number by which to divide
Returns:
  the remainder, rounded

#### copySign

    public static double copySign(double magnitude,
                  double sign)

Returns the first argument with the sign of the second argument. A NaN `sign` argument is treated as positive.

Parameters:
  `magnitude` - the value to return
  `sign` - the sign for the returned value
Returns:
  the magnitude with the same sign as the `sign` argument

#### copySign

    public static float copySign(float magnitude,
                 float sign)

Returns the first argument with the sign of the second argument. A NaN `sign` argument is treated as positive.

Parameters:
  `magnitude` - the value to return
  `sign` - the sign for the returned value
Returns:
  the magnitude with the same sign as the `sign` argument

#### getExponent

    public static int getExponent(double d)

Return the exponent of a double number, removing the bias.

For double numbers of the form 2x, the unbiased exponent is exactly x.

Parameters:
  `d` - number from which exponent is requested
Returns:
  exponent for d in IEEE754 representation, without bias

#### getExponent

    public static int getExponent(float f)

Return the exponent of a float number, removing the bias.

For float numbers of the form 2x, the unbiased exponent is exactly x.

Parameters:
  `f` - number from which exponent is requested
Returns:
  exponent for d in IEEE754 representation, without bias