Package org.nevec.rjm

Class BigDecimalMath

    • Constructor Summary

      Constructors 
      Constructor Description
      BigDecimalMath()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.math.BigDecimal acos​(java.math.BigDecimal x)
      The inverse trigonometric cosine.
      static java.math.BigDecimal acosh​(java.math.BigDecimal x)
      The inverse hyperbolic cosine.
      static java.math.BigDecimal add​(java.math.BigDecimal x, java.math.BigInteger y)
      Add a BigDecimal and a BigInteger.
      static java.math.BigDecimal addRound​(java.math.BigDecimal x, java.math.BigDecimal y)
      Add and round according to the larger of the two ulp's.
      static BigComplex addRound​(BigComplex x, java.math.BigDecimal y)
      Add and round according to the larger of the two ulp's.
      static BigComplex addRound​(BigComplex x, BigComplex y)
      Add and round according to the larger of the two ulp's.
      static java.math.BigDecimal asin​(java.math.BigDecimal x)
      The inverse trigonometric sine.
      static java.math.BigDecimal asinh​(java.math.BigDecimal x)
      The inverse hyperbolic sine.
      static java.math.BigDecimal atan​(java.math.BigDecimal x)
      The inverse trigonometric tangent.
      protected static java.math.BigDecimal broadhurstBBP​(int n, int p, int[] a, java.math.MathContext mc)
      Broadhurst ladder sequence.
      static java.math.BigDecimal cbrt​(java.math.BigDecimal x)
      The cube root.
      static java.math.BigDecimal cos​(java.math.BigDecimal x)
      Trigonometric cosine.
      static java.math.BigDecimal cosh​(java.math.BigDecimal x)
      The hyperbolic cosine.
      static double cot​(double x)
      trigonometric cot.
      static java.math.BigDecimal cot​(java.math.BigDecimal x)
      The trigonometric co-tangent.
      static java.math.BigDecimal divideRound​(int n, java.math.BigDecimal x)
      Divide and round.
      static java.math.BigDecimal divideRound​(java.math.BigDecimal x, int n)
      Divide and round.
      static java.math.BigDecimal divideRound​(java.math.BigDecimal x, java.math.BigDecimal y)
      Divide and round.
      static java.math.BigDecimal divideRound​(java.math.BigDecimal x, java.math.BigInteger n)
      Divide and round.
      static java.math.BigDecimal divideRound​(java.math.BigInteger n, java.math.BigDecimal x)
      Divide and round.
      static BigComplex divideRound​(java.math.BigInteger n, BigComplex x)
      Divide and round.
      static BigComplex divideRound​(BigComplex x, BigComplex y)
      Divide and round.
      static int err2prec​(double xerr)
      Convert a relative error to a precision.
      static int err2prec​(double x, double xerr)
      Convert an absolute error to a precision.
      static int err2prec​(java.math.BigDecimal x, java.math.BigDecimal xerr)
      Convert an absolute error to a precision.
      static java.math.BigDecimal exp​(java.math.BigDecimal x)
      The exponential function.
      static java.math.BigDecimal exp​(java.math.MathContext mc)
      The base of the natural logarithm.
      static java.math.BigDecimal gamma​(java.math.MathContext mc)
      Euler-Mascheroni constant.
      static java.math.BigDecimal Gamma​(java.math.BigDecimal x)
      The Gamma function.
      static java.math.BigDecimal Gamma​(Rational q, java.math.MathContext mc)
      The Gamma function.
      static java.math.BigDecimal hypot​(int n, java.math.BigDecimal x)
      The hypotenuse.
      static java.math.BigDecimal hypot​(java.math.BigDecimal x, java.math.BigDecimal y)
      The hypotenuse.
      static BigComplex invertRound​(BigComplex z)
      Build the inverse and maintain the approximate accuracy.
      static java.math.BigDecimal log​(int n, java.math.MathContext mc)
      The natural logarithm.
      static java.math.BigDecimal log​(java.math.BigDecimal x)
      The natural logarithm.
      static java.math.BigDecimal log​(Rational r, java.math.MathContext mc)
      The natural logarithm.
      static java.math.BigDecimal mod2pi​(java.math.BigDecimal x)
      Reduce value to the interval [0,2*Pi].
      static java.math.BigDecimal modpi​(java.math.BigDecimal x)
      Reduce value to the interval [-Pi/2,Pi/2].
      static java.math.BigDecimal multiplyRound​(java.math.BigDecimal x, int n)
      Multiply and round.
      static java.math.BigDecimal multiplyRound​(java.math.BigDecimal x, java.math.BigDecimal y)
      Multiply and round.
      static java.math.BigDecimal multiplyRound​(java.math.BigDecimal x, java.math.BigInteger n)
      Multiply and round.
      static java.math.BigDecimal multiplyRound​(java.math.BigDecimal x, Rational f)
      Multiply and round.
      static BigComplex multiplyRound​(BigComplex x, java.math.BigDecimal y)
      Multiply and round.
      static BigComplex multiplyRound​(BigComplex x, BigComplex y)
      Multiply and round.
      static java.math.BigDecimal pi​(java.math.MathContext mc)
      Euler's constant.
      static java.math.BigDecimal pochhammer​(java.math.BigDecimal x, int n)
      Pochhammer's function.
      static java.math.BigDecimal pow​(java.math.BigDecimal x, java.math.BigDecimal y)
      Power function.
      static java.math.BigDecimal powRound​(java.math.BigDecimal x, int n)
      Raise to an integer power and round.
      static java.math.BigDecimal powRound​(java.math.BigDecimal x, java.math.BigInteger n)
      Raise to an integer power and round.
      static java.math.BigDecimal powRound​(java.math.BigDecimal x, Rational q)
      Raise to a fractional power and round.
      static double prec2err​(double x, int prec)
      Convert a precision (relative error) to an absolute error.
      static double psi​(double x)
      Digamma function.
      static java.math.BigDecimal root​(int n, java.math.BigDecimal x)
      The integer root.
      static java.math.BigDecimal scalePrec​(java.math.BigDecimal x, int d)
      Append decimal zeros to the value.
      static java.math.BigDecimal scalePrec​(java.math.BigDecimal x, java.math.MathContext mc)
      Boost the precision by appending decimal zeros to the value.
      static BigComplex scalePrec​(BigComplex x, int d)
      Append decimal zeros to the value.
      static java.math.BigDecimal sin​(java.math.BigDecimal x)
      Trigonometric sine.
      static java.math.BigDecimal sinh​(java.math.BigDecimal x)
      The hyperbolic sine.
      static java.math.BigDecimal sqrt​(java.math.BigDecimal x)
      The square root.
      static java.math.BigDecimal sqrt​(java.math.BigDecimal x, java.math.MathContext mc)
      The square root.
      static java.math.BigDecimal subtractRound​(java.math.BigDecimal x, java.math.BigDecimal y)
      Subtract and round according to the larger of the two ulp's.
      static BigComplex subtractRound​(BigComplex x, BigComplex y)
      Subtract and round according to the larger of the two ulp's.
      static java.math.BigDecimal tan​(java.math.BigDecimal x)
      The trigonometric tangent.
      static java.math.BigDecimal tanh​(java.math.BigDecimal x)
      The hyperbolic tangent.
      static java.math.BigDecimal zeta​(int n, java.math.MathContext mc)
      Riemann zeta function.
      static double zeta1​(int n)
      Riemann zeta function.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • BigDecimalMath

        public BigDecimalMath()
    • Method Detail

      • pi

        public static java.math.BigDecimal pi​(java.math.MathContext mc)
        Euler's constant.
        Parameters:
        mc - The required precision of the result.
        Returns:
        3.14159...
        Since:
        2009-05-29
      • gamma

        public static java.math.BigDecimal gamma​(java.math.MathContext mc)
        Euler-Mascheroni constant.
        Parameters:
        mc - The required precision of the result.
        Returns:
        0.577...
        Since:
        2009-08-13
      • sqrt

        public static java.math.BigDecimal sqrt​(java.math.BigDecimal x,
                                                java.math.MathContext mc)
        The square root.
        Parameters:
        x - the non-negative argument.
        mc -
        Returns:
        the square root of the BigDecimal.
        Since:
        2008-10-27
      • sqrt

        public static java.math.BigDecimal sqrt​(java.math.BigDecimal x)
        The square root.
        Parameters:
        x - the non-negative argument.
        Returns:
        the square root of the BigDecimal rounded to the precision implied by x.
        Since:
        2009-06-25
      • cbrt

        public static java.math.BigDecimal cbrt​(java.math.BigDecimal x)
        The cube root.
        Parameters:
        x - The argument.
        Returns:
        The cubic root of the BigDecimal rounded to the precision implied by x. The sign of the result is the sign of the argument.
        Since:
        2009-08-16
      • root

        public static java.math.BigDecimal root​(int n,
                                                java.math.BigDecimal x)
        The integer root.
        Parameters:
        n - the positive argument.
        x - the non-negative argument.
        Returns:
        The n-th root of the BigDecimal rounded to the precision implied by x, x^(1/n).
        Since:
        2009-07-30
      • hypot

        public static java.math.BigDecimal hypot​(java.math.BigDecimal x,
                                                 java.math.BigDecimal y)
        The hypotenuse.
        Parameters:
        x - the first argument.
        y - the second argument.
        Returns:
        the square root of the sum of the squares of the two arguments, sqrt(x^2+y^2).
        Since:
        2009-06-25
      • hypot

        public static java.math.BigDecimal hypot​(int n,
                                                 java.math.BigDecimal x)
        The hypotenuse.
        Parameters:
        n - the first argument.
        x - the second argument.
        Returns:
        the square root of the sum of the squares of the two arguments, sqrt(n^2+x^2).
        Since:
        2009-08-05
      • exp

        public static java.math.BigDecimal exp​(java.math.BigDecimal x)
        The exponential function.
        Parameters:
        x - the argument.
        Returns:
        exp(x). The precision of the result is implicitly defined by the precision in the argument. In particular this means that "Invalid Operation" errors are thrown if catastrophic cancellation of digits causes the result to have no valid digits left.
        Since:
        2009-05-29
      • exp

        public static java.math.BigDecimal exp​(java.math.MathContext mc)
        The base of the natural logarithm.
        Parameters:
        mc - the required precision of the result
        Returns:
        exp(1) = 2.71828....
        Since:
        2009-05-29
      • log

        public static java.math.BigDecimal log​(java.math.BigDecimal x)
        The natural logarithm.
        Parameters:
        x - the argument.
        Returns:
        ln(x). The precision of the result is implicitly defined by the precision in the argument.
        Since:
        2009-05-29
      • log

        public static java.math.BigDecimal log​(int n,
                                               java.math.MathContext mc)
        The natural logarithm.
        Parameters:
        n - The main argument, a strictly positive integer.
        mc - The requirements on the precision.
        Returns:
        ln(n).
        Since:
        2009-08-08
      • log

        public static java.math.BigDecimal log​(Rational r,
                                               java.math.MathContext mc)
        The natural logarithm.
        Parameters:
        r - The main argument, a strictly positive value.
        mc - The requirements on the precision.
        Returns:
        ln(r).
        Since:
        2009-08-09
      • pow

        public static java.math.BigDecimal pow​(java.math.BigDecimal x,
                                               java.math.BigDecimal y)
        Power function.
        Parameters:
        x - Base of the power.
        y - Exponent of the power.
        Returns:
        x^y. The estimation of the relative error in the result is |log(x)*err(y)|+|y*err(x)/x|
        Since:
        2009-06-01
      • powRound

        public static java.math.BigDecimal powRound​(java.math.BigDecimal x,
                                                    int n)
        Raise to an integer power and round.
        Parameters:
        x - The base.
        n - The exponent.
        Returns:
        x^n.
        Since:
        2009-08-13, 2010-05-26 handle also n<0 cases.
      • powRound

        public static java.math.BigDecimal powRound​(java.math.BigDecimal x,
                                                    java.math.BigInteger n)
        Raise to an integer power and round.
        Parameters:
        x - The base.
        n - The exponent. The current implementation allows n only in the interval of the standard int values.
        Returns:
        x^n.
        Since:
        2010-05-26
      • powRound

        public static java.math.BigDecimal powRound​(java.math.BigDecimal x,
                                                    Rational q)
        Raise to a fractional power and round.
        Parameters:
        x - The base. Generally enforced to be positive, with the exception of integer exponents where the sign is carried over according to the parity of the exponent.
        q - The exponent.
        Returns:
        x^q.
        Since:
        2010-05-26
      • sin

        public static java.math.BigDecimal sin​(java.math.BigDecimal x)
        Trigonometric sine.
        Parameters:
        x - The argument in radians.
        Returns:
        sin(x) in the range -1 to 1.
        Since:
        2009-06-01
      • cos

        public static java.math.BigDecimal cos​(java.math.BigDecimal x)
        Trigonometric cosine.
        Parameters:
        x - The argument in radians.
        Returns:
        cos(x) in the range -1 to 1.
        Since:
        2009-06-01
      • tan

        public static java.math.BigDecimal tan​(java.math.BigDecimal x)
        The trigonometric tangent.
        Parameters:
        x - the argument in radians.
        Returns:
        the tan(x)
      • cot

        public static java.math.BigDecimal cot​(java.math.BigDecimal x)
        The trigonometric co-tangent.
        Parameters:
        x - the argument in radians.
        Returns:
        the cot(x)
        Since:
        2009-07-31
      • asin

        public static java.math.BigDecimal asin​(java.math.BigDecimal x)
        The inverse trigonometric sine.
        Parameters:
        x - the argument.
        Returns:
        the arcsin(x) in radians.
      • acos

        public static java.math.BigDecimal acos​(java.math.BigDecimal x)
        The inverse trigonometric cosine.
        Parameters:
        x - the argument.
        Returns:
        the arccos(x) in radians.
        Since:
        2009-09-29
      • atan

        public static java.math.BigDecimal atan​(java.math.BigDecimal x)
        The inverse trigonometric tangent.
        Parameters:
        x - the argument.
        Returns:
        the principal value of arctan(x) in radians in the range -pi/2 to +pi/2.
        Since:
        2009-08-03
      • cosh

        public static java.math.BigDecimal cosh​(java.math.BigDecimal x)
        The hyperbolic cosine.
        Parameters:
        x - The argument.
        Returns:
        The cosh(x) = (exp(x)+exp(-x))/2 .
        Since:
        2009-08-19
      • sinh

        public static java.math.BigDecimal sinh​(java.math.BigDecimal x)
        The hyperbolic sine.
        Parameters:
        x - the argument.
        Returns:
        the sinh(x) = (exp(x)-exp(-x))/2 .
        Since:
        2009-08-19
      • tanh

        public static java.math.BigDecimal tanh​(java.math.BigDecimal x)
        The hyperbolic tangent.
        Parameters:
        x - The argument.
        Returns:
        The tanh(x) = sinh(x)/cosh(x).
        Since:
        2009-08-20
      • asinh

        public static java.math.BigDecimal asinh​(java.math.BigDecimal x)
        The inverse hyperbolic sine.
        Parameters:
        x - The argument.
        Returns:
        The arcsinh(x) .
        Since:
        2009-08-20
      • acosh

        public static java.math.BigDecimal acosh​(java.math.BigDecimal x)
        The inverse hyperbolic cosine.
        Parameters:
        x - The argument.
        Returns:
        The arccosh(x) .
        Since:
        2009-08-20
      • Gamma

        public static java.math.BigDecimal Gamma​(java.math.BigDecimal x)
        The Gamma function.
        Parameters:
        x - The argument.
        Returns:
        Gamma(x).
        Since:
        2009-08-06
      • Gamma

        public static java.math.BigDecimal Gamma​(Rational q,
                                                 java.math.MathContext mc)
        The Gamma function.
        Parameters:
        q - The argument.
        mc - The required accuracy in the result.
        Returns:
        Gamma(x).
        Since:
        2010-05-26
      • pochhammer

        public static java.math.BigDecimal pochhammer​(java.math.BigDecimal x,
                                                      int n)
        Pochhammer's function.
        Parameters:
        x - The main argument.
        n - The non-negative index.
        Returns:
        (x)_n = x(x+1)(x+2)*...*(x+n-1).
        Since:
        2009-08-19
      • mod2pi

        public static java.math.BigDecimal mod2pi​(java.math.BigDecimal x)
        Reduce value to the interval [0,2*Pi].
        Parameters:
        x - the original value
        Returns:
        the value modulo 2*pi in the interval from 0 to 2*pi.
        Since:
        2009-06-01
      • modpi

        public static java.math.BigDecimal modpi​(java.math.BigDecimal x)
        Reduce value to the interval [-Pi/2,Pi/2].
        Parameters:
        x - The original value
        Returns:
        The value modulo pi, shifted to the interval from -Pi/2 to Pi/2.
        Since:
        2009-07-31
      • zeta

        public static java.math.BigDecimal zeta​(int n,
                                                java.math.MathContext mc)
        Riemann zeta function.
        Parameters:
        n - The positive integer argument.
        mc - Specification of the accuracy of the result.
        Returns:
        zeta(n).
        Since:
        2009-08-05
      • zeta1

        public static double zeta1​(int n)
        Riemann zeta function.
        Parameters:
        n - The positive integer argument.
        Returns:
        zeta(n)-1.
        Since:
        2009-08-20
      • cot

        public static double cot​(double x)
        trigonometric cot.
        Parameters:
        x - The argument.
        Returns:
        cot(x) = 1/tan(x).
      • psi

        public static double psi​(double x)
        Digamma function.
        Parameters:
        x - The main argument.
        Returns:
        psi(x). The error is sometimes up to 10 ulp, where AS 6.3.15 suffers from cancellation of digits and psi=0
        Since:
        2009-08-26
      • broadhurstBBP

        protected static java.math.BigDecimal broadhurstBBP​(int n,
                                                            int p,
                                                            int[] a,
                                                            java.math.MathContext mc)
        Broadhurst ladder sequence.
        Parameters:
        a - The vector of 8 integer arguments
        mc - Specification of the accuracy of the result
        Returns:
        S_(n,p)(a)
        Since:
        2009-08-09
        See Also:
        arXiv:math/9803067
      • add

        public static java.math.BigDecimal add​(java.math.BigDecimal x,
                                               java.math.BigInteger y)
        Add a BigDecimal and a BigInteger.
        Parameters:
        x - The left summand
        y - The right summand
        Returns:
        The sum x+y.
        Since:
        2012-03-02
      • addRound

        public static java.math.BigDecimal addRound​(java.math.BigDecimal x,
                                                    java.math.BigDecimal y)
        Add and round according to the larger of the two ulp's.
        Parameters:
        x - The left summand
        y - The right summand
        Returns:
        The sum x+y.
        Since:
        2009-07-30
      • addRound

        public static BigComplex addRound​(BigComplex x,
                                          java.math.BigDecimal y)
        Add and round according to the larger of the two ulp's.
        Parameters:
        x - The left summand
        y - The right summand
        Returns:
        The sum x+y.
        Since:
        2010-07-19
      • addRound

        public static BigComplex addRound​(BigComplex x,
                                          BigComplex y)
        Add and round according to the larger of the two ulp's.
        Parameters:
        x - The left summand
        y - The right summand
        Returns:
        The sum x+y.
        Since:
        2010-07-19
      • subtractRound

        public static java.math.BigDecimal subtractRound​(java.math.BigDecimal x,
                                                         java.math.BigDecimal y)
        Subtract and round according to the larger of the two ulp's.
        Parameters:
        x - The left term.
        y - The right term.
        Returns:
        The difference x-y.
        Since:
        2009-07-30
      • subtractRound

        public static BigComplex subtractRound​(BigComplex x,
                                               BigComplex y)
        Subtract and round according to the larger of the two ulp's.
        Parameters:
        x - The left summand
        y - The right summand
        Returns:
        The difference x-y.
        Since:
        2010-07-19
      • multiplyRound

        public static java.math.BigDecimal multiplyRound​(java.math.BigDecimal x,
                                                         java.math.BigDecimal y)
        Multiply and round.
        Parameters:
        x - The left factor.
        y - The right factor.
        Returns:
        The product x*y.
        Since:
        2009-07-30
      • multiplyRound

        public static BigComplex multiplyRound​(BigComplex x,
                                               java.math.BigDecimal y)
        Multiply and round.
        Parameters:
        x - The left factor.
        y - The right factor.
        Returns:
        The product x*y.
        Since:
        2010-07-19
      • multiplyRound

        public static BigComplex multiplyRound​(BigComplex x,
                                               BigComplex y)
        Multiply and round.
        Parameters:
        x - The left factor.
        y - The right factor.
        Returns:
        The product x*y.
        Since:
        2010-07-19
      • multiplyRound

        public static java.math.BigDecimal multiplyRound​(java.math.BigDecimal x,
                                                         Rational f)
        Multiply and round.
        Parameters:
        x - The left factor.
        f - The right factor.
        Returns:
        The product x*f.
        Since:
        2009-07-30
      • multiplyRound

        public static java.math.BigDecimal multiplyRound​(java.math.BigDecimal x,
                                                         int n)
        Multiply and round.
        Parameters:
        x - The left factor.
        n - The right factor.
        Returns:
        The product x*n.
        Since:
        2009-07-30
      • multiplyRound

        public static java.math.BigDecimal multiplyRound​(java.math.BigDecimal x,
                                                         java.math.BigInteger n)
        Multiply and round.
        Parameters:
        x - The left factor.
        n - The right factor.
        Returns:
        the product x*n
        Since:
        2009-07-30
      • divideRound

        public static java.math.BigDecimal divideRound​(java.math.BigDecimal x,
                                                       java.math.BigDecimal y)
        Divide and round.
        Parameters:
        x - The numerator
        y - The denominator
        Returns:
        the divided x/y
        Since:
        2009-07-30
      • invertRound

        public static BigComplex invertRound​(BigComplex z)
        Build the inverse and maintain the approximate accuracy.
        Parameters:
        z - The denominator
        Returns:
        The divided 1/z = [Re(z)-i*Im(z)]/ [Re^2 z + Im^2 z]
        Since:
        2010-07-19
      • divideRound

        public static BigComplex divideRound​(BigComplex x,
                                             BigComplex y)
        Divide and round.
        Parameters:
        x - The numerator
        y - The denominator
        Returns:
        the divided x/y
        Since:
        2010-07-19
      • divideRound

        public static java.math.BigDecimal divideRound​(java.math.BigDecimal x,
                                                       int n)
        Divide and round.
        Parameters:
        x - The numerator
        n - The denominator
        Returns:
        the divided x/n
        Since:
        2009-07-30
      • divideRound

        public static java.math.BigDecimal divideRound​(java.math.BigDecimal x,
                                                       java.math.BigInteger n)
        Divide and round.
        Parameters:
        x - The numerator
        n - The denominator
        Returns:
        the divided x/n
        Since:
        2009-07-30
      • divideRound

        public static java.math.BigDecimal divideRound​(java.math.BigInteger n,
                                                       java.math.BigDecimal x)
        Divide and round.
        Parameters:
        n - The numerator
        x - The denominator
        Returns:
        the divided n/x
        Since:
        2009-08-05
      • divideRound

        public static BigComplex divideRound​(java.math.BigInteger n,
                                             BigComplex x)
        Divide and round.
        Parameters:
        n - The numerator
        x - The denominator
        Returns:
        the divided n/x
        Since:
        2012-03-01
      • divideRound

        public static java.math.BigDecimal divideRound​(int n,
                                                       java.math.BigDecimal x)
        Divide and round.
        Parameters:
        n - The numerator.
        x - The denominator.
        Returns:
        the divided n/x.
        Since:
        2009-08-05
      • scalePrec

        public static java.math.BigDecimal scalePrec​(java.math.BigDecimal x,
                                                     int d)
        Append decimal zeros to the value. This returns a value which appears to have a higher precision than the input.
        Parameters:
        x - The input value
        d - The (positive) value of zeros to be added as least significant digits.
        Returns:
        The same value as the input but with increased (pseudo) precision.
      • scalePrec

        public static BigComplex scalePrec​(BigComplex x,
                                           int d)
        Append decimal zeros to the value. This returns a value which appears to have a higher precision than the input.
        Parameters:
        x - The input value
        d - The (positive) value of zeros to be added as least significant digits.
        Returns:
        The same value as the input but with increased (pseudo) precision.
      • scalePrec

        public static java.math.BigDecimal scalePrec​(java.math.BigDecimal x,
                                                     java.math.MathContext mc)
        Boost the precision by appending decimal zeros to the value. This returns a value which appears to have a higher precision than the input.
        Parameters:
        x - The input value
        mc - The requirement on the minimum precision on return.
        Returns:
        The same value as the input but with increased (pseudo) precision.
      • err2prec

        public static int err2prec​(java.math.BigDecimal x,
                                   java.math.BigDecimal xerr)
        Convert an absolute error to a precision.
        Parameters:
        x - The value of the variable
        xerr - The absolute error in the variable
        Returns:
        The number of valid digits in x. The value is rounded down, and on the pessimistic side for that reason.
        Since:
        2009-06-25
      • err2prec

        public static int err2prec​(double x,
                                   double xerr)
        Convert an absolute error to a precision.
        Parameters:
        x - The value of the variable The value returned depends only on the absolute value, not on the sign.
        xerr - The absolute error in the variable The value returned depends only on the absolute value, not on the sign.
        Returns:
        The number of valid digits in x. Derived from the representation x+- xerr, as if the error was represented in a "half width" (half of the error bar) form. The value is rounded down, and on the pessimistic side for that reason.
        Since:
        2009-05-30
      • err2prec

        public static int err2prec​(double xerr)
        Convert a relative error to a precision.
        Parameters:
        xerr - The relative error in the variable. The value returned depends only on the absolute value, not on the sign.
        Returns:
        The number of valid digits in x. The value is rounded down, and on the pessimistic side for that reason.
        Since:
        2009-08-05
      • prec2err

        public static double prec2err​(double x,
                                      int prec)
        Convert a precision (relative error) to an absolute error. The is the inverse functionality of err2prec().
        Parameters:
        x - The value of the variable The value returned depends only on the absolute value, not on the sign.
        prec - The number of valid digits of the variable.
        Returns:
        the absolute error in x. Derived from the an accuracy of one half of the ulp.
        Since:
        2009-08-09