← 2015 Paper 2

UPSC 2015 Maths Optional Paper 2 Q7b — Step-by-Step Solution

15 marks · Section B

Runge-Kutta methods (RK2/RK4) · Numerical Analysis · asked 4× in 13 yrs · Read the full method →

Question

Solve the initial value problem dydx=x(yx)\dfrac{dy}{dx}=x(y-x), y(2)=3y(2)=3 in the interval [2,2.4][2,2.4] using the Runge–Kutta fourth-order method with step size h=0.2h=0.2.

Technique

RK4 with two steps, h=0.2h=0.2; careful tracking of intermediate ff evaluations.

Solution

Setup. f(x,y)=x(yx)f(x,y)=x(y-x). x0=2x_0=2, y0=3y_0=3, h=0.2h=0.2. Two steps to reach x=2.4x=2.4.

RK4 formula: at each step,

k1=hf(xn,yn)k_1=hf(x_n,y_n) k2=hf(xn+h/2,  yn+k1/2)k_2=hf(x_n+h/2,\;y_n+k_1/2) k3=hf(xn+h/2,  yn+k2/2)k_3=hf(x_n+h/2,\;y_n+k_2/2) k4=hf(xn+h,  yn+k3)k_4=hf(x_n+h,\;y_n+k_3) yn+1=yn+16(k1+2k2+2k3+k4)y_{n+1}=y_n+\tfrac{1}{6}(k_1+2k_2+2k_3+k_4)

Step 1 — Step 1: x0=2,  y0=3x_0=2,\;y_0=3 to x1=2.2x_1=2.2

f(2,3)=2(32)=2f(2,3)=2(3-2)=2. k1=0.22=0.4k_1=0.2\cdot 2=0.4.

f(2.1,  3+0.4/2)=f(2.1,3.2)=2.1(3.22.1)=2.11.1=2.31f(2.1,\;3+0.4/2)=f(2.1,3.2)=2.1(3.2-2.1)=2.1\cdot 1.1=2.31. k2=0.22.31=0.462k_2=0.2\cdot 2.31=0.462.

f(2.1,  3+0.462/2)=f(2.1,3.231)=2.1(3.2312.1)=2.11.131=2.3751f(2.1,\;3+0.462/2)=f(2.1,3.231)=2.1(3.231-2.1)=2.1\cdot 1.131=2.3751. k3=0.22.3751=0.47502k_3=0.2\cdot 2.3751=0.47502.

f(2.2,  3+0.47502)=f(2.2,3.47502)=2.2(3.475022.2)=2.21.27502=2.805044f(2.2,\;3+0.47502)=f(2.2,3.47502)=2.2(3.47502-2.2)=2.2\cdot 1.27502=2.805044. k4=0.22.805044=0.561009k_4=0.2\cdot 2.805044=0.561009.

y1=3+16(0.4+20.462+20.47502+0.561009)y_1=3+\tfrac{1}{6}(0.4+2\cdot 0.462+2\cdot 0.47502+0.561009) =3+16(0.4+0.924+0.95004+0.561009)=3+\tfrac{1}{6}(0.4+0.924+0.95004+0.561009) =3+16(2.835049)=3+\tfrac{1}{6}(2.835049) =3+0.472508=3+0.472508 3.4725\approx 3.4725.

Step 2 — Step 2: x1=2.2,  y1=3.4725x_1=2.2,\;y_1=3.4725 to x2=2.4x_2=2.4

f(2.2,3.4725)=2.2(3.47252.2)=2.21.2725=2.7995f(2.2,3.4725)=2.2(3.4725-2.2)=2.2\cdot 1.2725=2.7995. k1=0.22.7995=0.5599k_1=0.2\cdot 2.7995=0.5599.

f(2.3,  3.4725+0.5599/2)=f(2.3,  3.4725+0.27995)=f(2.3,3.75245)=2.3(3.752452.3)=2.31.45245=3.340635f(2.3,\;3.4725+0.5599/2)=f(2.3,\;3.4725+0.27995)=f(2.3,3.75245)=2.3(3.75245-2.3)=2.3\cdot 1.45245=3.340635. k2=0.23.340635=0.668127k_2=0.2\cdot 3.340635=0.668127.

f(2.3,  3.4725+0.668127/2)=f(2.3,  3.4725+0.3340635)=f(2.3,  3.8065635)=2.3(3.80656352.3)=2.31.5065635=3.465096f(2.3,\;3.4725+0.668127/2)=f(2.3,\;3.4725+0.3340635)=f(2.3,\;3.8065635)=2.3(3.8065635-2.3)=2.3\cdot 1.5065635=3.465096. k3=0.23.465096=0.693019k_3=0.2\cdot 3.465096=0.693019.

f(2.4,  3.4725+0.693019)=f(2.4,4.165519)=2.4(4.1655192.4)=2.41.765519=4.237246f(2.4,\;3.4725+0.693019)=f(2.4,4.165519)=2.4(4.165519-2.4)=2.4\cdot 1.765519=4.237246. k4=0.24.237246=0.847449k_4=0.2\cdot 4.237246=0.847449.

y2=3.4725+16(0.5599+20.668127+20.693019+0.847449)y_2=3.4725+\tfrac{1}{6}(0.5599+2\cdot 0.668127+2\cdot 0.693019+0.847449) =3.4725+16(0.5599+1.336254+1.386038+0.847449)=3.4725+\tfrac{1}{6}(0.5599+1.336254+1.386038+0.847449) =3.4725+16(4.129641)=3.4725+\tfrac{1}{6}(4.129641) =3.4725+0.688274=3.4725+0.688274 4.1608\approx 4.1608.

Summary

Answer

  y(2.2)3.4725,y(2.4)4.1608.  \boxed{\;y(2.2)\approx 3.4725,\quad y(2.4)\approx 4.1608.\;}
We post more of this — worked solutions, CSAT trap breakdowns, guide chapters — a few times a week on Telegram. Free, no sign-in. Join

This solution is part of the Maths Coverage Map — 13 years, mapped. Get the take-away PDF free.