public class LegendreGaussIntegrator extends UnivariateRealIntegratorImpl
Legendre-Gauss integrators are efficient integrators that can accurately integrate functions with few functions evaluations. A Legendre-Gauss integrator using an n-points quadrature formula can integrate exactly 2n-1 degree polynomials.
These integrators evaluate the function on n carefully chosen abscissas in each step interval (mapped to the canonical [-1 1] interval). The evaluation abscissas are not evenly spaced and none of them are at the interval endpoints. This implies the function integrated can be undefined at integration interval endpoints.
The evaluation abscissas xi are the roots of the degree n Legendre polynomial. The weights ai of the quadrature formula integrals from -1 to +1 ∫ Li2 where Li (x) = ∏ (x-xk)/(xi-xk) for k != i.
Modifier and Type | Field and Description |
---|---|
private double[] |
abscissas
Abscissas for the current method.
|
private static double[] |
ABSCISSAS_2
Abscissas for the 2 points method.
|
private static double[] |
ABSCISSAS_3
Abscissas for the 3 points method.
|
private static double[] |
ABSCISSAS_4
Abscissas for the 4 points method.
|
private static double[] |
ABSCISSAS_5
Abscissas for the 5 points method.
|
private double[] |
weights
Weights for the current method.
|
private static double[] |
WEIGHTS_2
Weights for the 2 points method.
|
private static double[] |
WEIGHTS_3
Weights for the 3 points method.
|
private static double[] |
WEIGHTS_4
Weights for the 4 points method.
|
private static double[] |
WEIGHTS_5
Weights for the 5 points method.
|
defaultMinimalIterationCount, f, minimalIterationCount, result, resultComputed
absoluteAccuracy, defaultAbsoluteAccuracy, defaultMaximalIterationCount, defaultRelativeAccuracy, iterationCount, maximalIterationCount, relativeAccuracy
Constructor and Description |
---|
LegendreGaussIntegrator(int n,
int defaultMaximalIterationCount)
Build a Legendre-Gauss integrator.
|
Modifier and Type | Method and Description |
---|---|
double |
integrate(double min,
double max)
Deprecated.
|
double |
integrate(UnivariateRealFunction f,
double min,
double max)
Integrate the function in the given interval.
|
private double |
stage(UnivariateRealFunction f,
double min,
double max,
int n)
Compute the n-th stage integral.
|
clearResult, getMinimalIterationCount, getResult, resetMinimalIterationCount, setMinimalIterationCount, setResult, verifyInterval, verifyIterationCount
getAbsoluteAccuracy, getIterationCount, getMaximalIterationCount, getRelativeAccuracy, incrementIterationsCounter, resetAbsoluteAccuracy, resetIterationsCounter, resetMaximalIterationCount, resetRelativeAccuracy, setAbsoluteAccuracy, setMaximalIterationCount, setRelativeAccuracy
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getAbsoluteAccuracy, getIterationCount, getMaximalIterationCount, getRelativeAccuracy, resetAbsoluteAccuracy, resetMaximalIterationCount, resetRelativeAccuracy, setAbsoluteAccuracy, setMaximalIterationCount, setRelativeAccuracy
private static final double[] ABSCISSAS_2
private static final double[] WEIGHTS_2
private static final double[] ABSCISSAS_3
private static final double[] WEIGHTS_3
private static final double[] ABSCISSAS_4
private static final double[] WEIGHTS_4
private static final double[] ABSCISSAS_5
private static final double[] WEIGHTS_5
private final double[] abscissas
private final double[] weights
public LegendreGaussIntegrator(int n, int defaultMaximalIterationCount) throws IllegalArgumentException
n
- number of points desired (must be between 2 and 5 inclusive)defaultMaximalIterationCount
- maximum number of iterationsIllegalArgumentException
- if the number of points is not
in the supported range@Deprecated public double integrate(double min, double max) throws ConvergenceException, FunctionEvaluationException, IllegalArgumentException
min
- the lower bound for the intervalmax
- the upper bound for the intervalConvergenceException
- if the maximum iteration count is exceeded
or the integrator detects convergence problems otherwiseFunctionEvaluationException
- if an error occurs evaluating the
functionIllegalArgumentException
- if min > max or the endpoints do not
satisfy the requirements specified by the integratorpublic double integrate(UnivariateRealFunction f, double min, double max) throws ConvergenceException, FunctionEvaluationException, IllegalArgumentException
f
- the integrand functionmin
- the lower bound for the intervalmax
- the upper bound for the intervalConvergenceException
- if the maximum iteration count is exceeded
or the integrator detects convergence problems otherwiseFunctionEvaluationException
- if an error occurs evaluating the functionIllegalArgumentException
- if min > max or the endpoints do not
satisfy the requirements specified by the integratorprivate double stage(UnivariateRealFunction f, double min, double max, int n) throws FunctionEvaluationException
f
- the integrand functionmin
- the lower bound for the intervalmax
- the upper bound for the intervaln
- number of stepsFunctionEvaluationException
- if an error occurs evaluating the
functionCopyright (c) 2003-2014 Apache Software Foundation