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.- Version:
- 5.2.0
- Author:
- Mariusz Gromada
MathParser.org - mXparser project page
mXparser on GitHub
INFIMA place to purchase a commercial MathParser.org-mXparser software license
info@mathparser.org
ScalarMath.org - a powerful math engine and math scripting language
Scalar Lite
Scalar Pro
MathSpace.pl
Buy me a cup of coffee via donation
or support me purchasing the license via ORDER Page , or INFIMA online store
-
-
Constructor Summary
Constructors Constructor Description MathFunctions()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static double
abs(double a)
Absolute value.static double
acos(double a)
Arcus cosine - inverse trigonometric cosine functionstatic double
acosec(double a)
Arcus cosecant - inverse trigonometric cosecant functionstatic double
actan(double a)
Arcus cotangent - inverse trigonometric cotangent functionstatic boolean
almostEqual(double a, double b)
Check whether two double values are almost equal.static double
arcosh(double a)
Arcus hyperbolic cosine - inverse hyperbolic cosine function.static double
arcoth(double a)
Arcus hyperbolic tangent - inverse hyperbolic tangent function.static double
arcsch(double a)
Arcus hyperbolic cosecant - inverse hyperbolic cosecant function.static double
arsech(double a)
Arcus hyperbolic secant - inverse hyperbolic secant function.static double
arsinh(double a)
Arcus hyperbolic sine - inverse hyperbolic sine function.static double
artanh(double a)
Arcus hyperbolic tangent - inverse hyperbolic tangent function.static double
asec(double a)
Arcus secant - inverse trigonometric secant functionstatic double
asin(double a)
Arcus sine - inverse trigonometric sine functionstatic double
atan(double a)
Arcus tangent - inverse trigonometric tangent functionstatic double
bellNumber(double n)
Bell numberstatic double
bellNumber(int n)
Bell Numbersstatic double
bernoulliNumber(double m, double n)
Bernoulli numbersstatic double
bernoulliNumber(int m, int n)
Bernoulli numbersstatic double
binomCoeff(double n, double k)
Generalized binomial coefficientstatic double
binomCoeff(double n, long k)
Generalized binomial coefficientstatic double
catalanNumber(double n)
Catalan numbersstatic double
catalanNumber(int n)
Catalan numbersstatic double
ceil(double a)
Ceiling function.static double
chi(double x, double a, double b)
Characteristic function x in (a,b)static double
chi_L(double x, double a, double b)
Characteristic function x in [a,b)static double
chi_LR(double x, double a, double b)
Characteristic function x in [a,b]static double
chi_R(double x, double a, double b)
Characteristic function x in (a,b]static double
coalesce(double[] values)
Returns the first non-NaN valuestatic double
continuedFraction(double... sequence)
Continued fractionstatic double
continuedPolynomial(double... x)
Continued polynomialstatic double
cos(double a)
Cosine trigonometric functionstatic double
cosec(double a)
Cosecant trigonometric functionstatic double
cosh(double a)
Hyperbolic cosine function.static double
coth(double a)
Hyperbolic cotangent function.static double
csch(double a)
Hyperbolic cosecant function.static double
ctan(double a)
Cotangent trigonometric functionstatic int
decimalDigitsBefore(double value)
For very small number returns the position of first significant digit, ie 0.1 = 1, 0.01 = 2static int
decimalNumberLength(double value)
Length of a number represented in a standard decimal formatstatic double
deg(double a)
Radius to degrees translation.static double
div(double a, double b)
Division a / b applying canonical rounding if canonical rounding is enabledstatic double
eulerNumber(double n, double k)
Euler numbersstatic double
eulerNumber(int n, int k)
Euler numbersstatic double
eulerPolynomial(double m, double x)
Euler polynomialstatic double
eulerPolynomial(int m, double x)
Euler polynomialstatic double
exp(double a)
Exponential function.static double
factorial(double n)
Factorialstatic double
factorial(int n)
Factorialstatic double
factorialFalling(double x, double n)
Falling factorial polynomialstatic double
factorialRising(double x, double n)
Rising factorial polynomialstatic double
fibonacciNumber(double n)
Fibonacci numbersstatic double
fibonacciNumber(int n)
Fibonacci numbersstatic double
floor(double a)
Floor function.static int
fractionalPartLength(double value)
Fractional part length of a number represented in a standard decimal formatstatic double
getFunctionValue(Expression f, Argument x, double x0)
Calculates function f(x0) (given as expression) assigning Argument x = x0;static double[]
getFunctionValues(Expression f, Argument index, double from, double to, double delta)
Returns array of double values of the function f(i) calculated on the range: i = from to i = to by step = deltastatic double
harmonicNumber(double n)
Harmonic numberstatic double
harmonicNumber(double x, double n)
Harmonic number 1/1 + 1/2^x + ... + 1/n^xstatic double
harmonicNumber(double x, int n)
Harmonic number 1/1 + 1/2^x + ... + 1/n^xstatic double
harmonicNumber(int n)
Harmonic numerstatic double
integerPart(double x)
Returns integer part of a double value.static boolean
isAlmostInt(double a)
Verifies whether provided number is almost integerstatic boolean
isInteger(double x)
Check whether double value is almost integer.static double
kroneckerDelta(double i, double j)
Kronecker deltastatic double
kroneckerDelta(int i, int j)
Kronecker deltastatic double
lengthRound(double value)
Intelligent rounding of a number within the decimal position of the ULP (Unit in the Last Place), provided that the result is significantly shortened in the standard decimal notation.static double
ln(double a)
Natural logarithmstatic double
log(double a, double b)
General logarithm.static double
log10(double a)
Common logarithmstatic double
log2(double a)
Binary logarithmstatic double
lucasNumber(double n)
Lucas numebrsstatic double
lucasNumber(int n)
Lucas numebrsstatic double
minus(double a, double b)
Subtraction a - b applying canonical rounding if canonical rounding is enabledstatic double
mod(double a, double b)
Modulo operator a % bstatic double
multiply(double a, double b)
Multiplication a * b applying canonical rounding if canonical rounding is enabledstatic double
numberOfPermutations(double n, double k)
Generalized coefficient returning number of k permutations that can be drawn for n elements set.static double
numberOfPermutations(double n, long k)
Generalized coefficient returning number of k permutations that can be drawn for n elements set.static double
plus(double a, double b)
Addition a + b applying canonical rounding if canonical rounding is enabledstatic double
power(double a, double b)
Power function a^bstatic double
rad(double a)
Degrees to radius translation.static double
root(double n, double x)
Nth order root of a numberstatic double
round(double value, int places)
Double roundingstatic double
roundDown(double value, int places)
Double down roundingstatic double
roundHalfUp(double value, int places)
Double half up roundingstatic 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 double
sa(double a)
Normalized sinc function.static double
sec(double a)
Secant trigonometric functionstatic double
sech(double a)
Hyperbolic secant function.static double
sgn(double a)
Signum function.static double
sin(double a)
Sine trigonometric functionstatic double
sinc(double a)
Sinc function.static double
sinh(double a)
Hyperbolic sine function.static double
sqrt(double a)
Square root.static double
Stirling1Number(double n, double k)
Stirling numbers of the first kindstatic double
Stirling1Number(int n, int k)
Stirling numbers of the first kindstatic double
Stirling2Number(double n, double k)
Stirling numbers of the second kindstatic double
Stirling2Number(int n, int k)
Stirling numbers of the second kindstatic double
tan(double a)
Tangent trigonometric functionstatic double
tanh(double a)
Hyperbolic tangent function.static double
tetration(double a, double n)
Tetration, exponential power, power seriesstatic double
ulp(double value)
Unit in the last place(ULP) for doublestatic int
ulpDecimalDigitsBefore(double value)
Unit in The Last Place - number of decimal digits beforestatic double
worpitzkyNumber(double n, double k)
Worpitzky numbersstatic double
worpitzkyNumber(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.
-
decimalNumberLength
public static int decimalNumberLength(double value)
Length of a number represented in a standard decimal format- Parameters:
value
- A given number- Returns:
- Length of a number represented in a standard decimal format including decimal separator, excluding leading zeros (integer part), excluding trailing zeros (fractional part)
-
fractionalPartLength
public static int fractionalPartLength(double value)
Fractional part length of a number represented in a standard decimal format- Parameters:
value
- A given number- Returns:
- Fractional part length of a number represented in a standard decimal format excluding decimal separator, excluding trailing zeros (fractional part)
-
lengthRound
public static double lengthRound(double value)
Intelligent rounding of a number within the decimal position of the ULP (Unit in the Last Place), provided that the result is significantly shortened in the standard decimal notation. Examples: 30.499999999999992 is rounded to 30.5, but 30.499999999999122 will not be rounded. Rounding is made to the decimal position of the ULP minus 2 on condition that the resulted number is shortened by at least 9 places.- Parameters:
value
- A given number- Returns:
- Returns an intelligently rounded number when the decimal position of ULP is a minimum of 11 and when rounded to the position of ULP - 2, shortens the number by a minimum of 9 places. Otherwise, returns original number.
-
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
-
getFunctionValue
public static double getFunctionValue(Expression f, Argument x, double x0)
Calculates function f(x0) (given as expression) assigning Argument x = x0;- Parameters:
f
- the expressionx
- the argumentx0
- the argument value- Returns:
- f.calculate()
- See Also:
Expression
-
getFunctionValues
public static double[] getFunctionValues(Expression f, Argument index, double from, double to, double delta)
Returns array of double values of the function f(i) calculated on the range: i = from to i = to by step = delta- Parameters:
f
- Function expressionindex
- Index argumentfrom
- 'from' valueto
- 'to' valuedelta
- 'delta' step definition- Returns:
- Array of function values
-
-