[ Home ] | Integration II. Adaptive algorithms | Numerical Methods. Note « 7 » |
Gaussian quadratures seek to obtain the best approximation to the integral ∫ab w(x)f(x)dx ≈ ∑i=1..n wi f(xi) with optimally chosen abscissas xi and weights wi. The optimal abscissas happen to be the roots of polynomials which are orthogonal on (a,b) with the weight-function w(x). Since the number of free parameters is 2n (n abscissas and n weights) the Gaussian quadratures are accurate up to 2n-1 order compared to only n-1 order for equally spaced abscissas. Unfortunately the optimal points can not be reused at the next iteration in an adaptive algorithm.
Gauss-Kronrod quadratures represent a compromise between equally spaced abscissas and optimal abscissas. They reuse n points from the previous iteration (n weights as free parameters) and add m optimal points (m abscissas and m weights as free parameters). Thus the accuracy of the method is n+2m-1. There are several special variants of these quadratures fit for particular types of the integrands.
QUADPACK is (probably) the best integration library, available at netlib.org. It is also compiled into GNU scientific library which is installed on our server, gunilo. An example of how to use it is here.
Problems
function [J,err] = adapt(fun,a,b,acc,eps)
[J,err] = open24(fun,a,b) ; tolerance = acc+eps*abs(J)
if ( err > tolerance ) then
[J1,err1] = adapt(fun,a,(a+b)/2,acc/√(2),eps);
[J2,err2] = adapt(fun,(a+b)/2,b,acc/√(2),eps)
J=J1+J2 ; err = √(err12 + err22)
NB: Reuse points!