Class Romberg
- java.lang.Object
-
- dev.nm.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.- See Also:
- Wikipedia: Romberg's method
-
-
Constructor Summary
Constructors Constructor Description Romberg(IterativeIntegrator integrator)
Extend an integrator using Romberg's method.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method 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 \]
-
-
-
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 interfaceIntegrator
- Parameters:
f
- a univariate functiona
- the lower limitb
- 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 anIterativeIntegrator
, the integral is considered converged if the relative error of two successive sums is less than the threshold.- Specified by:
getPrecision
in interfaceIntegrator
- Returns:
- the precision
-
-