Class Romberg

  • All Implemented Interfaces:
    Integrator

    public class Romberg
    extends Object
    implements Integrator
    Romberg's method computes an integral by generating a sequence of estimations of the integral value and then doing an extrapolation. The estimations are extrapolated to where the discretization is 0. Simpson's rule is a special case of Romberg's method, with the number of points for extrapolation equal to 2.
    See Also:
    Wikipedia: Romberg's method
    • Constructor Detail

      • Romberg

        public Romberg​(IterativeIntegrator integrator)
        Extend an integrator using Romberg's method.
        Parameters:
        integrator - an iterative integrator that must do at least 2 iterations
    • Method Detail

      • integrate

        public double integrate​(UnivariateRealFunction f,
                                double a,
                                double b)
        Description copied from interface: Integrator
        Integrate function f from a to b, \[ \int_a^b\! f(x)\, dx \]
        Specified by:
        integrate in interface Integrator
        Parameters:
        f - a univariate function
        a - the lower limit
        b - the upper limit
        Returns:
        \(\int_a^b\! f(x)\, dx\)
      • getPrecision

        public double getPrecision()
        Description copied from interface: Integrator
        Get the convergence threshold. The usage depends on the specific integrator. For example, for an IterativeIntegrator, the integral is considered converged if the relative error of two successive sums is less than the threshold.
        Specified by:
        getPrecision in interface Integrator
        Returns:
        the precision