|
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.EulerMaclaurin
public class EulerMaclaurin
This class implements a specialized group of the Newton-Cotes integration methods using the Euler-Maclaurin formula.
This class forms the basis for a few standard numerical quadrature methods with equally spaced interpolation points. The extraploation method uses Neville's algorithm.
By customizing this class, one can construct various standard numerical quadrature algoritms, such as
rate = 2.
rate = 2 and specifying OPEN formula.
| Nested Class Summary | |
|---|---|
static class |
EulerMaclaurin.NewtonCotesType
Newton-Cotes methods can be classified into two categories: OPEN and CLOSED. |
| Field Summary | |
|---|---|
int |
maxIterations
the maximum number of iterations for this iterative procedure For those integrals that do not converge, we need to put a bound on the number of iterations. |
double |
precision
the convergence threshold The iterative procedure converges when the relative difference between two successive sums is less than precision. |
int |
rate
the rate of sub-dividing an interval Starting with the whole interval (b-a), we divide each sub-interval into rate many intervals. |
EulerMaclaurin.NewtonCotesType |
type
indicate whether the two end points are included for computation |
| Constructor Summary | |
|---|---|
EulerMaclaurin(int rate,
EulerMaclaurin.NewtonCotesType type,
double precision,
int maxIterations)
Construct an instance of the Euler-Maclaurin formula. |
|
| 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 iter,
UnivariateRealFunction f,
double a,
double b,
double sum0)
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 rate
Starting with the whole interval (b-a), we divide each sub-interval into rate many intervals.
For example, when rate = 2, we double the number of intervals,
hence abscissas, in each iteration.
Note: the number of abscissas grows exponentially.
public final EulerMaclaurin.NewtonCotesType type
public final double precision
The iterative procedure converges when the relative difference between two successive sums is less than precision.
public final int maxIterations
For those integrals that do not converge, we need to put a bound on the number of iterations.
Note that the number of abscissas grows exponentially with each iteration, i.e., rateiterations.
Thus, maxIterations should not be too big.
Be careful when choosing maxIterations, as it may severely affect the performance.
| Constructor Detail |
|---|
public EulerMaclaurin(int rate,
EulerMaclaurin.NewtonCotesType type,
double precision,
int maxIterations)
rate - the rate of further sub-dividing the integral interval.
For example, when rate = 2, we will divide [xi, xi+1] into two equal length intervals.
This is equivalent to the Trapezoidal rule.
type - specifying whether to use CLOSED or OPEN formulaprecision - the precision required, e.g., 1e-8maxIterations - 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 iter,
UnivariateRealFunction f,
double a,
double b,
double sum0)
IterativeIntegrator
next in interface IterativeIntegratoriter - the index/count for the iterations; it counts from 1f - the integranda - the lower limitb - the upper limitsum0 - 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 | |||||||