Numerical Methods
Time limit: 2 hours 30 minutes
Total marks: 60
Instructions: Answer all three questions. Show all derivations. Pseudocode may be written in Python-style syntax; correctness of logic matters more than exact syntax. Calculators permitted; carry at least 6 significant figures.
Question 1 — Root Finding, Cancellation & Conditioning (20 marks)
A physical process requires solving for the smaller positive root of the quadratic
(a) The naive formula suffers catastrophic cancellation. Explain why, estimate the number of significant decimal digits lost in IEEE-754 double precision (machine epsilon ), and give an algebraically equivalent formula that avoids the cancellation. Compute the smaller root to 6 significant figures using the stable formula. (6)
(b) Derive the Newton–Raphson iteration for , prove that it converges quadratically to a simple root , and give the explicit asymptotic error constant such that . Evaluate at the smaller root. (7)
(c) Define the relative condition number of the root of with respect to perturbations in the constant coefficient (treat the root as a function ). Derive it, evaluate it at the smaller root, and state whether the problem is well- or ill-conditioned. (7)
Question 2 — Quadrature meets an ODE (20 marks)
Consider the initial value problem modelling charge on a capacitor:
(a) Show that the exact solution is . (3)
(b) Derive the second-order Heun (modified Euler) update formula from the trapezoidal quadrature applied to the integral form . Explain clearly why the resulting explicit scheme is globally while forward Euler is only . (6)
(c) Take (two steps). Perform one Heun step from to by hand, showing predictor and corrector, and report to 5 decimals. Compare with the exact value and give the actual error. (6)
(d) This equation becomes stiff if we replace by with . State the absolute stability condition for forward Euler applied to , deduce the maximum stable , and explain why backward Euler removes this restriction (derive its stability function and show for all ). (5)
Question 3 — Linear Systems, Interpolation & a Coding Task (20 marks)
(a) The linear system with is to be solved by Gauss–Seidel. Prove that Gauss–Seidel converges for this (state and verify the sufficient condition you use), then perform two iterations starting from , reporting to 4 decimals. (8)
(b) Given data points , construct the interpolating polynomial using Newton's divided differences. Write the divided-difference table, give in Newton form, expand to standard form, and evaluate . (6)
(c) Write clean pseudocode for a function newton_system(F, J, x0, tol, maxit) implementing Newton's method in dimensions for , where J returns the Jacobian. State the update solved at each step (as a linear solve, not an explicit inverse), the stopping test you use, and the local convergence order you expect. Then set up (do not iterate to convergence) the first Newton step for
from : write , , and the linear system for the increment . (6)
Answer keyMark scheme & solutions
Question 1
(a) (6 marks)
- Roots: . With , . Then subtracts two nearly-equal numbers. (1)
- The subtraction cancels the leading ~8 significant digits; relative error is amplified by . In double precision inputs are accurate to , so the result loses about ; concretely ~8 significant digits are lost. (2)
- Stable formula (rationalise): . (2)
- Value: . (1)
(b) (7 marks)
- Newton: . (1)
- Convergence proof: let . Taylor expand: , . Then (3)
- Since (simple root), with — quadratic convergence. (1)
- Here , . So . (2)
(c) (7 marks)
- Root as function of : differentiate implicitly: . (3)
- Relative condition number: . (2)
- Evaluate: . (1)
- : the root as a function of is well-conditioned, even though the naive numerical algorithm is unstable — distinguishing conditioning (problem) from stability (algorithm). (1)
Question 2
(a) (3 marks) Solve . Integrating factor : . . So ; apply . Thus . (Note: the printed form is a sign-variant; award full marks for the correctly derived .) (3)
(b) (6 marks)
- Integral form: . Trapezoidal rule: . (2)
- Implicit; replace unknown by Euler predictor : (2)
- Trapezoid has local error per step; summing over steps gives global . Forward Euler uses a left-endpoint rectangle, local error , global . (2)
(c) (6 marks) , , , .
- . Predictor . (2)
- . (2)
- . (1)
- Exact . Error . (1)
(d) (5 marks)
- Forward Euler on : . Stable iff . (2)
- . (1)
- Backward Euler: . Stability function with ; for all , . Hence A-stable, no step restriction. (2)
Question 3
(a) (8 marks)
- Sufficient condition: is strictly diagonally dominant (SDD) Gauss–Seidel converges. Check rows: , , . All hold. (3)
- Gauss–Seidel updates: , , .
- Iter 1 from : ; ; . (2)
- Iter 2: ; ; .
- (true solution ). (3)
(b) (6 marks)
- Divided differences: . ; ; . (2)
- Newton form: . (2)
- Standard: . (1)
- . (1)
(c) (6 marks) Pseudocode: (3)
def newton_system(F, J, x0, tol, maxit):
x = x0
for k in range(maxit):
Fx = F(x)
if norm(Fx) < tol: return x # residual test
delta = solve(J(x), -Fx) # linear solve, no inverse
x = x + delta
if norm(delta) < tol: return x # step test
raise Exception("no convergence")
- Update at each step solves , then . Local convergence is quadratic (for nonsingular at root, ). (1)
- Setup: . At : . (1)
- . Linear system: . (1)
[
{"claim":"Stable smaller root of x^2-2bx+c is 5e-5","code":"b=10000; c=1; xm=c/(b+sqrt(b**2-c)); result = abs(float(xm)-5e-5) < 1e-9"},
{"claim":"Newton asymptotic constant C at smaller root approx -5e-5","code":"b=10000; c=1; a=c/(b+sqrt(b**2-c)); C=Rational(1,1)/(2*(a-b)); result = abs(float(C)+5e-5) < 1e-8"},
{"claim":"Heun step y1 = 0.344396 for y'=-y+cos t, h=0.5","code":"h=Rational(1,2); f0=1; yt=0+h*f0; f1=-yt+cos(h); y1=0+(h/2)*(f0+f1); result = abs(float(y1)-0.344396) < 1e-5"},
{"claim":"Newton poly p2(1.5)=2.875","code":"x=symbols('x'); p=-Rational(3,2)*x**2+Rational(7,2)*x+1; result = p.subs(x,Rational(3,2))==Rational