AdaptiveIntegrator
jhplot.math.num.integration

Class AdaptiveIntegrator



  • public class AdaptiveIntegratorextends IterativeMethod

    An implementation of adaptive quadrature.

    For example, to evaluate definite integrals for sine, first a Function is defined:

     Function sine = new Function() {    public double evaluate(double x) {        return Math.sin(x);    }} }; 

    Then, an adaptive integrator is created with the above function:

     AdaptiveIntegrator integrator = new AdaptiveIntegrator(sine); 

    Lastly, evaluating definite integrals is accomplished using the integrate(double, double) method:

     // integrate sine from 0 to Pi. double two = integrator.integrate(0.0, Math.PI);  // integrate sine from Pi/2 to 2 Pi. double one = integrator.integrate(Math.PI / 2.0, Math.PI); 

    References:

    1. "Adaptive Quadrature." http://www.cse.uiuc.edu/eot/modules/integration/adaptivq/

    • Constructor Detail

      • AdaptiveIntegrator

        public AdaptiveIntegrator(Function f)
        Create an integrator for the given function.
        Parameters:
        f - the target function.
      • AdaptiveIntegrator

        public AdaptiveIntegrator(Function f,                  int iterations,                  double error)
        Create an integrator for the given function.
        Parameters:
        f - the target function.
        iterations - maximum number of iterations.
        error - maximum relative error.
    • Method Detail

      • getFunction

        public Function getFunction()
        Access the target function.
        Returns:
        the target function.
      • integrate

        public double integrate(double a,               double b)                 throws NumericException
        Evaluate the definite integral from a to b.
        Parameters:
        a - the lower limit of integration.
        b - the upper limit of integration.
        Returns:
        the definite integral from a to b.
        Throws:
        NumericException - if the integral can not be evaluated.
      • setFunction

        public void setFunction(Function f)
        Modify the target function.
        Parameters:
        f - the new target function.

SCaVis 2.2 © jWork.ORG