The math optional, made finite. Daily Practice

Gaussian quadrature

At a Glance

Why This Chapter Matters

Gaussian quadrature and undetermined-coefficients quadrature are among the highest-mark derivation problems in Paper 2’s numerical methods section. The 2016 question (15 marks) derives the two-point Gauss-Legendre rule from scratch and applies it; the 2018 question (15 marks) finds a three-parameter formula by matching monomials; the 2020 question (20 marks) constructs a weighted quadrature rule using Beta-integral moments. All three use the same core technique — set up a linear system by requiring the formula to be exact on 1,x,x2,1, x, x^2, \ldots — and then evaluate. Getting the moment integrals right is the only genuinely hard part.

Minimum Theory

Undetermined coefficients method. A quadrature formula abw(x)f(x)dxicif(xi)\int_a^b w(x)f(x)\,dx \approx \sum_i c_i f(x_i) with kk free parameters is determined by requiring exactness on the kk monomials 1,x,x2,,xk11, x, x^2, \ldots, x^{k-1}. This gives a k×kk\times k linear system for the parameters.

Gauss-Legendre rule (2 points). On [1,1][-1,1] with w(x)=1w(x)=1 and two free nodes x1,x2x_1,x_2 and weights w1,w2w_1,w_2 (four parameters), impose exactness on 1,x,x2,x31,x,x^2,x^3. By symmetry: w1=w2=1w_1=w_2=1, x1=x2=1/3x_1=-x_2=1/\sqrt{3}. The rule 11fdxf(1/3)+f(1/3)\int_{-1}^1 f\,dx \approx f(1/\sqrt3)+f(-1/\sqrt3) is exact for all polynomials of degree 3\le 3.

Rescaling. For abf(x)dx\int_a^b f(x)\,dx, use x=a+b2+ba2tx=\tfrac{a+b}{2}+\tfrac{b-a}{2}t (t[1,1]t\in[-1,1], dx=ba2dtdx=\tfrac{b-a}{2}\,dt) to convert to the standard [1,1][-1,1] interval. The Jacobian factor ba2\tfrac{b-a}{2} must be included unless ba=2b-a=2.

Gauss-Legendre quadrature: nodes and weights on [-1,1]

Question Archetypes

ArchetypeRecognition
gauss-quadrature”Show that the two-point Gauss rule is …; use it to evaluate …“
undetermined-coefficients-quadrature”Find constants such that f=h[af(x0)+bf(x1)+cf(x2)]\int f = h[af(x_0)+bf(x_1)+cf(x_2)] is exact to highest degree”

gauss-quadrature (1 question(s); 2016)

Recognition Cues

Solution Template

  1. Set up the system. Write w1f(x1)+w2f(x2)=11xkdxw_1f(x_1)+w_2f(x_2)=\int_{-1}^1 x^k\,dx for k=0,1,2,3k=0,1,2,3.
  2. Invoke symmetry. Take w1=w2=ww_1=w_2=w, x2=x1x_2=-x_1 to halve the unknowns.
  3. Solve. k=0k=0 gives w=1w=1; k=2k=2 gives x12=1/3x_1^2=1/3, so x1=1/3x_1=1/\sqrt3.
  4. Rescale to [a,b][a,b]. Map t[1,1]t\in[-1,1] to x[a,b]x\in[a,b] via x=a+b2+ba2tx=\tfrac{a+b}{2}+\tfrac{b-a}{2}t; include Jacobian.
  5. Evaluate the rescaled function at t=±1/3t=\pm1/\sqrt3.

Worked Example

2016 Paper 2, 2016-P2-Q7c (15 marks)

Show that the two-point Gauss quadrature rule is 11f(x)dx=f(1/3)+f(1/3)\int_{-1}^1 f(x)\,dx = f(1/\sqrt3)+f(-1/\sqrt3) and use it to estimate 242xexdx\int_2^4 2xe^x\,dx.

Derivation. Four unknowns w1,w2,x1,x2w_1,w_2,x_1,x_2; impose exactness on 1,x,x2,x31,x,x^2,x^3 over [1,1][-1,1]:

w1+w2=2,w1x1+w2x2=0,w1x12+w2x22=23,w1x13+w2x23=0.w_1+w_2=2,\quad w_1x_1+w_2x_2=0,\quad w_1x_1^2+w_2x_2^2=\tfrac{2}{3},\quad w_1x_1^3+w_2x_2^3=0.

By symmetry w1=w2=1w_1=w_2=1, x2=x1x_2=-x_1. Equation (3): 2x12=23x1=132x_1^2=\tfrac{2}{3}\Rightarrow x_1=\tfrac{1}{\sqrt3}.

11f(x)dx=f ⁣(13)+f ⁣(13)\boxed{\int_{-1}^1 f(x)\,dx = f\!\left(\tfrac{1}{\sqrt3}\right)+f\!\left(-\tfrac{1}{\sqrt3}\right)}

Application. Map [2,4][2,4] to [1,1][-1,1]: x=3+tx=3+t (dx=dtdx=dt). Define g(t)=2(3+t)e3+tg(t)=2(3+t)e^{3+t}.

g(0.5774)=2(3.5774)e3.5774=7.1548×35.779255.98g(0.5774)=2(3.5774)\,e^{3.5774}=7.1548\times 35.779\approx255.98

g(0.5774)=2(2.4226)e2.4226=4.8452×11.27754.64g(-0.5774)=2(2.4226)\,e^{2.4226}=4.8452\times 11.277\approx54.64

242xexdx255.98+54.64=310.62\boxed{\int_2^4 2xe^x\,dx \approx 255.98+54.64 = 310.62}

(Exact: 2(3e4e2)312.812(3e^4-e^2)\approx312.81; error 2.19\approx2.19, expected since 2xex2xe^x is not a polynomial.)


undetermined-coefficients-quadrature (2 question(s); 2018, 2020)

Recognition Cues

Solution Template

  1. Evaluate the integral of each monomial xkx^k (possibly with weight w(x)w(x)). These are the moments μk=xkw(x)dx\mu_k=\int x^k w(x)\,dx.
  2. Set up the exactness conditions: icixik=μk\sum_i c_i x_i^k = \mu_k for k=0,1,,m1k=0,1,\ldots,m-1 where mm = number of free parameters.
  3. Solve the linear system for the weights.
  4. Check the next monomial (xmx^m) to identify the degree of exactness; it will fail.
  5. Compute the truncation error from the first-failing monomial: Ehm+1f(m)(ξ)/m!E\propto h^{m+1}f^{(m)}(\xi)/m!.

Worked Example

2018 Paper 2, 2018-P2-Q7b (15 marks)

Find a,b,ca,b,c such that 0hf(x)dx=h[af(0)+bf(h/3)+cf(h)]\int_0^h f(x)\,dx = h[af(0)+bf(h/3)+cf(h)] is exact for polynomials of highest degree. Find the order of the truncation error.

Three parameters \Rightarrow impose exactness on f=1,x,x2f=1,x,x^2.

For f=1f=1: h=h(a+b+c)h = h(a+b+c), so a+b+c=1a+b+c=1.

For f=xf=x: h2/2=h(bh/3+ch)=h2(b/3+c)h^2/2 = h(b\cdot h/3 + c\cdot h) = h^2(b/3+c), so b/3+c=1/2b/3+c=1/2.

For f=x2f=x^2: h3/3=h(bh2/9+ch2)=h3(b/9+c)h^3/3 = h(b\cdot h^2/9+c\cdot h^2) = h^3(b/9+c), so b/9+c=1/3b/9+c=1/3.

Subtract: b3b9=12132b9=16b=34\tfrac{b}{3}-\tfrac{b}{9}=\tfrac{1}{2}-\tfrac{1}{3} \Rightarrow \tfrac{2b}{9}=\tfrac{1}{6} \Rightarrow b=\tfrac{3}{4}. Then c=1214=14c=\tfrac{1}{2}-\tfrac{1}{4}=\tfrac{1}{4}, and a=13414=0a=1-\tfrac{3}{4}-\tfrac{1}{4}=0.

a=0,b=34,c=14\boxed{a=0,\quad b=\frac{3}{4},\quad c=\frac{1}{4}}

Check f=x3f=x^3: LHS =h4/4=h^4/4; RHS =h4[34127+14]=h4[136+14]=5h418h44=h^4[\tfrac{3}{4}\cdot\tfrac{1}{27}+\tfrac{1}{4}]=h^4[\tfrac{1}{36}+\tfrac{1}{4}]=\tfrac{5h^4}{18}\ne\tfrac{h^4}{4}. Not exact for degree 3.

Truncation error. Error for x3x^3: h445h418=h436\tfrac{h^4}{4}-\tfrac{5h^4}{18}=-\tfrac{h^4}{36}. With f(3)=6f^{(3)}=6: E=Ch46=h436C=1216E=Ch^4\cdot6=-\tfrac{h^4}{36}\Rightarrow C=-\tfrac{1}{216}.

E=h4216f(ξ),O(h4)\boxed{E = -\frac{h^4}{216}\,f'''(\xi),\quad O(h^4)}


2020 Paper 2, 2020-P2-Q7b (20 marks)

Find α1,α2,α3\alpha_1,\alpha_2,\alpha_3 such that 01f(x)dxx(1x)=α1f(0)+α2f(12)+α3f(1)\int_0^1 \tfrac{f(x)\,dx}{\sqrt{x(1-x)}}=\alpha_1 f(0)+\alpha_2 f(\tfrac12)+\alpha_3 f(1) is exact to highest degree; evaluate 01dxxx3\int_0^1\tfrac{dx}{\sqrt{x-x^3}}.

Moments of w(x)=1/x(1x)w(x)=1/\sqrt{x(1-x)} (Beta integrals):

μ0=π,μ1=π2,μ2=3π8,μ3=5π16\mu_0=\pi,\quad \mu_1=\frac{\pi}{2},\quad \mu_2=\frac{3\pi}{8},\quad \mu_3=\frac{5\pi}{16}

Exactness conditions (nodes 0,12,10,\tfrac12,1; k=0,1,2k=0,1,2):

α1+α2+α3=π\alpha_1+\alpha_2+\alpha_3=\pi; 12α2+α3=π2\tfrac{1}{2}\alpha_2+\alpha_3=\tfrac{\pi}{2}; 14α2+α3=3π8\tfrac{1}{4}\alpha_2+\alpha_3=\tfrac{3\pi}{8}.

Subtract: 14α2=π8α2=π2\tfrac{1}{4}\alpha_2=\tfrac{\pi}{8}\Rightarrow\alpha_2=\tfrac{\pi}{2}. Then α3=π4\alpha_3=\tfrac{\pi}{4}, α1=π4\alpha_1=\tfrac{\pi}{4}.

α1=π4,α2=π2,α3=π4\boxed{\alpha_1=\frac{\pi}{4},\quad \alpha_2=\frac{\pi}{2},\quad \alpha_3=\frac{\pi}{4}}

Check: rule is exact for x3x^3 (the weight’s symmetry gives a bonus) but fails for x4x^4. Exact to degree 3.

Evaluate 01dx/xx3\int_0^1 dx/\sqrt{x-x^3}: factor xx3=x(1x)(1+x)x-x^3=x(1-x)(1+x), so take f(x)=1/1+xf(x)=1/\sqrt{1+x}.

f(0)=1f(0)=1, f(1/2)=2/30.8165f(1/2)=\sqrt{2/3}\approx0.8165, f(1)=1/20.7071f(1)=1/\sqrt2\approx0.7071.

Iπ4(1)+π2(0.8165)+π4(0.7071)=0.7854+1.2826+0.5554=2.6234I\approx\frac{\pi}{4}(1)+\frac{\pi}{2}(0.8165)+\frac{\pi}{4}(0.7071)=0.7854+1.2826+0.5554=2.6234

01dxxx32.623\boxed{\int_0^1\frac{dx}{\sqrt{x-x^3}}\approx 2.623}

Common Traps

Marks-Aware Writing

A 15-mark derivation answer must show: explicit exactness conditions for each monomial (written as equations, not just stated), the solution of the linear system step by step, a check on the next failing monomial, and the error constant computed from the first failing case. A 20-mark answer additionally requires: the moment integrals evaluated explicitly, the identification of the highest degree of exactness, and the application to the specific integral with all numerical values shown.

Practice Set

We've mapped all 13 years of this exam. Get new chapters, tools, and solutions as we release them — free.