Maths

Gaussian Quadrature

An introduction to Gaussian quadrature, Legendre polynomials, and why orthogonality doubles the degree of exactness.

In Newton-Cotes formula, we choose n+1n+1 evenly spaced points on the interval to do Lagrange interpolation and deduce a formula from the integral of that polynomial. To improve the precision, we will choose nn special points in the interval; with the same interpolation–integration approach, we can achieve a degree of exactness of 2n12n-1. (Recall: When an algorithm works exactly right for all polynomials of degree m\leq m but not for degree m+1m+1, we say that it has a degree of exactness of mm. )

One of the typical solutions is to choose the nn roots of the Legendre polynomial Pn(x)P_n(x). The Legendre polynomials form a complete orthogonal system on [1,1][-1,1] with weight function w(x)=1w(x)=1 (where Pn(x)P_n(x) is a polynomial of degree nn), i.e.

11Pm(x)Pn(x)dx=0ifmn.\int_{-1}^{1}{P_m(x)P_n(x)\,\mathrm{d}x}=0\quad \text{if}\, m\neq n.

With the standardization condition Pn(1)=1P_n(1)=1 for all nn, all the polynomials can be uniquely determined. In fact, by Rodrigues' Formula,

Pn(x)=12nn!dndxn(x21)n.P_n(x)=\frac{1}{2^{n}n!}\frac{\mathrm{d}^{n}}{\mathrm{d}x^n}{(x^2-1)^n}.

Let x1,x2,,xnx_1,x_2,\cdots,x_n be the roots of Pn(x)P_n(x). We squeeze our target interval [a,b][a,b] to [1,1][-1,1] and do Lagrange interpolation with points (xi,g(xi))(x_i,g(x_i)), where g(x)g(x) is the transformed f(x)f(x). Gaussian Quadrature is then

abf(x)dxba2i=1nwif(ba2xi+a+b2)\int_{a}^{b}{f(x)\,\mathrm{d}x}\approx \frac{b-a}{2}\sum_{i=1}^{n}{w_{i}f(\frac{b-a}{2}x_i+\frac{a+b}{2})}

where the weights wiw_i can be found similarly to the Newton–Cotes αi\alpha_i values, or via the closed form

wi=2(1xi2)[Pn(xi)]2.w_i=\frac{2}{(1-x_i^2)[P_n'(x_i)]^2}.

We have known the procedure of Gaussian quadrature. But why are Legendre polynomials so useful that our exactness is doubled? It all comes from the orthogonality. Say we have a polynomial T(x)T(x) whose degree is no more than 2n12n-1. Divide T(x)T(x) by Pn(x)P_n(x)and we have T(x)=Q(x)Pn(x)+R(x)T(x)=Q(x)P_n(x)+R(x), where degQn1,degRn1deg\,Q\leq n-1,\, deg\,R\leq n-1. We write Q(x)Q(x) as a linear combination of lower-order Legendre polynomials: Q(x)=i=0n1kiPi(x)Q(x)=\sum_{i=0}^{n-1}{k_{i}P_i(x)}. Then by the definition of Legendre polynomials, 11Pi(x)Pn(x)=0\int_{-1}^{1}{P_i(x)P_n(x)=0}, thus 11Q(x)Pn(x)=0\int_{-1}^{1}{Q(x)P_n(x)=0}. Now we are ready to prove that

11T(x)dx=i=1nwiT(xi).\int_{-1}^{1}{T(x)\,\mathrm{d}x}=\sum_{i=1}^{n}{w_{i}T(x_i)}.

For the left side,

11T(x)dx=11Q(x)Pn(x)dx+11R(x)dx=11R(x)dx.\int_{-1}^{1}{T(x)\,\mathrm{d}x}=\int_{-1}^{1}{Q(x)P_n(x)\,\mathrm{d}x}+\int_{-1}^{1}{R(x)\,\mathrm{d}x}=\int_{-1}^{1}{R(x)\,\mathrm{d}x}.

For the right side,

i=1,2,,nPn(xi)=0\forall i=1,2,\cdots,n\quad P_n(x_i)=0 i=1nwiT(xi)=i=1nwi[Q(xi)Pn(xi)+R(xi)]=i=1nwiR(xi).\begin{aligned} \sum_{i=1}^{n}{w_{i}T(x_i)} &=\sum_{i=1}^{n}{w_{i}[Q(x_i)P_n(x_i)+R(x_i)]} \\ &=\sum_{i=1}^{n}{w_{i}R(x_i)}. \end{aligned}

By its construction, an n-point Gaussian quadrature rule is exact for any polynomial of degree up to n1n−1. Since degRn1deg\,R\leq n-1, the quadrature gives the exact integral:

11R(x)dx=i=1nwiR(xi).\int_{-1}^{1}{R(x)\,\mathrm{d}x}=\sum_{i=1}^{n}{w_{i}R(x_i)}.

Thus our quadrature works exactly right for T(x)T(x). On the other hand, the error

En(f)=22n+1(n!)4(2n+1)[(2n)!]3f(2n)(ξ)E_n(f)=\frac{2^{2n+1}(n!)^4}{(2n+1)[(2n)!]^3}f^{(2n)}(\xi)

for some ξ(1,1)\xi\in(-1,1). Therefore, the degree of exactness is 2n12n-1. Above is all of the magic of Gaussian quadrature.