UPSC 2013 Maths Optional Paper 2 Q7a — Step-by-Step Solution
20 marks · Section B
Question
Develop an algorithm for Newton–Raphson method to solve starting with initial iterate , be the number of iterations allowed, be the prescribed relative error and be the prescribed lower bound for .
Technique
Standard Newton–Raphson iteration with three safeguards: max iterations, relative tolerance, derivative-lower-bound.
Solution
Strategy. Implement the Newton–Raphson iteration with proper termination criteria: (a) iteration count limit, (b) convergence tolerance on relative change, (c) safeguard against small derivatives.
Algorithm
INPUT: f, f' (function and derivative)
x0 (initial iterate)
n (maximum number of iterations)
eps (prescribed relative error tolerance)
delta (prescribed lower bound for |f'(x)|; must satisfy |f'(x_k)| >= delta)
OUTPUT: an approximate root x_root (or a failure indicator)
ALGORITHM Newton-Raphson:
1. x_prev <- x0
converged <- FALSE
2. FOR k = 1, 2, ..., n DO:
2.1. Evaluate f_val <- f(x_prev) and fprime_val <- f'(x_prev)
2.2. IF |fprime_val| < delta THEN:
PRINT "Derivative too small at iteration k; method fails"
EXIT (failure due to small derivative)
END IF
2.3. x_curr <- x_prev - f_val / fprime_val
2.4. IF |x_curr - x_prev| <= eps * |x_curr| THEN:
converged <- TRUE
EXIT loop
END IF
2.5. x_prev <- x_curr
END FOR
3. IF converged THEN:
OUTPUT x_root = x_curr (success)
ELSE:
PRINT "Failed to converge in n iterations"
OUTPUT x_curr (with warning)
END IF
Step-by-step explanation
-
Initialisation: Set the working variable
x_prevto the user-supplied initial guess . The flagconvergedtracks whether the tolerance has been met. -
Main loop (up to iterations):
2.1. Evaluate and at the current iterate. (Each iteration costs one function evaluation and one derivative evaluation.)
2.2. Safeguard: If , the iteration formula would divide by a tiny number, causing wild overshoot. Abort with an error message instead.
2.3. Newton step: Apply the update.
2.4. Convergence test (relative error): Compare against . The relative-error form is preferred over the absolute form because it scales with the magnitude of the root. If the change is within tolerance, declare convergence.
2.5. Otherwise, update
x_prevand continue. -
Final output:
- On convergence: return .
- On exhaustion of iterations: return the last iterate with a warning.
Convergence properties (informational)
Newton–Raphson has quadratic convergence near a simple root : if , then for some constant depending on near . So convergence is very fast once the iterate is close.
Caveats:
- Quadratic convergence fails at multiple roots (linear instead).
- The “small derivative” safeguard catches both genuine non-convergence (function has zero derivative somewhere) and slow approach to a multiple root.
- The initial guess must be in a basin of attraction of the desired root; bad initial guesses lead to divergence, oscillation, or convergence to a wrong root.