|
SuanShu, a Java numerical and statistical library | |||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Objectcom.numericalmethod.suanshu.analysis.integration.univariate.riemann.Simpson
public class Simpson
Simpson's rule is often an accurate integration rule.
Simpson's is expected to improve on the trapezoidal rule for functions which are twice continuously differentiable. However for rougher functions the trapezoidal rule is likely to be more preferable.
This class implements Simpson's rule as a weighted average of two successive steps of the Trapezoidal rule.
| Field Summary | |
|---|---|
int |
maxIterations
the maximum number of iterations |
double |
precision
the convergence threshold |
| Constructor Summary | |
|---|---|
Simpson(double precision,
int maxIterations)
Construct an integrator that uses Simpson's rule. |
|
| Method Summary | |
|---|---|
double |
h()
Get the discretization size for the current iteration. |
double |
integrate(UnivariateRealFunction f,
double a,
double b)
Integrate function f from a to b. |
int |
maxIterations()
Get the maximum number of iterations for this iterative procedure. |
double |
next(int iteration,
UnivariateRealFunction f,
double a,
double b,
double sum)
Compute a refined sum for the integral. |
double |
precision()
Get the convergence threshold. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public final int maxIterations
public final double precision
| Constructor Detail |
|---|
public Simpson(double precision,
int maxIterations)
precision - the convergence thresholdmaxIterations - the maximum number of iterations| Method Detail |
|---|
public double integrate(UnivariateRealFunction f,
double a,
double b)
Integratorf from a to b.
/ b
| f(x) dx
/ a
integrate in interface Integratorf - a univariate functiona - lower limitb - upper limit
public double next(int iteration,
UnivariateRealFunction f,
double a,
double b,
double sum)
IterativeIntegrator
next in interface IterativeIntegratoriteration - the index/count for the iterations; it counts from 1f - the integranda - the lower limitb - the upper limitsum - the last sum
public double h()
IterativeIntegrator
h in interface IterativeIntegratorpublic int maxIterations()
IterativeIntegrator
maxIterations in interface IterativeIntegratorpublic double precision()
Integrator
For example, for an IterativeIntegrator,
the integral is considered converged
if the relative error of two successive sums is less than the threshold.
precision in interface Integrator
|
SuanShu, a Java numerical and statistical library | |||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||