SuanShu, a Java numerical and statistical library

com.numericalmethod.suanshu.analysis.integration.univariate.riemann
Class Romberg

java.lang.Object
  extended by com.numericalmethod.suanshu.analysis.integration.univariate.riemann.Romberg
All Implemented Interfaces:
Integrator

public class Romberg
extends java.lang.Object
implements Integrator

Romberg's method computes an integral by generating a sequence of estimations of the integral values and then extrapolation. The estimations are extrapolated to where the discretization is 0.

For example, Simpson's rule is a special case of Romberg's method, with the number of points for extrapolation is equal to 2.

This implementation does not assume any particular integrator, other than that the integrator is an IterativeIntegrator. The user may combine Romberg's method with his favorite iterative integrator.

See Also:
Wikipedia: Romberg's method

Constructor Summary
Romberg(IterativeIntegrator integrator)
          Construct an integrator by extending an IterativeIntegrator using Romberg's method.
 
Method Summary
 double integrate(UnivariateRealFunction f, double a, double b)
          Integrate function f from a to b.
 double precision()
          Get the convergence threshold.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Romberg

public Romberg(IterativeIntegrator integrator)
Construct an integrator by extending an IterativeIntegrator using Romberg's method.

Note that the iterative integrator must do at least 2 steps in order to carry out any extrapolation.

Parameters:
integrator - an iterative integrator
Method Detail

integrate

public double integrate(UnivariateRealFunction f,
                        double a,
                        double b)
Description copied from interface: Integrator
Integrate function f from a to b.
 / b
 |   f(x) dx
 / a
 

Specified by:
integrate in interface Integrator
Parameters:
f - a univariate function
a - lower limit
b - upper limit
Returns:
Σ(f(x))

precision

public double precision()
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:
precision in interface Integrator
Returns:
the precision

SuanShu, a Java numerical and statistical library

Copyright © 2011 Numerical Method Inc. Ltd. All Rights Reserved.