org.jscience.mathematics.analysis.quadrature
Class GaussLegendreNDIntegrator

java.lang.Object
  extended by org.jscience.mathematics.analysis.quadrature.GaussLegendreNDIntegrator
All Implemented Interfaces:
PrimitiveMappingNDIntegrator

public class GaussLegendreNDIntegrator
extends java.lang.Object
implements PrimitiveMappingNDIntegrator

This class implements a Gauss-Legendre integrator.

Gauss-Legendre integrators are efficient integrators that can accurately integrate functions with few functions evaluations. A Gauss-Legendre integrator using an n-points quadrature formula can integrate exactly 2n-1 degree polynoms.

These integrators evaluate the function on n carefully chosen points in each step interval. These points are not evenly spaced. The function is never evaluated at the boundary points, which means it can be undefined at these points.


Constructor Summary
GaussLegendreNDIntegrator(int minPoints, double rawStep)
          Build a Gauss-Legendre integrator.
 
Method Summary
 int getEvaluationsPerStep()
          Get the number of functions evaluation per step.
 double[] integrate(PrimitiveMappingND f, double a, double b)
          Integrate a function over a defined range.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GaussLegendreNDIntegrator

public GaussLegendreNDIntegrator(int minPoints,
                                 double rawStep)
Build a Gauss-Legendre integrator.

A Gauss-Legendre integrator is a formula like:

    int (f) from -1 to +1 = Sum (ai * f(xi))
 

The coefficients of the formula are computed as follow:

   let n be the desired number of points
   the xi are the roots of the degree n Legendre polynomial
   the ai are the integrals int (Li^2) from -1 to +1
   where Li (x) = Prod (x-xk)/(xi-xk) for k != i
 

A formula in n points can integrate exactly polynoms of degree up to 2n-1.

Parameters:
minPoints - minimal number of points desired
rawStep - raw integration step (the precise step will be adjusted in order to have an integer number of steps in the integration range).
Method Detail

getEvaluationsPerStep

public int getEvaluationsPerStep()
Get the number of functions evaluation per step.

Returns:
number of function evaluation per step

integrate

public double[] integrate(PrimitiveMappingND f,
                          double a,
                          double b)
                   throws MappingException
Description copied from interface: PrimitiveMappingNDIntegrator
Integrate a function over a defined range.

Specified by:
integrate in interface PrimitiveMappingNDIntegrator
Parameters:
f - function to integrate
a - first bound of the range (can be lesser or greater than b)
b - second bound of the range (can be lesser or greater than a)
Returns:
value of the integral over the range
Throws:
MappingException - if the underlying function throws one