public final class MathUtil extends Object
Modifier and Type | Method and Description |
---|---|
static double |
acosh(double a)
Calculates inverse hyperbolic cosine of a
double value. |
static double |
asinh(double a)
Calculates inverse hyperbolic sine of a
double value. |
static double |
atanh(double a)
Calculates inverse hyperbolic tangent of a
double value. |
static long |
gcd(long a,
long b)
|
static double |
log(double base,
double x)
Calculates logarithm in a given base with doubles.
|
static int |
log(long x,
int base)
Returns
x <= 0 ? 0 : Math.floor(Math.log(x) / Math.log(base)) |
static double |
sumRelativeErrorBound(int numValues)
Return a relative error bound for a sum of
numValues positive doubles,
computed using recursive summation, ie. |
public static int log(long x, int base)
x <= 0 ? 0 : Math.floor(Math.log(x) / Math.log(base))
base
- must be > 1
public static double log(double base, double x)
public static long gcd(long a, long b)
a
and b
,
consistently with BigInteger.gcd(BigInteger)
.
NOTE: A greatest common divisor must be positive, but
2^64
cannot be expressed as a long although it
is the GCD of Long.MIN_VALUE
and 0
and the GCD of
Long.MIN_VALUE
and Long.MIN_VALUE
. So in these 2 cases,
and only them, this method will return Long.MIN_VALUE
.
public static double asinh(double a)
double
value.
Special cases:
public static double acosh(double a)
double
value.
Special cases:
public static double atanh(double a)
double
value.
Special cases:
public static double sumRelativeErrorBound(int numValues)
numValues
positive doubles,
computed using recursive summation, ie. sum = x1 + ... + xn.
NOTE: This only works if all values are POSITIVE so that Σ |xi| == |Σ xi|.
This uses formula 3.5 from Higham, Nicholas J. (1993),
"The accuracy of floating point summation", SIAM Journal on Scientific Computing.Copyright © 2000-2021 Apache Software Foundation. All Rights Reserved.