Gauss-Legendre Quadrature

Description

Gauss-Legendre quadrature formulas are used to integrate functions f(x) over a closed and bound interval [a,b]. Let I[a,b] (f(x)) denote the integral of f(x) from a to b. By making a change of variables t = 2(x - a)/(b-a) -1, then I[-1,1] f( [(b-a) t + (b + a)] / 2 ) = I[a,b] (f(x)). With respect to the inner product < f,g > = I[-1,1] (f(x) g(x) w(x)), the Legendre polynomials P n(x) = 1 / ( 2 nn! ) ( d n / dx n )( x² - 1 ) n for n > 0, and P0(x) = 1 form an orthogonal family of polynomials with weight function w(x) = 1 on the interval [-1,1].
 
For integrating f(x) over [-1,1], the n -point Gauss-Legendre quadrature formula, GLn ( f(x) ), is given by
GLn ( f(x) ) = A1 f(x1) + ··· + An f(xn),
where xi , i = 1,...,n, are the zeros of Pn and Ai = 2 ( 1 - xi² ) / [n Pn-1 (xi) ] ², i = 1,...,n.
 
The truncation error is
I[-1,1] ( f(x) ) - GLn ( f(x) ) = K f (2n)( c ) / ( 2n! ),
where K is a constant, and c is some unknown number -1 < c < 1. The constant K is easily determined from K = I[-1,1] ( x 2n ) - GLn ( x 2n ).
 
Generalizing, in order to integrate f(x) over [a,b], the n -point Gauss-Legendre quadrature formula, GLn ( f(x) ), is given by
GLn ( f(x) ) = A'1 f(x'1) + ··· + A'n f(x'n),
where x'i = (b-a) xi /2 + (b+a) / 2 , xi i = 1,...,n, are the zeros of Pn and A'i = (b-a) ( 1 - xi² ) / [n Pn-1 (xi) ] ² = [ ( b - a ) / 2 ] Ai, i = 1,...,n.
 
The truncation error is
I[-1,1] ( f(x) ) - GLn ( f(x) ) = K f (2n)( c ) / ( 2n! ),
where K is a constant, and c is some unknown number -1 < c < 1.

Function List

C Source