UPSC 2026 Maths Optional Paper 2 Q8b — Step-by-Step Solution
15 marks · Section B
Runge-Kutta methods (RK2/RK4) · Numerical Analysis · asked 5× in 14 yrs · Read the full method →
Question
Consider the initial value problem:
dxdy=1+xy,y(1)=1,h=1 (Step-size)
(i) Apply the classical fourth order Runge-Kutta method to approximate the solution y(2).
(ii) Use Euler’s method to find y(2) and y(3).
Technique
Straight application of two standard one-step formulae, but with a step size h=1 that is deliberately enormous — that is the whole point of the question, and the marks are in the arithmetic being exact and completely shown. Note that f(x,y)=1+y/x depends on both arguments, so the Runge–Kutta stages must advance x to 1.5 and 2 as well as y; ignoring the x-shift is the standard way to lose this question. The equation is also linear (y′−y/x=1), so the exact solution is available in one line and the comparison table it makes possible is what lifts the answer above a bare numerical grind.
Solution
Step 0 — The problem is well posed on the interval we use
Here
f(x,y)=1+xy,x0=1,y0=1,h=1.
The right-hand side has a singular point at x=0, where f is undefined. But every abscissa used below lies in [1,3]: the Euler nodes are x=1,2,3 and the Runge–Kutta stages sample x=1,1.5,2. On the strip 1≤x≤3, y∈R, both f and
∂y∂f=x1(∂y∂f≤1)
are continuous and bounded, so f is Lipschitz in y. By Picard’s theorem the IVP has a unique solution on [1,3], and the standard convergence theory for one-step methods applies. Nothing is singular on the interval used.
Step 1 — The exact solution (needed for the comparison, and cheap)
The equation is linear of first order: dxdy−x1y=1. The integrating factor is
exp(−∫xdx)=x1,
so
dxd(xy)=x1⟹xy=logx+C.
The condition y(1)=1 gives 1=0+C, i.e. C=1. Hence
y(x)=x(1+logx)
Check: y′=1+logx+1=2+logx, while 1+y/x=1+(1+logx)=2+logx. ✓
(Note the second Euler step is started from the computed value y1=3, not from the exact y(2) — this is why the error compounds.)
Step 4 — Comparison with the exact solution, and why RK4 wins
x
Euler (h=1)
RK4 (h=1)
Exact x(1+logx)
Euler error
RK4 error
2
3.0000000
108365=3.3796296
2+2log2=3.3862944
0.3862944
0.0066647
3
211=5.5000000
—
3+3log3=6.2958369
0.7958369
—
Relative errors at x=2: Euler 11.41%, RK4 0.20% — a factor of about 58 in accuracy for four function evaluations instead of one.
Why RK4 is so much closer. The local truncation errors are
Euler: 2h2y′′(ξ)=O(h2),RK4: O(h5),
so the global orders are O(h) and O(h4). But note carefully: with h=1 the powers of h buy nothing — h2=h5=1. The entire advantage here is structural, not asymptotic. Euler uses a single slope, taken at the left endpoint, and extrapolates it linearly across a whole unit interval; RK4 samples the slope field four times (at x=1,1.5,1.5,2) and weights the samples 61(1,2,2,1) — Simpson’s weights — so that its increment reproduces the Taylor expansion of the exact solution through the h4 term instead of only through h1. It is the number of matched Taylor terms, not the smallness of h, that is doing the work at this step size.
Why both undershoot. Since y′′=1/x>0, the solution is convex, so the Euler local error
y(xi+1)−[yi+hf(xi,yi)]=2h2y′′(ξ)=2ξ1>0
is positive at every step: each Euler step lands below the curve. Moreover the error is propagated forward with the factor 1+h∂f/∂y=1+1/xi>0, so successive deficits reinforce rather than cancel. Euler must therefore undershoot at x=2 and undershoot by more at x=3 — which is exactly what the table shows (3<3.386, 5.5<6.296). This is a prediction, not a post-hoc observation.
Remark 1 (the Euler iteration in closed form). With h=1 and xn=n+1, Euler reads yn+1=ynn+1n+2+1. Putting yn=(n+1)zn gives zn+1=zn+n+21 with z0=1, so
yn=(n+1)Hn+1,Hm=j=1∑mj1.
Compare the exact y(xn)=(n+1)(1+log(n+1)): Euler has simply replaced log(n+1)=∫1n+1tdt by its right-endpoint rectangle sum ∑j=2n+1j1 on unit subintervals. Because 1/t is decreasing, that sum underestimates the integral — an independent proof of the undershoot. The exact global error is
γ being Euler’s constant: the error grows linearly and without bound, confirming that h=1 is far too coarse for Euler. (Check: n=1 gives 2[1−(1.5−log2)]=0.3862944 ✓, n=2 gives 3[1−(611−log3)]=0.7958369 ✓.)
Remark 2 (RK4 continued to x=3, for completeness — not asked). A second RK4 step from (2,108365) gives
an error of 0.0108369 against 6.2958369 — still 73 times better than Euler at the same point. Under exam conditions do not compute this: part (i) asks for y(2) only.