public class NewtonCotes extends Object implements IterativeIntegrator
rate = 2), the Midpoint method (rate = 2 and specifying OPEN formula).
This implementation is based on the Euler-Maclaurin formula.| Modifier and Type | Class and Description |
|---|---|
static class |
NewtonCotes.Type
There are two types of the Newton-Cotes method: OPEN and CLOSED.
|
| Constructor and Description |
|---|
NewtonCotes(int rate,
NewtonCotes.Type type,
double precision,
int maxIterations)
Construct an instance of the Newton-Cotes quadrature.
|
| Modifier and Type | Method and Description |
|---|---|
int |
getMaxIterations()
Get the maximum number of iterations for this iterative procedure.
|
double |
getPrecision()
Get the convergence threshold.
|
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_a^b\! f(x)\, dx
\]
|
double |
next(int iter,
UnivariateRealFunction f,
double a,
double b,
double sum0)
Compute a refined sum for the integral.
|
public NewtonCotes(int rate,
NewtonCotes.Type type,
double precision,
int maxIterations)
rate - the rate of further sub-dividing an integral interval. For example, when rate = 2, we 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 iterationspublic double integrate(UnivariateRealFunction f, double a, double b)
Integratorintegrate in interface Integratorf - a univariate functiona - the lower limitb - the upper limitpublic double next(int iter,
UnivariateRealFunction f,
double a,
double b,
double sum0)
IterativeIntegratornext in interface IterativeIntegratoriter - the index/count for the current iteration, counting from 1f - the integranda - the lower limitb - the upper limitsum0 - the last sumpublic double h()
IterativeIntegratorh in interface IterativeIntegratorpublic int getMaxIterations()
IterativeIntegratorgetMaxIterations in interface IterativeIntegratorpublic double getPrecision()
IntegratorIterativeIntegrator,
the integral is considered converged if the relative error of two successive sums is less than the threshold.getPrecision in interface IntegratorCopyright © 2010-2020 NM FinTech Ltd.. All Rights Reserved.