Legendre-Gauss Quadrature formula

From HandWiki

Legendre-Gauss Quadratude formiula is the approximation of the integral

(1) [math]\displaystyle{ \int_{-1}^1 f(x)\,dx \approx \sum_{i=1}^N w_i f(x_i). }[/math]

with special choice of nodes [math]\displaystyle{ x_i }[/math] and weights [math]\displaystyle{ w_i }[/math], characterised in that, if the finction [math]\displaystyle{ f }[/math] is polynomial of order smallet than [math]\displaystyle{ 2N }[/math], then the exact equality takes place in equation (1).

Legendre-Gauss quadratude formula is special case of Gaussian quadratures of more general kind, which allow efficient approximation of a function with known asumptiotic behavior at the edges of the interval of integration.

Nodes and weights

Nodes [math]\displaystyle{ x_i }[/math] in equation (1) are zeros of the Polunomial of Lehendre [math]\displaystyle{ P_N }[/math]:

(2) [math]\displaystyle{ P_N(x_i)=0 }[/math]
(3) [math]\displaystyle{ -1\lt x_1\lt x_2\lt ... \lt x_N \lt 1 }[/math]

Weight [math]\displaystyle{ w_i }[/math] in equaiton (1) can be expressed with

(4) [math]\displaystyle{ w_i = \frac{2}{\left( 1-x_i^2 \right) (P'_N(x_i))^2} }[/math]

There is no straightforward espression for the nodes [math]\displaystyle{ x_i }[/math]; they can be approximated with many decimal digits through only few iterations, solving numerically equation (2) with initial approach

(5) [math]\displaystyle{ x_i\approx \cos\left(\pi \frac{1/2 +i}{N}\right) }[/math]

These formulas are described in the books [1] [2]

Precision of the approximation

Example

File:GaulegExample.png
) versus number [math]\displaystyle{ N }[/math] of terms in the right hand side of equation (1).

Extension to other interval

is straightforward. Should I copypast the obvious formulas here?

References

  1. Handbook on special functions. 1980. 
  2. Numerical Resipes in C. Do not forget to type data of the ref. here!.