Top Description Fields Constructors Methods
org.apache.commons.math3.analysis.integration

public Class LegendreGaussIntegrator

extends BaseAbstractUnivariateIntegrator
Class Inheritance
Annotations
@Deprecated
Imports
org.apache.commons.math3.exception.MathIllegalArgumentException, .MaxCountExceededException, .NotStrictlyPositiveException, .NumberIsTooSmallException, .TooManyEvaluationsException, org.apache.commons.math3.exception.util.LocalizedFormats, org.apache.commons.math3.util.FastMath

Deprecated

As of 3.1 (to be removed in 4.0). Please use IterativeLegendreGaussIntegrator instead.

Implements the Legendre-Gauss quadrature formula.

Legendre-Gauss integrators are efficient integrators that can accurately integrate functions with few function evaluations. A Legendre-Gauss integrator using an n-points quadrature formula can integrate 2n-1 degree polynomials exactly.

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.

Since
1.2

Field Summary

Modifier and TypeField and Description
private final double[]
abscissas

Abscissas for the current method.

private static final double[]
ABSCISSAS_2

Abscissas for the 2 points method.

private static final double[]
ABSCISSAS_3

Abscissas for the 3 points method.

private static final double[]
ABSCISSAS_4

Abscissas for the 4 points method.

private static final double[]
ABSCISSAS_5

Abscissas for the 5 points method.

private final double[]
weights

Weights for the current method.

private static final double[]
WEIGHTS_2

Weights for the 2 points method.

private static final double[]
WEIGHTS_3

Weights for the 3 points method.

private static final double[]
WEIGHTS_4

Weights for the 4 points method.

private static final double[]
WEIGHTS_5

Weights for the 5 points method.

Inherited from org.apache.commons.math3.analysis.integration.BaseAbstractUnivariateIntegrator:
DEFAULT_ABSOLUTE_ACCURACYDEFAULT_MAX_ITERATIONS_COUNTDEFAULT_MIN_ITERATIONS_COUNTDEFAULT_RELATIVE_ACCURACYiterations

Constructor Summary

AccessConstructor and Description
public
LegendreGaussIntegrator(final int
number of points desired (must be between 2 and 5 inclusive)
n
,
final double
relative accuracy of the result
relativeAccuracy
,
final double
absolute accuracy of the result
absoluteAccuracy
,
final int
minimum number of iterations
minimalIterationCount
,
final int
maximum number of iterations
maximalIterationCount
)

Build a Legendre-Gauss integrator with given accuracies and iterations counts.

public
LegendreGaussIntegrator(final int
number of points desired (must be between 2 and 5 inclusive)
n
,
final double
relative accuracy of the result
relativeAccuracy
,
final double
absolute accuracy of the result
absoluteAccuracy
)

Build a Legendre-Gauss integrator with given accuracies.

public
LegendreGaussIntegrator(final int
number of points desired (must be between 2 and 5 inclusive)
n
,
final int
minimum number of iterations
minimalIterationCount
,
final int
maximum number of iterations
maximalIterationCount
)

Build a Legendre-Gauss integrator with given iteration counts.

Method Summary

Modifier and TypeMethod and Description
protected double
doIntegrate()

Implements abstract org.apache.commons.math3.analysis.integration.BaseAbstractUnivariateIntegrator.doIntegrate.

Method for implementing actual integration algorithms in derived classes.

private double

Returns:

the value of n-th stage integral
stage
(final int
number of steps
n
)

Compute the n-th stage integral.

Inherited from org.apache.commons.math3.analysis.integration.BaseAbstractUnivariateIntegrator:
computeObjectiveValuegetAbsoluteAccuracygetEvaluationsgetIterationsgetMaxgetMaximalIterationCountgetMingetMinimalIterationCountgetRelativeAccuracyincrementCountintegratesetup

Field Detail

abscissasback to summary
private final double[] abscissas

Abscissas for the current method.

ABSCISSAS_2back to summary
private static final double[] ABSCISSAS_2

Abscissas for the 2 points method.

ABSCISSAS_3back to summary
private static final double[] ABSCISSAS_3

Abscissas for the 3 points method.

ABSCISSAS_4back to summary
private static final double[] ABSCISSAS_4

Abscissas for the 4 points method.

ABSCISSAS_5back to summary
private static final double[] ABSCISSAS_5

Abscissas for the 5 points method.

weightsback to summary
private final double[] weights

Weights for the current method.

WEIGHTS_2back to summary
private static final double[] WEIGHTS_2

Weights for the 2 points method.

WEIGHTS_3back to summary
private static final double[] WEIGHTS_3

Weights for the 3 points method.

WEIGHTS_4back to summary
private static final double[] WEIGHTS_4

Weights for the 4 points method.

WEIGHTS_5back to summary
private static final double[] WEIGHTS_5

Weights for the 5 points method.

Constructor Detail

LegendreGaussIntegratorback to summary
public LegendreGaussIntegrator(final int n, final double relativeAccuracy, final double absoluteAccuracy, final int minimalIterationCount, final int maximalIterationCount) throws MathIllegalArgumentException, NotStrictlyPositiveException, NumberIsTooSmallException

Build a Legendre-Gauss integrator with given accuracies and iterations counts.

Parameters
n:int

number of points desired (must be between 2 and 5 inclusive)

relativeAccuracy:double

relative accuracy of the result

absoluteAccuracy:double

absolute accuracy of the result

minimalIterationCount:int

minimum number of iterations

maximalIterationCount:int

maximum number of iterations

Exceptions
MathIllegalArgumentException:
if number of points is out of [2; 5]
NotStrictlyPositiveException:
if minimal number of iterations is not strictly positive
NumberIsTooSmallException:
if maximal number of iterations is lesser than or equal to the minimal number of iterations
LegendreGaussIntegratorback to summary
public LegendreGaussIntegrator(final int n, final double relativeAccuracy, final double absoluteAccuracy) throws MathIllegalArgumentException

Build a Legendre-Gauss integrator with given accuracies.

Parameters
n:int

number of points desired (must be between 2 and 5 inclusive)

relativeAccuracy:double

relative accuracy of the result

absoluteAccuracy:double

absolute accuracy of the result

Exceptions
MathIllegalArgumentException:
if number of points is out of [2; 5]
LegendreGaussIntegratorback to summary
public LegendreGaussIntegrator(final int n, final int minimalIterationCount, final int maximalIterationCount) throws MathIllegalArgumentException

Build a Legendre-Gauss integrator with given iteration counts.

Parameters
n:int

number of points desired (must be between 2 and 5 inclusive)

minimalIterationCount:int

minimum number of iterations

maximalIterationCount:int

maximum number of iterations

Exceptions
MathIllegalArgumentException:
if number of points is out of [2; 5]
NotStrictlyPositiveException:
if minimal number of iterations is not strictly positive
NumberIsTooSmallException:
if maximal number of iterations is lesser than or equal to the minimal number of iterations

Method Detail

doIntegrateback to summary
protected double doIntegrate() throws MathIllegalArgumentException, TooManyEvaluationsException, MaxCountExceededException

Implements abstract org.apache.commons.math3.analysis.integration.BaseAbstractUnivariateIntegrator.doIntegrate.

Doc from org.apache.commons.math3.analysis.integration.BaseAbstractUnivariateIntegrator.doIntegrate.

Method for implementing actual integration algorithms in derived classes.

Returns:double

the root.

Annotations
@Override
Exceptions
TooManyEvaluationsException:
if the maximal number of evaluations is exceeded.
MaxCountExceededException:
if the maximum iteration count is exceeded or the integrator detects convergence problems otherwise
stageback to summary
private double stage(final int n) throws TooManyEvaluationsException

Compute the n-th stage integral.

Parameters
n:int

number of steps

Returns:double

the value of n-th stage integral

Exceptions
TooManyEvaluationsException:
if the maximum number of evaluations is exceeded.