Level 4 — ApplicationNumerical Methods

Numerical Methods

60 minutes60 marksprintable — key stays hidden on paper

Level: 4 (Application — novel problems, no hints) Time limit: 60 minutes Total marks: 60

Answer all questions. Calculators permitted. Show all working; unsupported answers earn no method marks.


Question 1 — Catastrophic cancellation & conditioning (12 marks)

Consider computing f(x)=1cosxx2f(x) = \dfrac{1 - \cos x}{x^2} for small xx, whose exact limit as x0x \to 0 is 12\tfrac12.

(a) Working in a hypothetical decimal machine that carries only 6 significant digits, evaluate f(x)f(x) directly at x=103x = 10^{-3} using cos(103)0.999999\cos(10^{-3}) \approx 0.999999 (rounded to 6 sig. figs). Report the computed value and the relative error against 0.50.5. (4)

(b) Explain precisely which subtraction causes catastrophic cancellation and estimate how many significant digits are lost. (3)

(c) Derive an algebraically equivalent formula for f(x)f(x) using a half-angle identity that avoids the cancellation, and re-evaluate at x=103x=10^{-3} using sin(5×104)0.000500000\sin(5\times10^{-4}) \approx 0.000500000 to 6 sig. figs. (3)

(d) The relative condition number of a function is κf(x)=xf(x)f(x)\kappa_f(x) = \left|\dfrac{x f'(x)}{f(x)}\right|. Compute κf\kappa_f at x0x \to 0 (use the limit) and state whether the problem itself is well-conditioned there, distinguishing this from the algorithm's instability. (2)


Question 2 — Root finding, mixed methods (14 marks)

Let g(x)=x32x5g(x) = x^3 - 2x - 5 (a classical test equation), which has a single real root near x=2x=2.

(a) Perform 2 iterations of the secant method starting from x0=2x_0 = 2, x1=3x_1 = 3. Report x2x_2 and x3x_3 to 5 decimal places. (5)

(b) Perform 1 iteration of Newton–Raphson from x0=2x_0 = 2. Compare the resulting estimate's accuracy with your x2x_2 from part (a). (3)

(c) Bisection is applied on [2,3][2,3]. Determine the minimum number of iterations required to guarantee the root is located to within an absolute error of 10610^{-6}. (3)

(d) State the theoretical order of convergence of the secant method and of Newton's method, and explain in one or two sentences why the secant method can still be preferred in practice. (3)


Question 3 — Interpolation & numerical integration (14 marks)

The function values below are sampled from an unknown smooth ff:

xx 0 1 2 3
f(x)f(x) 1 2 5 10

(a) Construct the Newton divided-difference interpolating polynomial through all four points and simplify it to standard form. (5)

(b) Use the composite Simpson's 1/3 rule with all four intervals-worth of data appropriately (i.e. use nodes 0,1,20,1,2 for Simpson and handle the remaining subinterval) to estimate 03f(x)dx\int_0^3 f(x)\,dx. Clearly state how you treat the interval [2,3][2,3] and justify. (5)

(c) Given that a bound f(4)(ξ)M|f^{(4)}(\xi)| \le M holds on [0,2][0,2], write the error term for the composite Simpson's 1/3 rule over [0,2][0,2] with h=1h=1, and evaluate it for the polynomial you found in (a) (state the value of f(4)f^{(4)}). (4)


Question 4 — Linear systems & iterative convergence (10 marks)

Consider the system

4x1x2+x3=7,2x1+5x2+x3=3,x1+x2+4x3=4.\begin{aligned} 4x_1 - x_2 + x_3 &= 7,\\ 2x_1 + 5x_2 + x_3 &= -3,\\ x_1 + x_2 + 4x_3 &= 4. \end{aligned}

(a) Show the coefficient matrix is strictly diagonally dominant, and hence state what this guarantees about the Jacobi and Gauss–Seidel iterations. (3)

(b) Perform 1 iteration of Gauss–Seidel starting from x(0)=(0,0,0)Tx^{(0)} = (0,0,0)^T. Report x(1)x^{(1)}. (5)

(c) State one reason Gauss–Seidel typically converges faster than Jacobi. (2)


Question 5 — ODE integration (10 marks)

Consider the IVP y=yt2+1y' = y - t^2 + 1,  y(0)=0.5\ y(0) = 0.5, on [0,0.4][0, 0.4] with step h=0.2h = 0.2.

(a) Take one step of Heun's method (modified Euler) to estimate y(0.2)y(0.2). Show the predictor and corrector explicitly. (5)

(b) Take one step of the classical RK4 method to estimate y(0.2)y(0.2) (compute k1,k2,k3,k4k_1,k_2,k_3,k_4). (5)


Answer keyMark scheme & solutions

Question 1 (12)

(a) With cos(103)=0.999999\cos(10^{-3})=0.999999 (6 sig figs): 1cosx=10.999999=0.000001=1.00000×1061-\cos x = 1 - 0.999999 = 0.000001 = 1.00000\times10^{-6}. x2=(103)2=1.00000×106x^2 = (10^{-3})^2 = 1.00000\times10^{-6}. f=1.0×1061.0×106=1.00000f = \dfrac{1.0\times10^{-6}}{1.0\times10^{-6}} = 1.00000. Relative error =1.00.50.5=1.0= \dfrac{|1.0 - 0.5|}{0.5} = 1.0 (100%). (1 mark subtraction, 1 mark x2x^2, 1 mark quotient, 1 mark rel. error.)

(b) The subtraction 1cosx1 - \cos x is the culprit: for small xx, cosx1x2/2=15×107\cos x \approx 1 - x^2/2 = 1 - 5\times10^{-7}, which is closer to 1 than 6 digits can resolve. Rounding cosx\cos x to 0.9999990.999999 retains only ~1 significant digit of the true difference 5×107\approx 5\times10^{-7}; the leading matching digits cancel. About 5–6 significant digits are lost (the true difference has magnitude 10710^{-7} but is represented as 10610^{-6}). (2 marks identify subtraction & why, 1 mark digit-loss estimate.)

(c) Half-angle: 1cosx=2sin2(x/2)1-\cos x = 2\sin^2(x/2), so f(x)=2sin2(x/2)x2=12(sin(x/2)x/2)2.f(x)=\frac{2\sin^2(x/2)}{x^2}=\frac12\left(\frac{\sin(x/2)}{x/2}\right)^2. At x=103x=10^{-3}, x/2=5×104x/2 = 5\times10^{-4}, sin(x/2)=0.000500000\sin(x/2)=0.000500000: sin(x/2)x/2=0.0005000000.000500000=1.00000\dfrac{\sin(x/2)}{x/2} = \dfrac{0.000500000}{0.000500000} = 1.00000, so f=12(1)2=0.500000f = \tfrac12(1)^2 = 0.500000. No cancellation because sin(x/2)\sin(x/2) is computed directly (no near-equal subtraction). (2 marks derivation, 1 mark value.)

(d) f(x)=12f(x)=\tfrac12 (limit), and f(x)0f'(x)\to 0 as x0x\to0 (even function, smooth min). Hence κf=xf(x)f(x)01/2=0\kappa_f = \left|\dfrac{xf'(x)}{f(x)}\right| \to \dfrac{0}{1/2}=0. The problem is well-conditioned near 00 (tiny perturbations in xx barely change ff). The 100% error in (a) is purely algorithmic instability (catastrophic cancellation in the chosen formula), not inherent to the problem. (1 mark κ0\kappa\to0, 1 mark distinction.)


Question 2 (14)

(a) Secant: xn+1=xng(xn)xnxn1g(xn)g(xn1)x_{n+1} = x_n - g(x_n)\dfrac{x_n-x_{n-1}}{g(x_n)-g(x_{n-1})}. g(2)=845=1g(2) = 8-4-5 = -1; g(3)=2765=16g(3)=27-6-5=16. x2=3163216(1)=31617=2.05882(35294)x_2 = 3 - 16\cdot\dfrac{3-2}{16-(-1)} = 3 - \dfrac{16}{17} = 2.05882\,(35294). g(x2)g(x_2): x2=2.0588235x_2=2.0588235, x23=8.72670x_2^3=8.72670, g(x2)=8.726704.117655=0.39094g(x_2)=8.72670-4.11765-5=-0.39094. x3=x2g(x2)x2x1g(x2)g(x1)x_3 = x_2 - g(x_2)\dfrac{x_2-x_1}{g(x_2)-g(x_1)} =2.05882(0.39094)2.0588230.3909416= 2.05882 - (-0.39094)\dfrac{2.05882-3}{-0.39094-16} =2.05882(0.39094)0.9411816.39094= 2.05882 - (-0.39094)\cdot\dfrac{-0.94118}{-16.39094} =2.05882+(0.39094)(0.05742)(1)= 2.05882 + (-0.39094)(-0.05742)\cdot(-1)... compute carefully: 0.9411816.39094=0.057421\dfrac{-0.94118}{-16.39094}=0.057421; (0.39094)(0.057421)=0.022449(-0.39094)(0.057421)=-0.022449; x3=2.05882(0.022449)=2.08127x_3 = 2.05882 - (-0.022449) = 2.08127. x22.05882x_2 \approx 2.05882, x32.08127x_3 \approx 2.08127. (2 marks x2x_2, 3 marks x3x_3.)

(b) Newton: g(x)=3x22g'(x)=3x^2-2, g(2)=10g'(2)=10, g(2)=1g(2)=-1. x1=2(1)/10=2.1x_1 = 2 - (-1)/10 = 2.1. True root 2.09455\approx 2.09455. Newton's error 0.0055\approx 0.0055; secant x2=2.05882x_2=2.05882 has error 0.036\approx 0.036. Newton's single step is more accurate than one secant step (it uses exact derivative). (2 marks value+compare, 1 mark reasoning.)

(c) Bisection error after nn steps ba2n=12n\le \dfrac{b-a}{2^n}=\dfrac{1}{2^n}. Require 12n106\dfrac{1}{2^n}\le10^{-6}, i.e. 2n1062^n\ge10^6. 219=524288<1062^{19}=524288<10^6, 220=10485761062^{20}=1048576\ge10^6. So n=20n=20 iterations. (1 formula, 1 inequality, 1 answer.)

(d) Secant order 1+521.618\approx \dfrac{1+\sqrt5}{2}\approx1.618 (superlinear); Newton order =2=2 (quadratic). Secant is often preferred because it needs no derivative evaluation — each step costs one function evaluation vs Newton's two (f and f'), giving comparable or better efficiency per work unit when derivatives are expensive/unavailable. (1 each order, 1 practical reason.)


Question 3 (14)

(a) Divided differences: f[0]=1, f[1]=2, f[2]=5, f[3]=10f[0]=1,\ f[1]=2,\ f[2]=5,\ f[3]=10. First: f[0,1]=1, f[1,2]=3, f[2,3]=5f[0,1]=1,\ f[1,2]=3,\ f[2,3]=5. Second: f[0,1,2]=312=1, f[1,2,3]=532=1f[0,1,2]=\dfrac{3-1}{2}=1,\ f[1,2,3]=\dfrac{5-3}{2}=1. Third: f[0,1,2,3]=113=0f[0,1,2,3]=\dfrac{1-1}{3}=0. Polynomial: P(x)=1+1x+1x(x1)+0=1+x+x2x=1+x2.P(x)=1 + 1\cdot x + 1\cdot x(x-1) + 0 = 1 + x + x^2 - x = 1 + x^2. P(x)=x2+1P(x)=x^2+1. (Check: 01,12,25,3100\to1,1\to2,2\to5,3\to10. ✓) (3 marks DD table, 2 marks simplification.)

(b) Composite Simpson's 1/3 on [0,2][0,2] (nodes 0,1,20,1,2, h=1h=1): 02h3[f0+4f1+f2]=13[1+4(2)+5]=143=4.6667.\int_0^2 \approx \dfrac{h}{3}[f_0+4f_1+f_2] = \dfrac{1}{3}[1+4(2)+5]=\dfrac{14}{3}=4.6667. Simpson's 1/3 needs an even number of intervals; [2,3][2,3] is a single leftover interval, so use the trapezoidal rule there: 2312(5+10)=7.5.\int_2^3 \approx \dfrac{1}{2}(5+10)=7.5. Total 4.6667+7.5=12.1667\approx 4.6667 + 7.5 = 12.1667. (Exact for P=x2+1P=x^2+1: 03(x2+1)dx=9+3=12\int_0^3(x^2+1)dx = 9+3 = 12. Simpson is exact on [0,2][0,2] giving 14/314/3; trapezoid over-estimates the quadratic on [2,3][2,3].) (2 marks Simpson, 2 marks handling [2,3][2,3] with justification, 1 mark total.)

(c) Composite Simpson error over [a,b]=[0,2][a,b]=[0,2]: E=(ba)h4180f(4)(ξ)=214180f(4)(ξ)=f(4)(ξ)90E=-\dfrac{(b-a)h^4}{180}f^{(4)}(\xi)=-\dfrac{2\cdot1^4}{180}f^{(4)}(\xi)=-\dfrac{f^{(4)}(\xi)}{90}. For P(x)=x2+1P(x)=x^2+1, f(4)0f^{(4)}\equiv 0, so E=0E=0 — Simpson's 1/3 is exact for polynomials up to degree 3, consistent with the exact match 14/314/3 on [0,2][0,2]. (2 marks error formula, 2 marks f(4)=0E=0f^{(4)}=0\Rightarrow E=0 with explanation.)


Question 4 (10)

(a) Row 1: 4=4>1+1=2|4|=4 > |-1|+|1|=2. Row 2: 5=5>2+1=3|5|=5>|2|+|1|=3. Row 3: 4=4>1+1=2|4|=4>|1|+|1|=2. Strictly diagonally dominant. This guarantees both Jacobi and Gauss–Seidel converge for any initial guess. (2 marks checks, 1 mark guarantee.)

(b) Gauss–Seidel (use updated values immediately), x(0)=(0,0,0)x^{(0)}=(0,0,0): x1=7+x2x34=7+004=1.75.x_1 = \dfrac{7 + x_2 - x_3}{4} = \dfrac{7+0-0}{4}=1.75. x2=32x1x35=32(1.75)05=6.55=1.3.x_2 = \dfrac{-3 - 2x_1 - x_3}{5} = \dfrac{-3-2(1.75)-0}{5}=\dfrac{-6.5}{5}=-1.3. x3=4x1x24=41.75(1.3)4=3.554=0.8875.x_3 = \dfrac{4 - x_1 - x_2}{4}=\dfrac{4-1.75-(-1.3)}{4}=\dfrac{3.55}{4}=0.8875. x(1)=(1.75, 1.3, 0.8875)Tx^{(1)}=(1.75,\ -1.3,\ 0.8875)^T. (2 marks x1x_1, 1.5 each x2,x3x_2,x_3.)

(c) Gauss–Seidel uses the most recently updated components within the same sweep, so it incorporates new information immediately rather than waiting for the next iteration (as Jacobi does), giving a smaller spectral radius / faster convergence for diagonally dominant systems. (2 marks.)


Question 5 (10)

f(t,y)=yt2+1f(t,y)=y-t^2+1, y0=0.5y_0=0.5, t0=0t_0=0, h=0.2h=0.2.

(a) Heun. Predictor (Euler): f(0,0.5)=0.50+1=1.5f(0,0.5)=0.5-0+1=1.5; y~=0.5+0.2(1.5)=0.8\tilde y = 0.5+0.2(1.5)=0.8. Corrector slope at (0.2,0.8)(0.2,0.8): f=0.80.04+1=1.76f=0.8-0.04+1=1.76. y1=0.5+0.22(1.5+1.76)=0.5+0.1(3.26)=0.5+0.326=0.826.y_1 = 0.5 + \dfrac{0.2}{2}(1.5+1.76)=0.5+0.1(3.26)=0.5+0.326=0.826. y(0.2)0.826y(0.2)\approx 0.826. (2 predictor, 2 corrector slope, 1 update.)

(b) RK4. k1=f(0,0.5)=1.5.k_1 = f(0,0.5)=1.5. k2=f(0.1,0.5+0.1(1.5))=f(0.1,0.65)=0.650.01+1=1.64.k_2 = f(0.1,\,0.5+0.1(1.5)) = f(0.1,0.65)=0.65-0.01+1=1.64. k3=f(0.1,0.5+0.1(1.64))=f(0.1,0.664)=0.6640.01+1=1.654.k_3 = f(0.1,\,0.5+0.1(1.64))=f(0.1,0.664)=0.664-0.01+1=1.654. k4=f(0.2,0.5+0.2(1.654))=f(0.2,0.8308)=0.83080.04+1=1.7908.k_4 = f(0.2,\,0.5+0.2(1.654))=f(0.2,0.8308)=0.8308-0.04+1=1.7908. y1=0.5+0.26(k1+2k2+2k3+k4)y_1 = 0.5 + \dfrac{0.2}{6}(k_1+2k_2+2k_3+k_4) =0.5+0.26(1.5+3.28+3.308+1.7908)= 0.5 + \dfrac{0.2}{6}(1.5 + 3.28 + 3.308 + 1.7908) =0.5+0.0333333(9.8788)=0.5+0.329293=0.829293.= 0.5 + 0.0333333(9.8788) = 0.5 + 0.329293 = 0.829293. y(0.2)0.82929y(0.2)\approx 0.82929. (Exact solution y=(t+1)20.5ety=(t+1)^2-0.5e^t gives y(0.2)=0.829299y(0.2)=0.829299.) *(1 each k1..k4k_1..k_4, 1