Class MathFunctions
- java.lang.Object
-
- org.mariuszgromada.math.mxparser.mathcollection.MathFunctions
-
public final class MathFunctions extends Object
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.
-
-
Constructor Summary
Constructors Constructor Description MathFunctions()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static doubleabs(double a)Absolute value.static doubleacos(double a)Arcus cosine - inverse trigonometric cosine functionstatic doubleacosec(double a)Arcus cosecant - inverse trigonometric cosecant functionstatic doubleactan(double a)Arcus cotangent - inverse trigonometric cotangent functionstatic booleanalmostEqual(double a, double b)Check whether two double values are almost equal.static doublearcosh(double a)Arcus hyperbolic cosine - inverse hyperbolic cosine function.static doublearcoth(double a)Arcus hyperbolic tangent - inverse hyperbolic tangent function.static doublearcsch(double a)Arcus hyperbolic cosecant - inverse hyperbolic cosecant function.static doublearsech(double a)Arcus hyperbolic secant - inverse hyperbolic secant function.static doublearsinh(double a)Arcus hyperbolic sine - inverse hyperbolic sine function.static doubleartanh(double a)Arcus hyperbolic tangent - inverse hyperbolic tangent function.static doubleasec(double a)Arcus secant - inverse trigonometric secant functionstatic doubleasin(double a)Arcus sine - inverse trigonometric sine functionstatic doubleatan(double a)Arcus tangent - inverse trigonometric tangent functionstatic doublebellNumber(double n)Bell numberstatic doublebellNumber(int n)Bell Numbersstatic doublebernoulliNumber(double m, double n)Bernoulli numbersstatic doublebernoulliNumber(int m, int n)Bernoulli numbersstatic doublebinomCoeff(double n, double k)Generalized binomial coefficientstatic doublebinomCoeff(double n, long k)Generalized binomial coefficientstatic doublecatalanNumber(double n)Catalan numbersstatic doublecatalanNumber(int n)Catalan numbersstatic doubleceil(double a)Ceiling function.static doublechi(double x, double a, double b)Characteristic function x in (a,b)static doublechi_L(double x, double a, double b)Characteristic function x in [a,b)static doublechi_LR(double x, double a, double b)Characteristic function x in [a,b]static doublechi_R(double x, double a, double b)Characteristic function x in (a,b]static doublecoalesce(double[] values)Returns the first non-NaN valuestatic doublecontinuedFraction(double... sequence)Continued fractionstatic doublecontinuedPolynomial(double... x)Continued polynomialstatic doublecos(double a)Cosine trigonometric functionstatic doublecosec(double a)Cosecant trigonometric functionstatic doublecosh(double a)Hyperbolic cosine function.static doublecoth(double a)Hyperbolic cotangent function.static doublecsch(double a)Hyperbolic cosecant function.static doublectan(double a)Cotangent trigonometric functionstatic intdecimalDigitsBefore(double value)For very small number returns the position of first significant digit, ie 0.1 = 1, 0.01 = 2static doubledeg(double a)Radius to degrees translation.static doublediv(double a, double b)Division a / b applying canonical rounding if canonical rounding is enabledstatic doubleeulerNumber(double n, double k)Euler numbersstatic doubleeulerNumber(int n, int k)Euler numbersstatic doubleeulerPolynomial(double m, double x)Euler polynomialstatic doubleeulerPolynomial(int m, double x)Euler polynomialstatic doubleexp(double a)Exponential function.static doublefactorial(double n)Factorialstatic doublefactorial(int n)Factorialstatic doublefactorialFalling(double x, double n)Falling factorial polynomialstatic doublefactorialRising(double x, double n)Rising factorial polynomialstatic doublefibonacciNumber(double n)Fibonacci numbersstatic doublefibonacciNumber(int n)Fibonacci numbersstatic doublefloor(double a)Floor function.static doubleharmonicNumber(double n)Harmonic numberstatic doubleharmonicNumber(double x, double n)Harmonic number 1/1 + 1/2^x + ... + 1/n^xstatic doubleharmonicNumber(double x, int n)Harmonic number 1/1 + 1/2^x + ... + 1/n^xstatic doubleharmonicNumber(int n)Harmonic numerstatic doubleintegerPart(double x)Returns integer part of a double value.static booleanisAlmostInt(double a)Verifies whether provided number is almost integerstatic booleanisInteger(double x)Check whether double value is almost integer.static doublekroneckerDelta(double i, double j)Kronecker deltastatic doublekroneckerDelta(int i, int j)Kronecker deltastatic doubleln(double a)Natural logarithmstatic doublelog(double a, double b)General logarithm.static doublelog10(double a)Common logarithmstatic doublelog2(double a)Binary logarithmstatic doublelucasNumber(double n)Lucas numebrsstatic doublelucasNumber(int n)Lucas numebrsstatic doubleminus(double a, double b)Subtraction a - b applying canonical rounding if canonical rounding is enabledstatic doublemod(double a, double b)Modulo operator a % bstatic doublemultiply(double a, double b)Multiplication a * b applying canonical rounding if canonical rounding is enabledstatic doublenumberOfPermutations(double n, double k)Generalized coefficient returning number of k permutations that can be drawn for n elements set.static doublenumberOfPermutations(double n, long k)Generalized coefficient returning number of k permutations that can be drawn for n elements set.static doubleplus(double a, double b)Addition a + b applying canonical rounding if canonical rounding is enabledstatic doublepower(double a, double b)Power function a^bstatic doublerad(double a)Degrees to radius translation.static doubleroot(double n, double x)Nth order root of a numberstatic doubleround(double value, int places)Double roundingstatic doubleroundDown(double value, int places)Double down roundingstatic doubleroundHalfUp(double value, int places)Double half up roundingstatic doubleroundUlp(double number)Unit in the last place rounding, see 0.1 + 0.1 + 0.1 vs roundUlp(0.1 + 0.1 + 0.1)static doublesa(double a)Normalized sinc function.static doublesec(double a)Secant trigonometric functionstatic doublesech(double a)Hyperbolic secant function.static doublesgn(double a)Signum function.static doublesin(double a)Sine trigonometric functionstatic doublesinc(double a)Sinc function.static doublesinh(double a)Hyperbolic sine function.static doublesqrt(double a)Square root.static doubleStirling1Number(double n, double k)Stirling numbers of the first kindstatic doubleStirling1Number(int n, int k)Stirling numbers of the first kindstatic doubleStirling2Number(double n, double k)Stirling numbers of the second kindstatic doubleStirling2Number(int n, int k)Stirling numbers of the second kindstatic doubletan(double a)Tangent trigonometric functionstatic doubletanh(double a)Hyperbolic tangent function.static doubletetration(double a, double n)Tetration, exponential power, power seriesstatic doubleulp(double value)Unit in the last place(ULP) for doublestatic intulpDecimalDigitsBefore(double value)Unit in The Last Place - number of decimal digits beforestatic doubleworpitzkyNumber(double n, double k)Worpitzky numbersstatic doubleworpitzkyNumber(int n, int k)Worpitzky numbers
-
-
-
Method Detail
-
plus
public static 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 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 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 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 double bellNumber(int n)
Bell Numbers- Parameters:
n- the n- Returns:
- if n >= 0 returns Bell numbers, otherwise returns Double.NaN.
-
bellNumber
public static 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 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. Returns also Double.NaN when MAX RECURSION CALLS is exceeded.
- See Also:
mXparser.getMaxAllowedRecursionDepth(),mXparser.setMaxAllowedRecursionDepth(int)
-
eulerNumber
public static 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 double factorial(int n)
Factorial- Parameters:
n- the n function parameter- Returns:
- Factorial if n >=0, otherwise returns Double.NaN.
-
factorial
public static 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.
-
factorialFalling
public static double factorialFalling(double x, double n)Falling factorial polynomial- Parameters:
x- Argumentn- Polynomial degree- Returns:
- Falling factorial polynomial of degree n at point x
-
factorialRising
public static double factorialRising(double x, double n)Rising factorial polynomial- Parameters:
x- Argumentn- Polynomial degree- Returns:
- Rising factorial polynomial of degree n at point x
-
binomCoeff
public static 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 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 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 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 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 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 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 Returns also Double.NaN when MAX RECURSION CALLS is exceeded.
- See Also:
mXparser.getMaxAllowedRecursionDepth(),mXparser.setMaxAllowedRecursionDepth(int)
-
Stirling1Number
public static 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 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 Returns also Double.NaN when MAX RECURSION CALLS is exceeded.
- See Also:
mXparser.getMaxAllowedRecursionDepth(),mXparser.setMaxAllowedRecursionDepth(int)
-
Stirling2Number
public static 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 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 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 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 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 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 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 double catalanNumber(int n)
Catalan numbers- Parameters:
n- the n function parameter- Returns:
- Catalan numbers
-
catalanNumber
public static 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 double fibonacciNumber(int n)
Fibonacci numbers- Parameters:
n- the n function parameter- Returns:
- if n >= 0 returns fibonacci numbers, otherwise returns Double.NaN. Returns also Double.NaN when MAX RECURSION CALLS is exceeded.
- See Also:
mXparser.getMaxAllowedRecursionDepth(),mXparser.setMaxAllowedRecursionDepth(int)
-
fibonacciNumber
public static 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 double lucasNumber(int n)
Lucas numebrs- Parameters:
n- the n function parameter- Returns:
- if n >= 0 returns Lucas numbers, otherwise returns Double.NaN. Returns also Double.NaN when MAX RECURSION CALLS is exceeded.
- See Also:
mXparser.getMaxAllowedRecursionDepth(),mXparser.setMaxAllowedRecursionDepth(int)
-
lucasNumber
public static 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 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 double kroneckerDelta(int i, int j)Kronecker delta- Parameters:
i- the i function parameterj- the j function parameter- Returns:
- Kronecker delta
-
continuedFraction
public static 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 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 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 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 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 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 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 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 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:
BinaryRelations.DEFAULT_COMPARISON_EPSILON
-
power
public static 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 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 double tetration(double a, double n)Tetration, exponential power, power series- Parameters:
a- basen- exponent- Returns:
- Tetration result.
-
mod
public static 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 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 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 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 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 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 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 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 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 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 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 double asec(double a)
Arcus secant - inverse trigonometric secant function- Parameters:
a- the a function parameter- Returns:
- Inverse trigonometric secant function
-
acosec
public static double acosec(double a)
Arcus cosecant - inverse trigonometric cosecant function- Parameters:
a- the a function parameter- Returns:
- Inverse trigonometric cosecant function
-
ln
public static 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 double round(double value, int places)Double rounding- Parameters:
value- double value to be roundedplaces- decimal places- Returns:
- Rounded value
-
roundHalfUp
public static 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 double roundDown(double value, int places)Double down rounding- Parameters:
value- double value to be roundedplaces- decimal places- Returns:
- Rounded value
-
roundUlp
public static 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:
decimalDigitsBefore(double),ulp(double)
-
integerPart
public static 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 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 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 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 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 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:
BinaryRelations.DEFAULT_COMPARISON_EPSILON
-
almostEqual
public static 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:
BinaryRelations.DEFAULT_COMPARISON_EPSILON
-
-