Class MathFunctions
java.lang.Object
org.mariuszgromada.math.mxparser.mathcollection.MathFunctions
MathFunctions - the most popular math functions. Many of function implemented by this class
could be found in java Math package (in fact functions from MathFunctions typically calls
original functions from the Math package). The reason why it was "re-implemented" is:
if you decide to implement your own function you do not need to change anything in the parser,
jut modify function implementation in this class.
- Version:
- 4.4.2
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic final double
abs
(double a) Absolute value.static final double
acos
(double a) Arcus cosine - inverse trigonometric cosine functionstatic final double
acosec
(double a) Arcus cosecant - inverse trigonometric cosecant functionstatic final double
actan
(double a) Arcus cotangent - inverse trigonometric cotangent functionstatic final boolean
almostEqual
(double a, double b) Check whether two double values are almost equal.static final double
arcosh
(double a) Arcus hyperbolic cosine - inverse hyperbolic cosine function.static final double
arcoth
(double a) Arcus hyperbolic tangent - inverse hyperbolic tangent function.static final double
arcsch
(double a) Arcus hyperbolic cosecant - inverse hyperbolic cosecant function.static final double
arsech
(double a) Arcus hyperbolic secant - inverse hyperbolic secant function.static final double
arsinh
(double a) Arcus hyperbolic sine - inverse hyperbolic sine function.static final double
artanh
(double a) Arcus hyperbolic tangent - inverse hyperbolic tangent function.static final double
asec
(double a) Arcus secant - inverse trigonometric secant functionstatic final double
asin
(double a) Arcus sine - inverse trigonometric sine functionstatic final double
atan
(double a) Arcus tangent - inverse trigonometric tangent functionstatic final double
bellNumber
(double n) Bell numberstatic final double
bellNumber
(int n) Bell Numbersstatic final double
bernoulliNumber
(double m, double n) Bernoulli numbersstatic final double
bernoulliNumber
(int m, int n) Bernoulli numbersstatic final double
binomCoeff
(double n, double k) Generalized binomial coefficientstatic final double
binomCoeff
(double n, long k) Generalized binomial coefficientstatic final double
catalanNumber
(double n) Catalan numbersstatic final double
catalanNumber
(int n) Catalan numbersstatic final double
ceil
(double a) Ceiling function.static final double
chi
(double x, double a, double b) Characteristic function x in (a,b)static final double
chi_L
(double x, double a, double b) Characteristic function x in [a,b)static final double
chi_LR
(double x, double a, double b) Characteristic function x in [a,b]static final double
chi_R
(double x, double a, double b) Characteristic function x in (a,b]static final double
coalesce
(double[] values) Returns the first non-NaN valuestatic final double
continuedFraction
(double... sequence) Continued fractionstatic final double
continuedPolynomial
(double... x) Continued polynomialstatic final double
cos
(double a) Cosine trigonometric functionstatic final double
cosec
(double a) Cosecant trigonometric functionstatic final double
cosh
(double a) Hyperbolic cosine function.static final double
coth
(double a) Hyperbolic cotangent function.static final double
csch
(double a) Hyperbolic cosecant function.static final double
ctan
(double a) Cotangent trigonometric functionstatic final int
decimalDigitsBefore
(double value) For very small number returns the position of first significant digit, ie 0.1 = 1, 0.01 = 2static final double
deg
(double a) Radius to degrees translation.static final double
div
(double a, double b) Division a / b applying canonical rounding if canonical rounding is enabledstatic final double
eulerNumber
(double n, double k) Euler numbersstatic final double
eulerNumber
(int n, int k) Euler numbersstatic final double
eulerPolynomial
(double m, double x) Euler polynomialstatic final double
eulerPolynomial
(int m, double x) Euler polynomialstatic final double
exp
(double a) Exponential function.static final double
factorial
(double n) Factorialstatic final double
factorial
(int n) Factorialstatic final double
fibonacciNumber
(double n) Fibonacci numbersstatic final double
fibonacciNumber
(int n) Fibonacci numbersstatic final double
floor
(double a) Floor function.static final double
harmonicNumber
(double n) Harmonic numberstatic final double
harmonicNumber
(double x, double n) Harmonic number 1/1 + 1/2^x + ... + 1/n^xstatic final double
harmonicNumber
(double x, int n) Harmonic number 1/1 + 1/2^x + ... + 1/n^xstatic final double
harmonicNumber
(int n) Harmonic numerstatic final double
integerPart
(double x) Returns integer part of a double value.static final boolean
isAlmostInt
(double a) Verifies whether provided number is almost integerstatic final boolean
isInteger
(double x) Check whether double value is almost integer.static final double
kroneckerDelta
(double i, double j) Kronecker deltastatic final double
kroneckerDelta
(int i, int j) Kronecker deltastatic final double
ln
(double a) Natural logarithmstatic final double
log
(double a, double b) General logarithm.static final double
log10
(double a) Common logarithmstatic final double
log2
(double a) Binary logarithmstatic final double
lucasNumber
(double n) Lucas numebrsstatic final double
lucasNumber
(int n) Lucas numebrsstatic final double
minus
(double a, double b) Subtraction a - b applying canonical rounding if canonical rounding is enabledstatic final double
mod
(double a, double b) Modulo operator a % bstatic final double
multiply
(double a, double b) Multiplication a * b applying canonical rounding if canonical rounding is enabledstatic final double
numberOfPermutations
(double n, double k) Generalized coefficient returning number of k permutations that can be drawn for n elements set.static final double
numberOfPermutations
(double n, long k) Generalized coefficient returning number of k permutations that can be drawn for n elements set.static final double
plus
(double a, double b) Addition a + b applying canonical rounding if canonical rounding is enabledstatic final double
power
(double a, double b) Power function a^bstatic final double
rad
(double a) Degrees to radius translation.static final double
root
(double n, double x) Nth order root of a numberstatic final double
round
(double value, int places) Double roundingstatic final double
roundDown
(double value, int places) Double down roundingstatic final double
roundHalfUp
(double value, int places) Double half up roundingstatic final double
roundUlp
(double number) Unit in the last place rounding, see 0.1 + 0.1 + 0.1 vs roundUlp(0.1 + 0.1 + 0.1)static final double
sa
(double a) Normalized sinc function.static final double
sec
(double a) Secant trigonometric functionstatic final double
sech
(double a) Hyperbolic secant function.static final double
sgn
(double a) Signum function.static final double
sin
(double a) Sine trigonometric functionstatic final double
sinc
(double a) Sinc function.static final double
sinh
(double a) Hyperbolic sine function.static final double
sqrt
(double a) Square root.static final double
Stirling1Number
(double n, double k) Stirling numbers of the first kindstatic final double
Stirling1Number
(int n, int k) Stirling numbers of the first kindstatic final double
Stirling2Number
(double n, double k) Stirling numbers of the second kindstatic final double
Stirling2Number
(int n, int k) Stirling numbers of the second kindstatic final double
tan
(double a) Tangent trigonometric functionstatic final double
tanh
(double a) Hyperbolic tangent function.static final double
tetration
(double a, double n) Tetration, exponential power, power seriesstatic final double
ulp
(double value) Unit in the last place(ULP) for doublestatic final int
ulpDecimalDigitsBefore
(double value) Unit in The Last Place - number of decimal digits beforestatic final double
worpitzkyNumber
(double n, double k) Worpitzky numbersstatic final double
worpitzkyNumber
(int n, int k) Worpitzky numbers
-
Constructor Details
-
MathFunctions
public MathFunctions()
-
-
Method Details
-
plus
public static final double plus(double a, double b) Addition a + b applying canonical rounding if canonical rounding is enabled- Parameters:
a
- The a parameterb
- The b parameter- Returns:
- The result of addition
-
minus
public static final double minus(double a, double b) Subtraction a - b applying canonical rounding if canonical rounding is enabled- Parameters:
a
- The a parameterb
- The b parameter- Returns:
- The result of subtraction
-
multiply
public static final double multiply(double a, double b) Multiplication a * b applying canonical rounding if canonical rounding is enabled- Parameters:
a
- The a parameterb
- The b parameter- Returns:
- The result of multiplication
-
div
public static final double div(double a, double b) Division a / b applying canonical rounding if canonical rounding is enabled- Parameters:
a
- The a parameterb
- The b parameter- Returns:
- The result of division
-
bellNumber
public static final double bellNumber(int n) Bell Numbers- Parameters:
n
- the n- Returns:
- if n >= 0 returns Bell numbers, otherwise returns Double.NaN.
-
bellNumber
public static final double bellNumber(double n) Bell number- Parameters:
n
- the n- Returns:
- if n <> Double.NaN return bellNumber( (int)Math.round(n) ), otherwise return Double.NaN.
-
eulerNumber
public static final double eulerNumber(int n, int k) Euler numbers- Parameters:
n
- the n function paramk
- the k function param- Returns:
- if n >=0 returns Euler number, otherwise return Double.NaN.
-
eulerNumber
public static final double eulerNumber(double n, double k) Euler numbers- Parameters:
n
- the n function paramk
- the k function param- Returns:
- if n, k <> Double.NaN returns eulerNumber( (int)Math.round(n), (int)Math.round(k) ), otherwise return Double.NaN.
-
factorial
public static final double factorial(int n) Factorial- Parameters:
n
- the n function parameter- Returns:
- Factorial if n >=0, otherwise returns Double.NaN.
-
factorial
public static final double factorial(double n) Factorial- Parameters:
n
- the n function parameter- Returns:
- if n <> Double.NaN return factorial( (int)Math.round(n) ), otherwise returns Double.NaN.
-
binomCoeff
public static final double binomCoeff(double n, long k) Generalized binomial coefficient- Parameters:
n
- the n function parameterk
- k the k function parameter- Returns:
- Generalized binomial coefficient, if n = Double.NaN or k < 0 returns Double.NaN.
-
binomCoeff
public static final double binomCoeff(double n, double k) Generalized binomial coefficient- Parameters:
n
- the n function parameterk
- the k function parameter- Returns:
- if n, k <> Double.NaN returns binomCoeff(n, (int)Math.round(k) ), otherwise returns Double.NaN.
-
numberOfPermutations
public static final double numberOfPermutations(double n, long k) Generalized coefficient returning number of k permutations that can be drawn for n elements set.- Parameters:
n
- the n function parameterk
- the k function parameter- Returns:
- For k greater than 0 return number of permutations, otherwise returns Double.NaN
-
numberOfPermutations
public static final double numberOfPermutations(double n, double k) Generalized coefficient returning number of k permutations that can be drawn for n elements set.- Parameters:
n
- the n function parameterk
- the k function parameter- Returns:
- For k greater than 0 return number of permutations, otherwise returns Double.NaN
-
bernoulliNumber
public static final double bernoulliNumber(int m, int n) Bernoulli numbers- Parameters:
m
- the m function parametern
- the n function parameter- Returns:
- if n, m >= 0 returns Bernoulli number, otherwise returns Double.NaN.
-
bernoulliNumber
public static final double bernoulliNumber(double m, double n) Bernoulli numbers- Parameters:
m
- the m function parametern
- the n function parameter- Returns:
- if n, m <> Double.NaN returns bernoulliNumber( (int)Math.round(m), (int)Math.round(n) ), otherwise returns Double.NaN.
-
Stirling1Number
public static final double Stirling1Number(int n, int k) Stirling numbers of the first kind- Parameters:
n
- the n function parameterk
- the k function parameter- Returns:
- Stirling numbers of the first kind
-
Stirling1Number
public static final double Stirling1Number(double n, double k) Stirling numbers of the first kind- Parameters:
n
- the n function parameterk
- the k function parameter- Returns:
- if n, k <> Doube.NaN returns Stirling1Number( (int)Math.round(n), (int)Math.round(k) ), otherwise returns Double.NaN.
-
Stirling2Number
public static final double Stirling2Number(int n, int k) Stirling numbers of the second kind- Parameters:
n
- the n function parameterk
- the k function parameter- Returns:
- Stirling numbers of the second kind
-
Stirling2Number
public static final double Stirling2Number(double n, double k) Stirling numbers of the second kind- Parameters:
n
- the n function parameterk
- the k function parameter- Returns:
- if n, k <> Doube.NaN returns Stirling2Number( (int)Math.round(n), (int)Math.round(k) ), otherwise returns Double.NaN.
-
worpitzkyNumber
public static final double worpitzkyNumber(int n, int k) Worpitzky numbers- Parameters:
n
- the n function parameterk
- the k function parameter- Returns:
- if n,k >= 0 and k <= n return Worpitzky number, otherwise return Double.NaN.
-
worpitzkyNumber
public static final double worpitzkyNumber(double n, double k) Worpitzky numbers- Parameters:
n
- the n function parameterk
- the k function parameter- Returns:
- if n,k <> Double.NaN returns worpitzkyNumber( (int)Math.round(n), (int)Math.round(k) ), otherwise return Double.NaN.
-
harmonicNumber
public static final double harmonicNumber(int n) Harmonic numer- Parameters:
n
- the n function parameter- Returns:
- if n > 0 returns harmonic number, otherwise returns 0 (empty summation operator)
-
harmonicNumber
public static final double harmonicNumber(double n) Harmonic number- Parameters:
n
- the n function parameter- Returns:
- if n <> Double.NaN returns harmonicNumber( (int)Math.round(n) ), otherwise returns Double.NaN
-
harmonicNumber
public static final double harmonicNumber(double x, int n) Harmonic number 1/1 + 1/2^x + ... + 1/n^x- Parameters:
x
- the x function parametern
- the n function parameter- Returns:
- if x <> Double.NaN and x >= 0 Harmonic number, otherwise returns Double.NaN.
-
harmonicNumber
public static final double harmonicNumber(double x, double n) Harmonic number 1/1 + 1/2^x + ... + 1/n^x- Parameters:
x
- the x function parametern
- the n function parameter- Returns:
- if x,n <> Double.NaN returns harmonicNumber( x, (int)Math.round(n) ), otherwise returns Double.NaN.
-
catalanNumber
public static final double catalanNumber(int n) Catalan numbers- Parameters:
n
- the n function parameter- Returns:
- Catalan numbers
-
catalanNumber
public static final double catalanNumber(double n) Catalan numbers- Parameters:
n
- the n function parameter- Returns:
- if n <> Double.NaN returns catalanNumber( (int)Math.round(n) ), otherwise returns Double.NaN.
-
fibonacciNumber
public static final double fibonacciNumber(int n) Fibonacci numbers- Parameters:
n
- the n function parameter- Returns:
- if n >= 0 returns fibonacci numbers, otherwise returns Double.NaN.
-
fibonacciNumber
public static final double fibonacciNumber(double n) Fibonacci numbers- Parameters:
n
- the n function parameter- Returns:
- if n <> Double.NaN returns fibonacciNumber( (int)Math.round(n) ), otherwise returns Double.NaN.
-
lucasNumber
public static final double lucasNumber(int n) Lucas numebrs- Parameters:
n
- the n function parameter- Returns:
- if n >= 0 returns Lucas numbers, otherwise returns Double.NaN.
-
lucasNumber
public static final double lucasNumber(double n) Lucas numebrs- Parameters:
n
- the n function parameter- Returns:
- if n <> Double.NaN returns lucasNumber( (int)Math.round(n) ), otherwise returns Double.NaN.
-
kroneckerDelta
public static final double kroneckerDelta(double i, double j) Kronecker delta- Parameters:
i
- the i function parameterj
- the j function parameter- Returns:
- if i,j <> Double.NaN returns Kronecker delta, otherwise returns Double.NaN.
-
kroneckerDelta
public static final double kroneckerDelta(int i, int j) Kronecker delta- Parameters:
i
- the i function parameterj
- the j function parameter- Returns:
- Kronecker delta
-
continuedFraction
public static final double continuedFraction(double... sequence) Continued fraction- Parameters:
sequence
- the numbers- Returns:
- if each number form the sequence <> Double.NaN and there is no division by 0 while computing returns continued fraction value, otherwise returns Double.NaN.
-
continuedPolynomial
public static final double continuedPolynomial(double... x) Continued polynomial- Parameters:
x
- the x values- Returns:
- if each number for x is different the Double.NaN returns continued polynomial, otherwise returns Double.NaN.
-
eulerPolynomial
public static final double eulerPolynomial(int m, double x) Euler polynomial- Parameters:
m
- the m parameterx
- the x parameter- Returns:
- if x <> Double.NaN and m >= 0 returns polynomial value, otherwise returns Double.NaN.
-
eulerPolynomial
public static final double eulerPolynomial(double m, double x) Euler polynomial- Parameters:
m
- the m parameterx
- the x parameter- Returns:
- if x,m <> Double.NaN returns eulerPolynomial( (int)Math.round(m), (int)Math.round(x) ), otherwise returns Double.NaN.
-
chi
public static final double chi(double x, double a, double b) Characteristic function x in (a,b)- Parameters:
x
- the x valuea
- the left (lower) limitb
- the right (upper) limit- Returns:
- if x, a, b <> Double.NaN returns characteristic function value on the (a,b) range.
-
chi_LR
public static final double chi_LR(double x, double a, double b) Characteristic function x in [a,b]- Parameters:
x
- the x valuea
- the left (lower) limitb
- the right (upper) limit- Returns:
- if x, a, b <> Double.NaN returns characteristic function value on the [a,b] range.
-
chi_L
public static final double chi_L(double x, double a, double b) Characteristic function x in [a,b)- Parameters:
x
- the x valuea
- the left (lower) limitb
- the right (upper) limit- Returns:
- if x, a, b <> Double.NaN returns characteristic function value on the [a,b) range.
-
chi_R
public static final double chi_R(double x, double a, double b) Characteristic function x in (a,b]- Parameters:
x
- the x valuea
- the left (lower) limitb
- the right (upper) limit- Returns:
- if x, a, b <> Double.NaN returns characteristic function value on the (a,b] range.
-
isAlmostInt
public static final boolean isAlmostInt(double a) Verifies whether provided number is almost integer- Parameters:
a
- The number to be verified- Returns:
- True if the number is almost integer according to the default epsilon, otherwise returns false.
- See Also:
-
power
public static final double power(double a, double b) Power function a^b- Parameters:
a
- the a function parameterb
- the b function parameter- Returns:
- if a,b <> Double.NaN returns Math.pow(a, b), otherwise returns Double.NaN.
-
root
public static final double root(double n, double x) Nth order root of a number- Parameters:
n
- Root orderx
- Number- Returns:
- Returns root of a number. If calculation is not possible Double.NaN is returned.
-
tetration
public static final double tetration(double a, double n) Tetration, exponential power, power series- Parameters:
a
- basen
- exponent- Returns:
- Tetration result.
-
mod
public static final double mod(double a, double b) Modulo operator a % b- Parameters:
a
- the a function parameterb
- the b function parameter- Returns:
- if a,b <> Double.NaN returns a % b.
-
sin
public static final double sin(double a) Sine trigonometric function- Parameters:
a
- the a function parameter- Returns:
- if a <> Double.NaN return Math.sin(a), otherwise return Double.NaN.
-
cos
public static final double cos(double a) Cosine trigonometric function- Parameters:
a
- the a function parameter- Returns:
- if a <> Double.NaN returns Math.cos(a), otherwise returns Double.NaN.
-
tan
public static final double tan(double a) Tangent trigonometric function- Parameters:
a
- the a function parameter- Returns:
- if a <> Double.NaN returns Math.tan(a), otherwise returns Double.NaN.
-
ctan
public static final double ctan(double a) Cotangent trigonometric function- Parameters:
a
- the a function parameter- Returns:
- if a <> Double.NaN and tan(a) <> 0 returns 1 / Math.tan(a), otherwise returns Double.NaN.
-
sec
public static final double sec(double a) Secant trigonometric function- Parameters:
a
- the a function parameter- Returns:
- if a <> Double.NaN and cos(a) <> 0 returns 1 / Math.cos(a), otherwise returns Double.NaN.
-
cosec
public static final double cosec(double a) Cosecant trigonometric function- Parameters:
a
- the a function parameter- Returns:
- if a <> Double.NaN and sin(a) <> 0 returns 1 / Math.sin(a), otherwise returns Double.NaN.
-
asin
public static final double asin(double a) Arcus sine - inverse trigonometric sine function- Parameters:
a
- the a function parameter- Returns:
- if a <> Double.NaN returns Math.asin(a), otherwise returns Double.NaN.
-
acos
public static final double acos(double a) Arcus cosine - inverse trigonometric cosine function- Parameters:
a
- the a function parameter- Returns:
- if a <> Double.NaN returns Math.acos(a), otherwise returns Double.NaN.
-
atan
public static final double atan(double a) Arcus tangent - inverse trigonometric tangent function- Parameters:
a
- the a function parameter- Returns:
- if a <> Double.NaN returns Math.atan(a), otherwise returns Double.NaN.
-
actan
public static final double actan(double a) Arcus cotangent - inverse trigonometric cotangent function- Parameters:
a
- the a function parameter- Returns:
- if a <> Double.NaN and a <> 0 returns Math.atan(1/a), otherwise returns Double.NaN.
-
asec
public static final double asec(double a) Arcus secant - inverse trigonometric secant function- Parameters:
a
- the a function parameter- Returns:
- Inverse trigonometric secant function
-
acosec
public static final double acosec(double a) Arcus cosecant - inverse trigonometric cosecant function- Parameters:
a
- the a function parameter- Returns:
- Inverse trigonometric cosecant function
-
ln
public static final double ln(double a) Natural logarithm- Parameters:
a
- the a function parameter- Returns:
- if a <> Double.NaN returns Math.log(1/a), otherwise returns Double.NaN.
-
log2
public static final double log2(double a) Binary logarithm- Parameters:
a
- the a function parameter- Returns:
- if a <> Double.NaN returns Math.log(a)/Math.log(2.0), otherwise returns Double.NaN.
-
log10
public static final double log10(double a) Common logarithm- Parameters:
a
- the a function parameter- Returns:
- if a <> Double.NaN returns Math.log10(a), otherwise returns Double.NaN.
-
rad
public static final double rad(double a) Degrees to radius translation.- Parameters:
a
- the a function parameter- Returns:
- if a <> Double.NaN returns Math.toRadians(a), otherwise returns Double.NaN.
-
exp
public static final double exp(double a) Exponential function.- Parameters:
a
- the a function parameter- Returns:
- if a <> Double.NaN returns Math.exp(a), otherwise returns Double.NaN.
-
sqrt
public static final double sqrt(double a) Square root.- Parameters:
a
- the a function parameter- Returns:
- if a <> Double.NaN returns Math.sqrt(a), otherwise returns Double.NaN.
-
sinh
public static final double sinh(double a) Hyperbolic sine function.- Parameters:
a
- the a function parameter- Returns:
- if a <> Double.NaN returns Math.sinh(a), otherwise returns Double.NaN.
-
cosh
public static final double cosh(double a) Hyperbolic cosine function.- Parameters:
a
- the a function parameter- Returns:
- if a <> Double.NaN returns Math.cosh(a), otherwise returns Double.NaN.
-
tanh
public static final double tanh(double a) Hyperbolic tangent function.- Parameters:
a
- the a function parameter- Returns:
- if a <> Double.NaN returns Math.tanh(a), otherwise returns Double.NaN.
-
coth
public static final double coth(double a) Hyperbolic cotangent function.- Parameters:
a
- the a function parameter- Returns:
- if a <> Double.NaN and tanh(a) <> 0 returns 1 / Math.tanh(a), otherwise returns Double.NaN.
-
sech
public static final double sech(double a) Hyperbolic secant function.- Parameters:
a
- the a function parameter- Returns:
- if a <> Double.NaN and cosh(a) <> 0 returns 1 / Math.cosh(a), otherwise returns Double.NaN.
-
csch
public static final double csch(double a) Hyperbolic cosecant function.- Parameters:
a
- the a function parameter- Returns:
- if a <> Double.NaN and sinh(a) <> 0 returns 1 / Math.sinh(a), otherwise returns Double.NaN.
-
deg
public static final double deg(double a) Radius to degrees translation.- Parameters:
a
- the a function parameter- Returns:
- if a <> Double.NaN returns Math.toDegrees(a), otherwise returns Double.NaN.
-
abs
public static final double abs(double a) Absolute value.- Parameters:
a
- the a function parameter- Returns:
- if a <> Double.NaN returns Math.abs(a), otherwise returns Double.NaN.
-
sgn
public static final double sgn(double a) Signum function.- Parameters:
a
- the a function parameter- Returns:
- if a <> Double.NaN returns Math.signum(a), otherwise returns Double.NaN.
-
floor
public static final double floor(double a) Floor function.- Parameters:
a
- the a function parameter- Returns:
- if a <> Double.NaN returns Math.floor(a), otherwise returns Double.NaN.
-
ceil
public static final double ceil(double a) Ceiling function.- Parameters:
a
- the a function parameter- Returns:
- if a <> Double.NaN returns Math.ceil(a), otherwise returns Double.NaN.
-
arsinh
public static final double arsinh(double a) Arcus hyperbolic sine - inverse hyperbolic sine function.- Parameters:
a
- the a function parameter- Returns:
- if a <> Double.NaN returns Math.log(a + Math.sqrt(a*a+1)), otherwise returns Double.NaN.
-
arcosh
public static final double arcosh(double a) Arcus hyperbolic cosine - inverse hyperbolic cosine function.- Parameters:
a
- the a function parameter- Returns:
- if a <> Double.NaN returns Math.log(a + Math.sqrt(a*a-1)), otherwise returns Double.NaN.
-
artanh
public static final double artanh(double a) Arcus hyperbolic tangent - inverse hyperbolic tangent function.- Parameters:
a
- the a function parameter- Returns:
- if a <> Double.NaN and 1-a <> 0 returns 0.5*Math.log( (1+a)/(1-a) ), otherwise returns Double.NaN.
-
arcoth
public static final double arcoth(double a) Arcus hyperbolic tangent - inverse hyperbolic tangent function.- Parameters:
a
- the a function parameter- Returns:
- if a <> Double.NaN and a-1 <> 0 returns 0.5*Math.log( (a+1)/(a-1) );, otherwise returns Double.NaN.
-
arsech
public static final double arsech(double a) Arcus hyperbolic secant - inverse hyperbolic secant function.- Parameters:
a
- the a function parameter- Returns:
- if a <> Double.NaN and a <> 0 returns Math.log( (1+Math.sqrt(1-a*a))/a);, otherwise returns Double.NaN.
-
arcsch
public static final double arcsch(double a) Arcus hyperbolic cosecant - inverse hyperbolic cosecant function.- Parameters:
a
- the a function parameter- Returns:
- if a <> Double.NaN and a <> 0 returns Math.log( (1+Math.sqrt(1-a*a))/a);, otherwise returns Double.NaN.
-
sa
public static final double sa(double a) Normalized sinc function.- Parameters:
a
- the a function parameter- Returns:
- if a <> Double.NaN and a <> 0 returns Math.sin(PI*a) / (PI*a);, otherwise returns Double.NaN.
-
sinc
public static final double sinc(double a) Sinc function.- Parameters:
a
- the a function parameter- Returns:
- if a <> Double.NaN and a <> 0 returns Math.sin(a) / (a), otherwise returns Double.NaN.
-
log
public static final double log(double a, double b) General logarithm.- Parameters:
a
- the a function parameter (base)b
- the b function parameter (number)- Returns:
- if a,b <> Double.NaN and log(b) <> 0 returns Math.log(a) / Math.log(b), otherwise returns Double.NaN.
-
round
public static final double round(double value, int places) Double rounding- Parameters:
value
- double value to be roundedplaces
- decimal places- Returns:
- Rounded value
-
roundHalfUp
public static final double roundHalfUp(double value, int places) Double half up rounding- Parameters:
value
- double value to be roundedplaces
- decimal places- Returns:
- Rounded value
-
roundDown
public static final double roundDown(double value, int places) Double down rounding- Parameters:
value
- double value to be roundedplaces
- decimal places- Returns:
- Rounded value
-
roundUlp
public static final double roundUlp(double number) Unit in the last place rounding, see 0.1 + 0.1 + 0.1 vs roundUlp(0.1 + 0.1 + 0.1)- Parameters:
number
- Double number that is to be rounded- Returns:
- Double number with rounded ulp
- See Also:
-
integerPart
public static final double integerPart(double x) Returns integer part of a double value.- Parameters:
x
- Number- Returns:
- For non- negative x returns Math.floor(x), otherwise returns -Math.floor(-x)
-
decimalDigitsBefore
public static final int decimalDigitsBefore(double value) For very small number returns the position of first significant digit, ie 0.1 = 1, 0.01 = 2- Parameters:
value
- Double value, small one.- Returns:
- Number of digits, number of places.
-
ulp
public static final double ulp(double value) Unit in the last place(ULP) for double- Parameters:
value
- Double number- Returns:
- ULP for a given double.
-
ulpDecimalDigitsBefore
public static final int ulpDecimalDigitsBefore(double value) Unit in The Last Place - number of decimal digits before- Parameters:
value
- Double number- Returns:
- Positive number of digits N for ulp = 1e-{N+1}, if ulp is > 1 then -1 is returned. Returned proper value is always between -1 and +322. If value is NaN then -2 is returned.
-
coalesce
public static final double coalesce(double[] values) Returns the first non-NaN value- Parameters:
values
- List of values- Returns:
- Returns the first non-NaN value, if list is null then returns Double.NaN, if list contains no elements then returns Double.NaN.
-
isInteger
public static final boolean isInteger(double x) Check whether double value is almost integer.- Parameters:
x
- Number- Returns:
- True if double value is almost integer, otherwise false.
BinaryRelations.DEFAULT_COMPARISON_EPSILON
- See Also:
-
almostEqual
public static final boolean almostEqual(double a, double b) Check whether two double values are almost equal.- Parameters:
a
- First numberb
- Second number- Returns:
- True if double values are almost equal, otherwise false.
BinaryRelations.DEFAULT_COMPARISON_EPSILON
- See Also:
-