# SuanShu, a Java numerical and statistical library

com.numericalmethod.suanshu.analysis.integration.univariate.riemann.newtoncotes

## Class Romberg

• java.lang.Object
• com.numericalmethod.suanshu.analysis.integration.univariate.riemann.newtoncotes.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.
Wikipedia: Romberg's method
• ### Constructor Summary

Constructors
Constructor and Description
Romberg(IterativeIntegrator integrator)
Extend an integrator using Romberg's method.
• ### Method Summary

All Methods
Modifier and Type Method and Description
double getPrecision()
Get the convergence threshold.
double integrate(UnivariateRealFunction f, double a, double b)
Integrate function f from a to b, $\int_a^b\! f(x)\, dx$
• ### 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)
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