Class SimpsonIntegrator
- java.lang.Object
-
- org.apache.commons.math4.legacy.analysis.integration.BaseAbstractUnivariateIntegrator
-
- org.apache.commons.math4.legacy.analysis.integration.SimpsonIntegrator
-
- All Implemented Interfaces:
UnivariateIntegrator
public class SimpsonIntegrator extends BaseAbstractUnivariateIntegrator
Implements Simpson's Rule for integration of real univariate functions. See Introduction to Numerical Analysis, ISBN 038795452X, chapter 3.This implementation employs the basic trapezoid rule to calculate Simpson's rule.
Caveat: At each iteration, the algorithm refines the estimation by evaluating the function twice as many times as in the previous iteration; When specifying a
maximum number of function evaluations
, the caller must ensure that it is compatible with therequested minimal number of iterations
.- Since:
- 1.2
-
-
Field Summary
-
Fields inherited from class org.apache.commons.math4.legacy.analysis.integration.BaseAbstractUnivariateIntegrator
DEFAULT_ABSOLUTE_ACCURACY, DEFAULT_MAX_ITERATIONS_COUNT, DEFAULT_MIN_ITERATIONS_COUNT, DEFAULT_RELATIVE_ACCURACY, iterations
-
-
Constructor Summary
Constructors Constructor Description SimpsonIntegrator()
Construct an integrator with default settings.SimpsonIntegrator(double relativeAccuracy, double absoluteAccuracy, int minimalIterationCount, int maximalIterationCount)
Build a Simpson integrator with given accuracies and iterations counts.SimpsonIntegrator(int minimalIterationCount, int maximalIterationCount)
Build a Simpson integrator with given iteration counts.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected double
doIntegrate()
Method for implementing actual integration algorithms in derived classes.-
Methods inherited from class org.apache.commons.math4.legacy.analysis.integration.BaseAbstractUnivariateIntegrator
computeObjectiveValue, getAbsoluteAccuracy, getEvaluations, getIterations, getMax, getMaximalIterationCount, getMin, getMinimalIterationCount, getRelativeAccuracy, integrate, setup
-
-
-
-
Constructor Detail
-
SimpsonIntegrator
public SimpsonIntegrator(double relativeAccuracy, double absoluteAccuracy, int minimalIterationCount, int maximalIterationCount)
Build a Simpson integrator with given accuracies and iterations counts.- Parameters:
relativeAccuracy
- relative accuracy of the resultabsoluteAccuracy
- absolute accuracy of the resultminimalIterationCount
- Minimum number of iterations.maximalIterationCount
- Maximum number of iterations. It must be less than or equal to 30.- Throws:
NotStrictlyPositiveException
- ifminimalIterationCount <= 0
.NumberIsTooSmallException
- ifmaximalIterationCount < minimalIterationCount
. is lesser than or equal to the minimal number of iterationsNumberIsTooLargeException
- ifmaximalIterationCount > 30
.
-
SimpsonIntegrator
public SimpsonIntegrator(int minimalIterationCount, int maximalIterationCount)
Build a Simpson integrator with given iteration counts.- Parameters:
minimalIterationCount
- Minimum number of iterations.maximalIterationCount
- Maximum number of iterations. It must be less than or equal to 30.- Throws:
NotStrictlyPositiveException
- ifminimalIterationCount <= 0
.NumberIsTooSmallException
- ifmaximalIterationCount < minimalIterationCount
. is lesser than or equal to the minimal number of iterationsNumberIsTooLargeException
- ifmaximalIterationCount > 30
.
-
SimpsonIntegrator
public SimpsonIntegrator()
Construct an integrator with default settings.
-
-
Method Detail
-
doIntegrate
protected double doIntegrate()
Method for implementing actual integration algorithms in derived classes.- Specified by:
doIntegrate
in classBaseAbstractUnivariateIntegrator
- Returns:
- the root.
-
-