Examples of round()


Examples of java.math.BigDecimal.round()

                 * The first derivative of sinh(x) is cosh(x), so the absolute error
                 * in the result is cosh(x)*errx, and the relative error is coth(x)*errx = errx/tanh(x)
                 */
                //double eps = Math.tanh(x.doubleValue());                                       // removed by l.bruninx, 2012-03-19
                //MathContext mc = new MathContext(err2prec(0.5 * x.ulp().doubleValue() / eps)); // removed by l.bruninx, 2012-03-19
                return resul.round(mc);
            }
            else {
                BigDecimal xhighpr = scalePrec(x, 2);
                /* Simple Taylor expansion, sum_{i=0..infinity} x^(2i+1)/(2i+1)! */
                BigDecimal resul = xhighpr;
View Full Code Here

Examples of java.math.BigDecimal.round()

             * The absolute error in arcsinh x is err(x)/sqrt(1+x^2)
             */
            double xDbl = x.doubleValue();
            double eps = 0.5 * x.ulp().doubleValue() / Math.hypot(1., xDbl);
            MathContext mc = new MathContext(err2prec(logx.doubleValue(), eps));
            return logx.round(mc);
        }
    } /* BigDecimalMath.asinh */

    /** The inverse hyperbolic cosine.
     * @param x The argument.
View Full Code Here

Examples of java.math.BigDecimal.round()

             * The absolute error in arcsinh x is err(x)/sqrt(x^2-1)
             */
            double xDbl = x.doubleValue();
            double eps = 0.5 * x.ulp().doubleValue() / Math.sqrt(xDbl * xDbl - 1.);
            MathContext mc = new MathContext(err2prec(logx.doubleValue(), eps));
            return logx.round(mc);
        }
    } /* BigDecimalMath.acosh */

    /** The Gamma function.
     * @param x The argument.
View Full Code Here

Examples of java.math.BigDecimal.round()

                     * smaller than the relative error in z^n/n (the absolute error of thelatter  is the
                     * absolute error in z)
                     */
                    BigDecimal c = divideRound(z.pow(n, mcloc), n);
                    MathContext m = new MathContext(err2prec(n * z.ulp().doubleValue() / 2. / z.doubleValue()));
                    c = c.round(m);

                    /* At larger n, zeta(n)-1 is roughly 1/2^n. The product is c/2^n.
                     * The relative error in c is c.ulp/2/c . The error in the product should be small versus eps/10.
                     * Error from 1/2^n is c*err(sigma-1).
                     * We need a relative error of zeta-1 of the order of c.ulp/50/c. This is an absolute
View Full Code Here

Examples of java.math.BigDecimal.round()

            double eps = 0.5 * xUlpDbl / Math.abs(xDbl);
            for (int i = 1; i < n; i++) {
                eps += 0.5 * xUlpDbl / Math.abs(xDbl + i);
                resul = resul.multiply(xhighpr.add(new BigDecimal(i)));
                final MathContext mcloc = new MathContext(4 + err2prec(eps));
                resul = resul.round(mcloc);
            }
            return resul.round(new MathContext(err2prec(eps)));
        }
    } /* BigDecimalMath.pochhammer */

 
View Full Code Here

Examples of java.math.BigDecimal.round()

                eps += 0.5 * xUlpDbl / Math.abs(xDbl + i);
                resul = resul.multiply(xhighpr.add(new BigDecimal(i)));
                final MathContext mcloc = new MathContext(4 + err2prec(eps));
                resul = resul.round(mcloc);
            }
            return resul.round(new MathContext(err2prec(eps)));
        }
    } /* BigDecimalMath.pochhammer */

    /** Reduce value to the interval [0,2*Pi].
     * @param x the original value
View Full Code Here

Examples of java.math.BigDecimal.round()

        /*
         * The actual precision is set by the input value, its absolute value of x.ulp()/2.
         */
        mc = new MathContext(err2prec(res.doubleValue(), x.ulp().doubleValue() / 2.));
        return res.round(mc);
    } /* mod2pi */

    /** Reduce value to the interval [-Pi/2,Pi/2].
     * @param x The original value
     * @return The value modulo pi, shifted to the interval from -Pi/2 to Pi/2.
View Full Code Here

Examples of java.math.BigDecimal.round()

        /*
         * The actual precision is set by the input value, its absolute value of x.ulp()/2.
         */
        mc = new MathContext(err2prec(res.doubleValue(), x.ulp().doubleValue() / 2.));
        return res.round(mc);
    } /* modpi */

    /** Riemann zeta function.
     * @param n The positive integer argument.
     * @param mc Specification of the accuracy of the result.
View Full Code Here

Examples of java.math.BigDecimal.round()

        /*
         * The estimation of the absolute error in the result is |err(y)|+|err(x)|
         */
        double errR = Math.abs(y.ulp().doubleValue() / 2.) + Math.abs(x.ulp().doubleValue() / 2.);
        MathContext mc = new MathContext(err2prec(resul.doubleValue(), errR));
        return resul.round(mc);
    } /* addRound */

    /** Add and round according to the larger of the two ulp's.
     * @param x The left summand
     * @param y The right summand
View Full Code Here

Examples of java.math.BigDecimal.round()

        /*
         * The estimation of the absolute error in the result is |err(y)|+|err(x)|
         */
        double errR = Math.abs(y.ulp().doubleValue() / 2.) + Math.abs(x.ulp().doubleValue() / 2.);
        MathContext mc = new MathContext(err2prec(resul.doubleValue(), errR));
        return resul.round(mc);
    } /* subtractRound */

    /** Subtract and round according to the larger of the two ulp's.
     * @param x The left summand
     * @param y The right summand
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.