org.apache.commons.math.analysis
Class SimpsonIntegrator

java.lang.Object
  extended by org.apache.commons.math.analysis.UnivariateRealIntegratorImpl
      extended by org.apache.commons.math.analysis.SimpsonIntegrator
All Implemented Interfaces:
java.io.Serializable, UnivariateRealIntegrator

public class SimpsonIntegrator
extends UnivariateRealIntegratorImpl

Implements the Simpson's Rule for integration of real univariate functions. For reference, see Introduction to Numerical Analysis, ISBN 038795452X, chapter 3.

This implementation employs basic trapezoid rule as building blocks to calculate the Simpson's rule of alternating 2/3 and 4/3.

Since:
1.2
Version:
$Revision: 620312 $ $Date: 2008-02-10 12:28:59 -0700 (Sun, 10 Feb 2008) $
See Also:
Serialized Form

Field Summary
private static long serialVersionUID
          serializable version identifier
 
Fields inherited from class org.apache.commons.math.analysis.UnivariateRealIntegratorImpl
defaultMaximalIterationCount, defaultMinimalIterationCount, defaultRelativeAccuracy, f, iterationCount, maximalIterationCount, minimalIterationCount, relativeAccuracy, result, resultComputed
 
Constructor Summary
SimpsonIntegrator(UnivariateRealFunction f)
          Construct an integrator for the given function.
 
Method Summary
 double integrate(double min, double max)
          Integrate the function in the given interval.
protected  void verifyIterationCount()
          Verifies that the iteration limits are valid and within the range.
 
Methods inherited from class org.apache.commons.math.analysis.UnivariateRealIntegratorImpl
clearResult, getIterationCount, getMaximalIterationCount, getMinimalIterationCount, getRelativeAccuracy, getResult, isSequence, resetMaximalIterationCount, resetMinimalIterationCount, resetRelativeAccuracy, setMaximalIterationCount, setMinimalIterationCount, setRelativeAccuracy, setResult, verifyInterval
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID
serializable version identifier

See Also:
Constant Field Values
Constructor Detail

SimpsonIntegrator

public SimpsonIntegrator(UnivariateRealFunction f)
Construct an integrator for the given function.

Parameters:
f - function to integrate
Method Detail

integrate

public double integrate(double min,
                        double max)
                 throws MaxIterationsExceededException,
                        FunctionEvaluationException,
                        java.lang.IllegalArgumentException
Integrate the function in the given interval.

Parameters:
min - the lower bound for the interval
max - the upper bound for the interval
Returns:
the value of integral
Throws:
MaxIterationsExceededException - if the maximum iteration count is exceeded or the integrator detects convergence problems otherwise
FunctionEvaluationException - if an error occurs evaluating the function
java.lang.IllegalArgumentException - if any parameters are invalid

verifyIterationCount

protected void verifyIterationCount()
                             throws java.lang.IllegalArgumentException
Verifies that the iteration limits are valid and within the range.

Overrides:
verifyIterationCount in class UnivariateRealIntegratorImpl
Throws:
java.lang.IllegalArgumentException - if not