## org.apache.commons.math.analysis.integration
Class TrapezoidIntegrator

    java.lang.Object
      org.apache.commons.math.ConvergingAlgorithmImpl
          org.apache.commons.math.analysis.integration.UnivariateRealIntegratorImpl
              org.apache.commons.math.analysis.integration.TrapezoidIntegrator

All Implemented Interfaces:
  UnivariateRealIntegrator, ConvergingAlgorithm

    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: 825919 $ $Date: 2009-10-16 10:51:55 -0400 (Fri, 16 Oct 2009) $

Field Summary
`private double` `s` Intermediate result.

Fields inherited from class org.apache.commons.math.analysis.integration.UnivariateRealIntegratorImpl
`defaultMinimalIterationCount, f, minimalIterationCount, result, resultComputed`

Fields inherited from class org.apache.commons.math.ConvergingAlgorithmImpl
`absoluteAccuracy, defaultAbsoluteAccuracy, defaultMaximalIterationCount, defaultRelativeAccuracy, iterationCount, maximalIterationCount, relativeAccuracy`

Constructor Summary
`TrapezoidIntegrator()` Construct an integrator.
`TrapezoidIntegrator(UnivariateRealFunction f)` Deprecated. as of 2.0 the integrand function is passed as an argument to the `integrate(UnivariateRealFunction, double, double)`method.

Method Summary
`double` `integrate(double min, double max)` Deprecated.
`double` `integrate(UnivariateRealFunction f, double min, double max)` Integrate the function in the given interval.
`(package private) double` `stage(UnivariateRealFunction f, double min, double max, int n)` Compute the n-th stage integral of trapezoid rule.
`protected void` `verifyIterationCount()` Verifies that the upper and lower limits of iterations are valid.

Methods inherited from class org.apache.commons.math.analysis.integration.UnivariateRealIntegratorImpl
`clearResult, getMinimalIterationCount, getResult, resetMinimalIterationCount, setMinimalIterationCount, setResult, verifyInterval`

Methods inherited from class org.apache.commons.math.ConvergingAlgorithmImpl
`getAbsoluteAccuracy, getIterationCount, getMaximalIterationCount, getRelativeAccuracy, resetAbsoluteAccuracy, resetMaximalIterationCount, resetRelativeAccuracy, setAbsoluteAccuracy, setMaximalIterationCount, setRelativeAccuracy`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Methods inherited from interface org.apache.commons.math.ConvergingAlgorithm
`getAbsoluteAccuracy, getIterationCount, getMaximalIterationCount, getRelativeAccuracy, resetAbsoluteAccuracy, resetMaximalIterationCount, resetRelativeAccuracy, setAbsoluteAccuracy, setMaximalIterationCount, setRelativeAccuracy`

Field Detail

### s

    private double s

  Intermediate result.

Constructor Detail

### TrapezoidIntegrator

    @Deprecated
    public TrapezoidIntegrator(UnivariateRealFunction f)

  Deprecated. as of 2.0 the integrand function is passed as an argument to the `integrate(UnivariateRealFunction, double, double)`method.

  Construct an integrator for the given function.

  Parameters:
    `f` - function to integrate

### TrapezoidIntegrator

    public TrapezoidIntegrator()

  Construct an integrator.

Method Detail

### stage

    double stage(UnivariateRealFunction f,
                 double min,
                 double max,
                 int n)
           throws FunctionEvaluationException

  Compute the n-th stage integral of trapezoid rule. This function should only be called by API `integrate()` in the package. To save time it does not verify arguments - caller does.

  The interval is divided equally into 2^n sections rather than an arbitrary m sections because this configuration can best utilize the alrealy computed values.

  Parameters:
    `f` - the integrand function
    `min` - the lower bound for the interval
    `max` - the upper bound for the interval
    `n` - the stage of 1/2 refinement, n = 0 is no refinement
  Returns:
    the value of n-th stage integral
  Throws:
    `FunctionEvaluationException` - if an error occurs evaluating the function

### integrate

    @Deprecated
    public double integrate(double min,
                                       double max)
                     throws MaxIterationsExceededException,
                            FunctionEvaluationException,
                            java.lang.IllegalArgumentException

  Deprecated.

  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:
    `FunctionEvaluationException` - if an error occurs evaluating the function
    `java.lang.IllegalArgumentException` - if min > max or the endpoints do not satisfy the requirements specified by the integrator
    `MaxIterationsExceededException`

### integrate

    public double integrate(UnivariateRealFunction f,
                            double min,
                            double max)
                     throws MaxIterationsExceededException,
                            FunctionEvaluationException,
                            java.lang.IllegalArgumentException

  Integrate the function in the given interval.

  Parameters:
    `f` - the integrand function
    `min` - the lower bound for the interval
    `max` - the upper bound for the interval
  Returns:
    the value of integral
  Throws:
    `FunctionEvaluationException` - if an error occurs evaluating the function
    `java.lang.IllegalArgumentException` - if min > max or the endpoints do not satisfy the requirements specified by the integrator
    `MaxIterationsExceededException`

### verifyIterationCount

    protected void verifyIterationCount()
                                 throws java.lang.IllegalArgumentException

  Verifies that the upper and lower limits of iterations are valid.

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

Copyright (c) 2003-2010 Apache Software Foundation