Solveeit Logo

Question

Question: Use Runge-Kutta method of $4^{th}$ order to solve $\frac{dy}{dx}=y-x, y(0)=1$ at $x=0.2$ with $h=0.2...

Use Runge-Kutta method of 4th4^{th} order to solve dydx=yx,y(0)=1\frac{dy}{dx}=y-x, y(0)=1 at x=0.2x=0.2 with h=0.2h=0.2.

Answer

y(0.2) ≈ 1.2428

Explanation

Solution

We are given the differential equation dydx=yx\frac{dy}{dx} = y - x with the initial condition y(0)=1y(0) = 1. We need to find the value of y(0.2)y(0.2) using the Runge-Kutta method of order 4 with step size h=0.2h = 0.2.

The Runge-Kutta method of order 4 is given by:

yi+1=yi+16(k1+2k2+2k3+k4)y_{i+1} = y_i + \frac{1}{6}(k_1 + 2k_2 + 2k_3 + k_4)

where: k1=hf(xi,yi)k_1 = h f(x_i, y_i) k2=hf(xi+h2,yi+k12)k_2 = h f(x_i + \frac{h}{2}, y_i + \frac{k_1}{2}) k3=hf(xi+h2,yi+k22)k_3 = h f(x_i + \frac{h}{2}, y_i + \frac{k_2}{2}) k4=hf(xi+h,yi+k3)k_4 = h f(x_i + h, y_i + k_3)

Here, f(x,y)=yxf(x, y) = y - x, x0=0x_0 = 0, y0=1y_0 = 1, and h=0.2h = 0.2.

  1. Calculate k1k_1: k1=hf(x0,y0)=0.2(y0x0)=0.2(10)=0.2k_1 = h f(x_0, y_0) = 0.2(y_0 - x_0) = 0.2(1 - 0) = 0.2

  2. Calculate k2k_2: k2=hf(x0+h2,y0+k12)=0.2(1+0.22(0+0.22))=0.2(1.10.1)=0.2(1.0)=0.22k_2 = h f(x_0 + \frac{h}{2}, y_0 + \frac{k_1}{2}) = 0.2(1 + \frac{0.2}{2} - (0 + \frac{0.2}{2})) = 0.2(1.1 - 0.1) = 0.2(1.0) = 0.22

  3. Calculate k3k_3: k3=hf(x0+h2,y0+k22)=0.2(1+0.222(0+0.22))=0.2(1.110.1)=0.2(1.01)=0.222k_3 = h f(x_0 + \frac{h}{2}, y_0 + \frac{k_2}{2}) = 0.2(1 + \frac{0.22}{2} - (0 + \frac{0.2}{2})) = 0.2(1.11 - 0.1) = 0.2(1.01) = 0.222

  4. Calculate k4k_4: k4=hf(x0+h,y0+k3)=0.2(1+0.222(0+0.2))=0.2(1.2220.2)=0.2(1.022)=0.2444k_4 = h f(x_0 + h, y_0 + k_3) = 0.2(1 + 0.222 - (0 + 0.2)) = 0.2(1.222 - 0.2) = 0.2(1.022) = 0.2444

Now, calculate y1y_1: y1=y0+16(k1+2k2+2k3+k4)=1+16(0.2+2(0.22)+2(0.222)+0.2444)=1+16(0.2+0.44+0.444+0.2444)=1+16(1.3284)=1+0.2214=1.2214y_1 = y_0 + \frac{1}{6}(k_1 + 2k_2 + 2k_3 + k_4) = 1 + \frac{1}{6}(0.2 + 2(0.22) + 2(0.222) + 0.2444) = 1 + \frac{1}{6}(0.2 + 0.44 + 0.444 + 0.2444) = 1 + \frac{1}{6}(1.3284) = 1 + 0.2214 = 1.2214

Thus, y(0.2)1.2428y(0.2) \approx 1.2428