Class MathFunctions

    • 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 function
      static double acosec​(double a)
      Arcus cosecant - inverse trigonometric cosecant function
      static double actan​(double a)
      Arcus cotangent - inverse trigonometric cotangent function
      static 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 function
      static double asin​(double a)
      Arcus sine - inverse trigonometric sine function
      static double atan​(double a)
      Arcus tangent - inverse trigonometric tangent function
      static double bellNumber​(double n)
      Bell number
      static double bellNumber​(int n)
      Bell Numbers
      static double bernoulliNumber​(double m, double n)
      Bernoulli numbers
      static double bernoulliNumber​(int m, int n)
      Bernoulli numbers
      static double binomCoeff​(double n, double k)
      Generalized binomial coefficient
      static double binomCoeff​(double n, long k)
      Generalized binomial coefficient
      static double catalanNumber​(double n)
      Catalan numbers
      static double catalanNumber​(int n)
      Catalan numbers
      static 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 value
      static double continuedFraction​(double... sequence)
      Continued fraction
      static double continuedPolynomial​(double... x)
      Continued polynomial
      static double cos​(double a)
      Cosine trigonometric function
      static double cosec​(double a)
      Cosecant trigonometric function
      static 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 function
      static int decimalDigitsBefore​(double value)
      For very small number returns the position of first significant digit, ie 0.1 = 1, 0.01 = 2
      static int decimalNumberLength​(double value)
      Length of a number represented in a standard decimal format
      static 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 enabled
      static double eulerNumber​(double n, double k)
      Euler numbers
      static double eulerNumber​(int n, int k)
      Euler numbers
      static double eulerPolynomial​(double m, double x)
      Euler polynomial
      static double eulerPolynomial​(int m, double x)
      Euler polynomial
      static double exp​(double a)
      Exponential function.
      static double factorial​(double n)
      Factorial
      static double factorial​(int n)
      Factorial
      static double factorialFalling​(double x, double n)
      Falling factorial polynomial
      static double factorialRising​(double x, double n)
      Rising factorial polynomial
      static double fibonacciNumber​(double n)
      Fibonacci numbers
      static double fibonacciNumber​(int n)
      Fibonacci numbers
      static double floor​(double a)
      Floor function.
      static int fractionalPartLength​(double value)
      Fractional part length of a number represented in a standard decimal format
      static 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 = delta
      static double harmonicNumber​(double n)
      Harmonic number
      static double harmonicNumber​(double x, double n)
      Harmonic number 1/1 + 1/2^x + ... + 1/n^x
      static double harmonicNumber​(double x, int n)
      Harmonic number 1/1 + 1/2^x + ... + 1/n^x
      static double harmonicNumber​(int n)
      Harmonic numer
      static double integerPart​(double x)
      Returns integer part of a double value.
      static boolean isAlmostInt​(double a)
      Verifies whether provided number is almost integer
      static boolean isInteger​(double x)
      Check whether double value is almost integer.
      static double kroneckerDelta​(double i, double j)
      Kronecker delta
      static double kroneckerDelta​(int i, int j)
      Kronecker delta
      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.
      static double ln​(double a)
      Natural logarithm
      static double log​(double a, double b)
      General logarithm.
      static double log10​(double a)
      Common logarithm
      static double log2​(double a)
      Binary logarithm
      static double lucasNumber​(double n)
      Lucas numebrs
      static double lucasNumber​(int n)
      Lucas numebrs
      static double minus​(double a, double b)
      Subtraction a - b applying canonical rounding if canonical rounding is enabled
      static double mod​(double a, double b)
      Modulo operator a % b
      static double multiply​(double a, double b)
      Multiplication a * b applying canonical rounding if canonical rounding is enabled
      static 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 enabled
      static double power​(double a, double b)
      Power function a^b
      static double rad​(double a)
      Degrees to radius translation.
      static double root​(double n, double x)
      Nth order root of a number
      static double round​(double value, int places)
      Double rounding
      static double roundDown​(double value, int places)
      Double down rounding
      static double roundHalfUp​(double value, int places)
      Double half up rounding
      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)
      static double sa​(double a)
      Normalized sinc function.
      static double sec​(double a)
      Secant trigonometric function
      static double sech​(double a)
      Hyperbolic secant function.
      static double sgn​(double a)
      Signum function.
      static double sin​(double a)
      Sine trigonometric function
      static 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 kind
      static double Stirling1Number​(int n, int k)
      Stirling numbers of the first kind
      static double Stirling2Number​(double n, double k)
      Stirling numbers of the second kind
      static double Stirling2Number​(int n, int k)
      Stirling numbers of the second kind
      static double tan​(double a)
      Tangent trigonometric function
      static double tanh​(double a)
      Hyperbolic tangent function.
      static double tetration​(double a, double n)
      Tetration, exponential power, power series
      static double ulp​(double value)
      Unit in the last place(ULP) for double
      static int ulpDecimalDigitsBefore​(double value)
      Unit in The Last Place - number of decimal digits before
      static double worpitzkyNumber​(double n, double k)
      Worpitzky numbers
      static double worpitzkyNumber​(int n, int k)
      Worpitzky numbers
    • Constructor Detail

      • MathFunctions

        public MathFunctions()
    • 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 parameter
        b - 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 parameter
        b - 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 parameter
        b - 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 parameter
        b - 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​(double n,
                                         double k)
        Euler numbers
        Parameters:
        n - the n function param
        k - 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 - Argument
        n - 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 - Argument
        n - 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 parameter
        k - 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 parameter
        k - 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 parameter
        k - 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 parameter
        k - 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 parameter
        n - 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 parameter
        n - 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​(double n,
                                             double k)
        Stirling numbers of the first kind
        Parameters:
        n - the n function parameter
        k - 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​(double n,
                                             double k)
        Stirling numbers of the second kind
        Parameters:
        n - the n function parameter
        k - 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 parameter
        k - 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 parameter
        k - 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 parameter
        n - 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 parameter
        n - 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​(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​(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 parameter
        j - 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 parameter
        j - 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 parameter
        x - 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 parameter
        x - 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 value
        a - the left (lower) limit
        b - 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 value
        a - the left (lower) limit
        b - 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 value
        a - the left (lower) limit
        b - 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 value
        a - the left (lower) limit
        b - 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 parameter
        b - 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 order
        x - 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 - base
        n - exponent
        Returns:
        Tetration result.
      • mod

        public static double mod​(double a,
                                 double b)
        Modulo operator a % b
        Parameters:
        a - the a function parameter
        b - 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 rounded
        places - decimal places
        Returns:
        Rounded value
      • roundHalfUp

        public static double roundHalfUp​(double value,
                                         int places)
        Double half up rounding
        Parameters:
        value - double value to be rounded
        places - decimal places
        Returns:
        Rounded value
      • roundDown

        public static double roundDown​(double value,
                                       int places)
        Double down rounding
        Parameters:
        value - double value to be rounded
        places - 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.
      • 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 expression
        x - the argument
        x0 - 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 expression
        index - Index argument
        from - 'from' value
        to - 'to' value
        delta - 'delta' step definition
        Returns:
        Array of function values