|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sf.doodleproject.numerics4j.IterativeMethod net.sf.doodleproject.numerics4j.integration.RombergIntegrator
public class RombergIntegrator
An implementation of Romberg Integration.
For example, to evaluate definite integrals for sine, first a
Function
is defined:
Function sine = new Function() { public double evaluate(double x) { return Math.sin(x); }} };
Then, a Romberg integrator is created with the above function:
RombergIntegrator integrator = new RombergIntegrator(sine);
Lastly, evaluating definite integrals is accomplished using the
integrate(double, double)
method:
// 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);
References:
Nested Class Summary |
---|
Nested classes/interfaces inherited from class net.sf.doodleproject.numerics4j.IterativeMethod |
---|
IterativeMethod.IterativeState |
Constructor Summary | |
---|---|
RombergIntegrator(Function f)
Create an integrator for the given function. |
|
RombergIntegrator(Function f,
int iterations,
double error)
Create an integrator for the given function. |
Method Summary | |
---|---|
Function |
getFunction()
Access the target function. |
double |
integrate(double a,
double b)
Evaluate the definite integral from a to b. |
void |
setFunction(Function f)
Modify the target function. |
Methods inherited from class net.sf.doodleproject.numerics4j.IterativeMethod |
---|
getMaximumIterations, getMaximumRelativeError, iterate, setMaximumIterations, setMaximumRelativeError |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public RombergIntegrator(Function f)
f
- the target function.public RombergIntegrator(Function f, int iterations, double error)
f
- the target function.iterations
- maximum number of iterations.error
- maximum relative error.Method Detail |
---|
public Function getFunction()
public double integrate(double a, double b) throws NumericException
a
- the lower limit of integration.b
- the upper limit of integration.
NumericException
- if the integral can not be evaluated.public void setFunction(Function f)
f
- the new target function.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |