Consider the initial value problem :
dy/dx = 1 + y/x, 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).
15 marks · directive: Apply and find
The core of a good answer
One RK4 step gives k₁ = 2, k₂ = 7/3, k₃ = 22/9, k₄ = 49/18 and y(2) ≈ 365/108 = 3.3796; Euler's method gives y(2) = 3 and y(3) = 5.5 (exact values 3.3863 and 6.2958 from y = x ln x + x).
An outline written by upsc.help, not an official UPSC answer; every fact checked by a separate review. How we work
What the question asks
A routine numerical ODE question: carry out one step of classical RK4 and two steps of Euler with h = 1, showing each slope. A good answer also compares with the exact solution, which is easy here because the equation is linear.
Answer outline
Introduction
f(x, y) = 1 + y/x, x₀ = 1, y₀ = 1, h = 1. RK4: k₁ = hf(x₀, y₀), k₂ = hf(x₀ + h/2, y₀ + k₁/2), k₃ = hf(x₀ + h/2, y₀ + k₂/2), k₄ = hf(x₀ + h, y₀ + k₃), y₁ = y₀ + (k₁ + 2k₂ + 2k₃ + k₄)/6.
Step 1: RK4 slopes
- k₁ = f(1, 1) = 1 + 1 = 2
- k₂ = f(1.5, 2) = 1 + 2/1.5 = 7/3 = 2.333333
- k₃ = f(1.5, 1 + 7/6) = 1 + (13/6)/1.5 = 22/9 = 2.444444
- k₄ = f(2, 1 + 22/9) = 1 + (31/9)/2 = 49/18 = 2.722222
Step 2: RK4 result
- y(2) ≈ 1 + (2 + 2(7/3) + 2(22/9) + 49/18)/6
- = 1 + (14.277778)/6 = 365/108 = 3.379630
Step 3: Euler's method
- y_{i+1} = y_i + h f(x_i, y_i)
- y(2) ≈ 1 + 1 × (1 + 1/1) = 3
- y(3) ≈ 3 + 1 × (1 + 3/2) = 5.5
Step 4: Check against the exact solution
- The equation is linear: y′ − y/x = 1, integrating factor 1/x, (y/x)′ = 1/x
- y/x = ln x + C, y(1) = 1 gives C = 1, so y = x ln x + x
- Exact y(2) = 2 ln 2 + 2 = 3.386294; RK4 error 0.0067, Euler error 0.3863
- Exact y(3) = 3 ln 3 + 3 = 6.295837; Euler error 0.7958
Conclusion
RK4 gives y(2) ≈ 3.3796; Euler gives y(2) = 3 and y(3) = 5.5. Even with the large step h = 1, RK4 is accurate to about 0.2 per cent while Euler is off by over 11 per cent. All values were recomputed in Python with exact fractions.
Examples and data to cite
- With a step this large Euler's error grows step by step because each step uses only the slope at the left end.
- Halving the step size reduces RK4 error by about 16 times and Euler error by about 2 times.
Facts to remember
- Classical RK4: y_{n+1} = y_n + (k₁ + 2k₂ + 2k₃ + k₄)/6; local error O(h⁵), global error O(h⁴).
- Euler's method: y_{n+1} = y_n + h f(x_n, y_n); global error O(h).
- Linear first order ODE y′ + P(x)y = Q(x) is solved with integrating factor e^(∫P dx).
- Exact solution of this problem: y = x(1 + ln x).