## Gauss-Legendre Quadrature

Gauss-Legendre quadrature formulas are used to integrate functions*f(x)*over a closed and bounded interval

*[a, b]*. Let

*∫*denote the integral of

_{a}^{b}f( x ) dx*f(x)*from

*a*to

*b*. After making the change of variable

*t = 2(x - a)/(b-a) -1*, then

*∫*=

_{a}^{b}f( x ) dx*( (b-a)/2 ) ∫*.

_{-1}^{1}f( [(b-a) t + (b + a)] / 2 ) dtWith respect to the inner product

*< f,g > = ∫*, the Legendre polynomials

_{-1}^{1}(f(x) g(x) w(x)) dx*P*for

_{ n}(x) = 1 / ( 2^{ n}n! ) ( d^{ n}/ dx^{ n})( x² - 1 )^{ n}*n > 0*, and

*P*form an orthogonal family of polynomials with weight function

_{0}(x) = 1*w(x) = 1*on the interval

*[-1,1]*.

The

*n*-point Gauss-Legendre quadrature formula,

*GL*for approximating the integral of

_{n}( f(x) ),*f(x)*over

*[-1,1]*, is given by

*GL*=

_{n}( f(x) )*A*,

_{1}f(x_{1}) + ··· + A_{n}f(x_{n})*x*are the zeros of

_{i}, i = 1,...,n,*P*and

_{n}*A*,

_{i}= 2 ( 1 - x_{i}² ) / [n P_{n-1}(x_{i}) ] ²*i = 1,...,n*.

The truncation error is

*∫*-

_{-1}^{1}f(x) dx*GL*=

_{n}( f(x) )*K f*,

^{ (2n)}( c ) / ( 2n! )*K*is a constant, and

*c*is some unknown number

*-1 < c < 1*. The constant

*K*is easily determined from

*K*=

*∫*-

_{-1}^{1}( x^{ 2n}) dx*GL*.

_{n}( x^{ 2n})Generalizing, in order to integrate

*f(x)*over

*[a,b]*, the

*n*-point Gauss-Legendre quadrature formula,

*GL*is given by

_{n}( f(x), a, b ),*GL*=

_{n}( f(x), a, b )*A'*,

_{1}f(x'_{1}) + ··· + A'_{n}f(x'_{n})*x'*are the zeros of

_{i}= (b-a) x_{i}/2 + (b+a) / 2 , x_{i}i = 1,...,n,*P*and

_{n}*A'*,

_{i}= (b-a) ( 1 - x_{i}² ) / [n P_{n-1}(x_{i}) ] ² = [ ( b - a ) / 2 ] A_{i}*i = 1,...,n*.

The truncation error is

*∫*-

_{a}^{b}( f(x) )*GL*=

_{n}( f(x), a, b )*K f*,

^{ (2n)}( c ) / ( 2n! )*K*is a constant, and

*c*is some unknown number

*a < c < b*.

### Function List

For*n = 2,3,4,5,6,7,8,9,10,12,14,16,20,24,28,32,40,48,56,64,82,96, and 100*

- double Gauss_Legendre_Integration_
*n*pts( double a, double b, double (*f)(double) )

Integrate the user supplied function (*f)(x) from a to b where a is the lower limit of integration, b > a is the upper limit of integration.

- void Gauss_Legendre_Zeros_
*n*pts( double nodes[ ])

Returns the zeros of the Legendre polynomial*P*in the user allocated array nodes of dimension n._{n}(x)

- void Gauss_Legendre_Coefs_
*n*pts( double wght[ ] )

Returns the weights of the Gauss-Legendre formula in the user allocated array wght of dimension n. The*i*element of the array wght is the weight which corresponds to the^{ th}*i*node in the array nodes as returned in Gauss_Legendre_Zeros_^{ th}*n*pts( double nodes[ ]).

*C* Source Code

- The file, gauss_legendre_2pts.c, contains the versions of Gauss_Legendre_Integration_2pts( ), Gauss_Legendre_Zeros_2pts and Gauss_Legendre_Coefs_2pts( ) written in
*C*.

- The file, gauss_legendre_3pts.c, contains the versions of Gauss_Legendre_Integration_3pts( ), Gauss_Legendre_Zeros_3pts and Gauss_Legendre_Coefs_3pts( ) written in
*C*.

- The file, gauss_legendre_4pts.c, contains the versions of Gauss_Legendre_Integration_4pts( ), Gauss_Legendre_Zeros_4pts and Gauss_Legendre_Coefs_4pts( ) written in
*C*.

- The file, gauss_legendre_5pts.c, contains the versions of Gauss_Legendre_Integration_5pts( ), Gauss_Legendre_Zeros_5pts and Gauss_Legendre_Coefs_5pts( ) written in
*C*.

- The file, gauss_legendre_6pts.c, contains the versions of Gauss_Legendre_Integration_6pts( ), Gauss_Legendre_Zeros_6pts and Gauss_Legendre_Coefs_6pts( ) written in
*C*.

- The file, gauss_legendre_7pts.c, contains the versions of Gauss_Legendre_Integration_7pts( ), Gauss_Legendre_Zeros_7pts and Gauss_Legendre_Coefs_7pts( ) written in
*C*.

- The file, gauss_legendre_8pts.c, contains the versions of Gauss_Legendre_Integration_8pts( ), Gauss_Legendre_Zeros_8pts and Gauss_Legendre_Coefs_8pts( ) written in
*C*.

- The file, gauss_legendre_9pts.c, contains the versions of Gauss_Legendre_Integration_9pts( ), Gauss_Legendre_Zeros_9pts and Gauss_Legendre_Coefs_9pts( ) written in
*C*.

- The file, gauss_legendre_10pts.c, contains the versions of Gauss_Legendre_Integration_10pts( ), Gauss_Legendre_Zeros_10pts and Gauss_Legendre_Coefs_10pts( ) written in
*C*.

- The file, gauss_legendre_12pts.c, contains the versions of Gauss_Legendre_Integration_12pts( ), Gauss_Legendre_Zeros_12pts and Gauss_Legendre_Coefs_12pts( ) written in
*C*.

- The file, gauss_legendre_14pts.c, contains the versions of Gauss_Legendre_Integration_14pts( ), Gauss_Legendre_Zeros_14pts and Gauss_Legendre_Coefs_14pts( ) written in
*C*.

- The file, gauss_legendre_16pts.c, contains the versions of Gauss_Legendre_Integration_16pts( ), Gauss_Legendre_Zeros_16pts and Gauss_Legendre_Coefs_16pts( ) written in
*C*.

- The file, gauss_legendre_20pts.c, contains the versions of Gauss_Legendre_Integration_20pts( ), Gauss_Legendre_Zeros_20pts and Gauss_Legendre_Coefs_20pts( ) written in
*C*.

- The file, gauss_legendre_24pts.c, contains the versions of Gauss_Legendre_Integration_24pts( ), Gauss_Legendre_Zeros_24pts and Gauss_Legendre_Coefs_24pts( ) written in
*C*.

- The file, gauss_legendre_28pts.c, contains the versions of Gauss_Legendre_Integration_28pts( ), Gauss_Legendre_Zeros_28pts and Gauss_Legendre_Coefs_28pts( ) written in
*C*.

- The file, gauss_legendre_32pts.c, contains the versions of Gauss_Legendre_Integration_32pts( ), Gauss_Legendre_Zeros_32pts and Gauss_Legendre_Coefs_32pts( ) written in
*C*.

- The file, gauss_legendre_40pts.c, contains the versions of Gauss_Legendre_Integration_40pts( ), Gauss_Legendre_Zeros_40pts and Gauss_Legendre_Coefs_40pts( ) written in
*C*.

- The file, gauss_legendre_48pts.c, contains the versions of Gauss_Legendre_Integration_48pts( ), Gauss_Legendre_Zeros_48pts and Gauss_Legendre_Coefs_48pts( ) written in
*C*.

- The file, gauss_legendre_56pts.c, contains the versions of Gauss_Legendre_Integration_56pts( ), Gauss_Legendre_Zeros_56pts and Gauss_Legendre_Coefs_56pts( ) written in
*C*.

- The file, gauss_legendre_64pts.c, contains the versions of Gauss_Legendre_Integration_64pts( ), Gauss_Legendre_Zeros_64pts and Gauss_Legendre_Coefs_64pts( ) written in
*C*.

- The file, gauss_legendre_82pts.c, contains the versions of Gauss_Legendre_Integration_82pts( ), Gauss_Legendre_Zeros_82pts and Gauss_Legendre_Coefs_82pts( ) written in
*C*.

- The file, gauss_legendre_96pts.c, contains the versions of Gauss_Legendre_Integration_96pts( ), Gauss_Legendre_Zeros_96pts and Gauss_Legendre_Coefs_96pts( ) written in
*C*.

- The file, gauss_legendre_100pts.c, contains the versions of Gauss_Legendre_Integration_100pts( ), Gauss_Legendre_Zeros_100pts and Gauss_Legendre_Coefs_100pts( ) written in
*C*.