Fourth Order Runge-Kutta Method Calculator

The calculator will find the approximate solution of the first-order differential equation using the classical fourth order Runge-Kutta method, with steps shown.

If the calculator did not compute something or you have identified an error, or you have a suggestion/feedback, please write it in the comments below.

Find $y{\left(2 \right)}$ for $y^{\prime } = \sin{\left(t y \right)}$, when $y{\left(0 \right)} = 1$, $h = \frac{2}{5}$ using the classical fourth order Runge-Kutta method.

Solution

The Runge-Kutta method states that $y_{n+1} = y_{n} + \frac{h}{6} \left(k_{1} + 2 k_{2} + 2 k_{3} + k_{4}\right)$, where $t_{n+1} = t_{n} + h$, $k_{1} = f{\left(t_{n},y_{n} \right)}$, $k_{2} = f{\left(t_{n} + \frac{h}{2},y_{n} + \frac{h k_{1}}{2} \right)}$, $k_{3} = f{\left(t_{n} + \frac{h}{2},y_{n} + \frac{h k_{2}}{2} \right)}$, and $k_{4} = f{\left(t_{n} + h,y_{n} + h k_{3} \right)}$.

We have that $h = \frac{2}{5}$, $t_{0} = 0$, $y_{0} = 1$, and $f{\left(t,y \right)} = \sin{\left(t y \right)}$.

Step 1

$t_{1} = t_{0} + h = 0 + \frac{2}{5} = \frac{2}{5}$

$k_{1} = f{\left(t_{0},y_{0} \right)} = f{\left(0,1 \right)} = 0$

$k_{2} = f{\left(t_{0} + \frac{h}{2},y_{0} + \frac{h k_{1}}{2} \right)} = f{\left(0 + \frac{\frac{2}{5}}{2},1 + \frac{\left(\frac{2}{5}\right)\cdot \left(0\right)}{2} \right)} = f{\left(\frac{1}{5},1 \right)} = 0.198669330795061$

$k_{3} = f{\left(t_{0} + \frac{h}{2},y_{0} + \frac{h k_{2}}{2} \right)} = f{\left(0 + \frac{\frac{2}{5}}{2},1 + \frac{\left(\frac{2}{5}\right)\cdot \left(0.198669330795061\right)}{2} \right)} = f{\left(\frac{1}{5},1.03973386615901 \right)} = 0.206451342596583$

$k_{4} = f{\left(t_{0} + h,y_{0} + h k_{3} \right)} = f{\left(0 + \frac{2}{5},1 + \left(\frac{2}{5}\right)\cdot \left(0.206451342596583\right) \right)} = f{\left(\frac{2}{5},1.08258053703863 \right)} = 0.419625061196877$

$y{\left(\frac{2}{5} \right)} = y{\left(t_{1} \right)} = y_{1} = y_{0} + \frac{h}{6} \left(k_{1} + 2 k_{2} + 2 k_{3} + k_{4}\right) = 1 + \frac{\frac{2}{5}}{6} \left(0 + 2 \cdot 0.198669330795061 + 2 \cdot 0.206451342596583 + 0.419625061196877\right) = 1.08199109386534$

Step 2

$t_{2} = t_{1} + h = \frac{2}{5} + \frac{2}{5} = \frac{4}{5}$

$k_{1} = f{\left(t_{1},y_{1} \right)} = f{\left(\frac{2}{5},1.08199109386534 \right)} = 0.419411035089935$

$k_{2} = f{\left(t_{1} + \frac{h}{2},y_{1} + \frac{h k_{1}}{2} \right)} = f{\left(\frac{2}{5} + \frac{\frac{2}{5}}{2},1.08199109386534 + \frac{\left(\frac{2}{5}\right)\cdot \left(0.419411035089935\right)}{2} \right)} = f{\left(\frac{3}{5},1.16587330088333 \right)} = 0.643853534490712$

$k_{3} = f{\left(t_{1} + \frac{h}{2},y_{1} + \frac{h k_{2}}{2} \right)} = f{\left(\frac{2}{5} + \frac{\frac{2}{5}}{2},1.08199109386534 + \frac{\left(\frac{2}{5}\right)\cdot \left(0.643853534490712\right)}{2} \right)} = f{\left(\frac{3}{5},1.21076180076349 \right)} = 0.664225362212255$

$k_{4} = f{\left(t_{1} + h,y_{1} + h k_{3} \right)} = f{\left(\frac{2}{5} + \frac{2}{5},1.08199109386534 + \left(\frac{2}{5}\right)\cdot \left(0.664225362212255\right) \right)} = f{\left(\frac{4}{5},1.34768123875025 \right)} = 0.881081971595253$

$y{\left(\frac{4}{5} \right)} = y{\left(t_{2} \right)} = y_{2} = y_{1} + \frac{h}{6} \left(k_{1} + 2 k_{2} + 2 k_{3} + k_{4}\right) = 1.08199109386534 + \frac{\frac{2}{5}}{6} \left(0.419411035089935 + 2 \cdot 0.643853534490712 + 2 \cdot 0.664225362212255 + 0.881081971595253\right) = 1.34310114720475$

Step 3

$t_{3} = t_{2} + h = \frac{4}{5} + \frac{2}{5} = \frac{6}{5}$

$k_{1} = f{\left(t_{2},y_{2} \right)} = f{\left(\frac{4}{5},1.34310114720475 \right)} = 0.879343087787042$

$k_{2} = f{\left(t_{2} + \frac{h}{2},y_{2} + \frac{h k_{1}}{2} \right)} = f{\left(\frac{4}{5} + \frac{\frac{2}{5}}{2},1.34310114720475 + \frac{\left(\frac{2}{5}\right)\cdot \left(0.879343087787042\right)}{2} \right)} = f{\left(1,1.51896976476216 \right)} = 0.998657304313516$

$k_{3} = f{\left(t_{2} + \frac{h}{2},y_{2} + \frac{h k_{2}}{2} \right)} = f{\left(\frac{4}{5} + \frac{\frac{2}{5}}{2},1.34310114720475 + \frac{\left(\frac{2}{5}\right)\cdot \left(0.998657304313516\right)}{2} \right)} = f{\left(1,1.54283260806746 \right)} = 0.999609040694986$

$k_{4} = f{\left(t_{2} + h,y_{2} + h k_{3} \right)} = f{\left(\frac{4}{5} + \frac{2}{5},1.34310114720475 + \left(\frac{2}{5}\right)\cdot \left(0.999609040694986\right) \right)} = f{\left(\frac{6}{5},1.74294476348275 \right)} = 0.867452549636552$

$y{\left(\frac{6}{5} \right)} = y{\left(t_{3} \right)} = y_{3} = y_{2} + \frac{h}{6} \left(k_{1} + 2 k_{2} + 2 k_{3} + k_{4}\right) = 1.34310114720475 + \frac{\frac{2}{5}}{6} \left(0.879343087787042 + 2 \cdot 0.998657304313516 + 2 \cdot 0.999609040694986 + 0.867452549636552\right) = 1.72598970236746$

Step 4

$t_{4} = t_{3} + h = \frac{6}{5} + \frac{2}{5} = \frac{8}{5}$

$k_{1} = f{\left(t_{3},y_{3} \right)} = f{\left(\frac{6}{5},1.72598970236746 \right)} = 0.877394887797677$

$k_{2} = f{\left(t_{3} + \frac{h}{2},y_{3} + \frac{h k_{1}}{2} \right)} = f{\left(\frac{6}{5} + \frac{\frac{2}{5}}{2},1.72598970236746 + \frac{\left(\frac{2}{5}\right)\cdot \left(0.877394887797677\right)}{2} \right)} = f{\left(\frac{7}{5},1.90146867992699 \right)} = 0.461368005308125$

$k_{3} = f{\left(t_{3} + \frac{h}{2},y_{3} + \frac{h k_{2}}{2} \right)} = f{\left(\frac{6}{5} + \frac{\frac{2}{5}}{2},1.72598970236746 + \frac{\left(\frac{2}{5}\right)\cdot \left(0.461368005308125\right)}{2} \right)} = f{\left(\frac{7}{5},1.81826330342908 \right)} = 0.561356508370458$

$k_{4} = f{\left(t_{3} + h,y_{3} + h k_{3} \right)} = f{\left(\frac{6}{5} + \frac{2}{5},1.72598970236746 + \left(\frac{2}{5}\right)\cdot \left(0.561356508370458\right) \right)} = f{\left(\frac{8}{5},1.95053230571564 \right)} = 0.020739477392444$

$y{\left(\frac{8}{5} \right)} = y{\left(t_{4} \right)} = y_{4} = y_{3} + \frac{h}{6} \left(k_{1} + 2 k_{2} + 2 k_{3} + k_{4}\right) = 1.72598970236746 + \frac{\frac{2}{5}}{6} \left(0.877394887797677 + 2 \cdot 0.461368005308125 + 2 \cdot 0.561356508370458 + 0.020739477392444\right) = 1.92222859520394$

Step 5

$t_{5} = t_{4} + h = \frac{8}{5} + \frac{2}{5} = 2$

$k_{1} = f{\left(t_{4},y_{4} \right)} = f{\left(\frac{8}{5},1.92222859520394 \right)} = 0.06597893710495$

$k_{2} = f{\left(t_{4} + \frac{h}{2},y_{4} + \frac{h k_{1}}{2} \right)} = f{\left(\frac{8}{5} + \frac{\frac{2}{5}}{2},1.92222859520394 + \frac{\left(\frac{2}{5}\right)\cdot \left(0.06597893710495\right)}{2} \right)} = f{\left(\frac{9}{5},1.93542438262493 \right)} = -0.33553324651362$

$k_{3} = f{\left(t_{4} + \frac{h}{2},y_{4} + \frac{h k_{2}}{2} \right)} = f{\left(\frac{8}{5} + \frac{\frac{2}{5}}{2},1.92222859520394 + \frac{\left(\frac{2}{5}\right)\cdot \left(-0.33553324651362\right)}{2} \right)} = f{\left(\frac{9}{5},1.85512194590122 \right)} = -0.196342927593455$

$k_{4} = f{\left(t_{4} + h,y_{4} + h k_{3} \right)} = f{\left(\frac{8}{5} + \frac{2}{5},1.92222859520394 + \left(\frac{2}{5}\right)\cdot \left(-0.196342927593455\right) \right)} = f{\left(2,1.84369142416656 \right)} = -0.519093645672128$

$y{\left(2 \right)} = y{\left(t_{5} \right)} = y_{5} = y_{4} + \frac{h}{6} \left(k_{1} + 2 k_{2} + 2 k_{3} + k_{4}\right) = 1.92222859520394 + \frac{\frac{2}{5}}{6} \left(0.06597893710495 + 2 \left(-0.33553324651362\right) + 2 \left(-0.196342927593455\right) - 0.519093645672128\right) = 1.82110412475186$

$y{\left(2 \right)}\approx 1.82110412475186$A