The net.sf.doodleproject.numerics4j.integration.RombergIntegrator class provides an implementation of Romberg Integration.
Evaluating definite integrals using Romberg integration involves
creating a RombergIntegrator object for a particular
net.sf.doodleproject.numerics4j.function.Function
object. Once, the integrator is created, definite integrals can be
evaluated by calling the integrate method providing the
limits of integration. Here is an example of evaluating integrals for
sine:
Function sine = new Function() {
public double evaluate(double x) {
return Math.sin(x);
}
};
RombergIntegrator integrator = new RombergIntegrator(sine);
// integrate sine from 0 to Pi.
double two = integrator.integrate(0.0, Math.PI);
// integrate sine from Pi/2 to 2 Pi.
double one = integrator.integrate(Math.PI / 2.0, Math.PI);