org.apache.commons.math.analysis
Class TrapezoidIntegrator

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

public class TrapezoidIntegrator
extends UnivariateRealIntegratorImpl

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

The function should be integrable.

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

Field Summary
 
Fields inherited from class org.apache.commons.math.analysis.UnivariateRealIntegratorImpl
defaultMaximalIterationCount, defaultMinimalIterationCount, defaultRelativeAccuracy, f, iterationCount, maximalIterationCount, minimalIterationCount, relativeAccuracy, result, resultComputed
 
Constructor Summary
TrapezoidIntegrator(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
 

Constructor Detail

TrapezoidIntegrator

public TrapezoidIntegrator(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


Copyright © 2003-2008 The Apache Software Foundation. All Rights Reserved.