Home > Numerical methods > Numerical Differential Equation > Euler method example

4. Runge-Kutta 4 method (first order differential equation) example ( Enter your problem )
  1. Formula-1 & Example-1 : `y'=(x-y)/2`
  2. Example-2 : `y'=-2x-y`
  3. Example-3 : `y'=-y`
  4. Formula-2 & Example-1 : `y'=(x-y)/2`
  5. Example-2 : `y'=-2x-y`
  6. Example-3 : `y'=-y`

2. Example-2 : `y'=-2x-y`





Find y(0.5) for `y'=-2x-y`, `x_0=0, y_0=-1`, with step length 0.1 using Runge-Kutta 4 method (first order differential equation)

Solution:
Given `y'=-2x-y, y(0)=-1, h=0.1, y(0.5)=?`

Fourth order Runge-Kutta (RK4) method formula
`k_1=h f(x_n,y_n)

`k_2=h f(x_n+h/2,y_n+k_1/2

`k_3=h f(x_n+h/2,y_n+k_2/2

`k_4=h f(x_n+h,y_n+k_3

`y_(n+1)=y_n+1/6(k_1+2k_2+2k_3+k_4)`



for `n=0,x_0=0,y_0=-1`

`k_1=hf(x_0,y_0)`

`=(0.1)f(0,-1)`

`=(0.1)*(1)`

`=0.1`

`k_2=hf(x_0+h/2,y_0+k_1/2)`

`=(0.1)f(0.05,-0.95)`

`=(0.1)*(0.85)`

`=0.085`

`k_3=hf(x_0+h/2,y_0+k_2/2)`

`=(0.1)f(0.05,-0.9575)`

`=(0.1)*(0.8575)`

`=0.0858`

`k_4=hf(x_0+h,y_0+k_3)`

`=(0.1)f(0.1,-0.9142)`

`=(0.1)*(0.7143)`

`=0.0714`

`y_1=y_0+1/6(k_1+2k_2+2k_3+k_4)`

`=-1+1/6[0.1+2(0.085)+2(0.0858)+(0.0714)]`

`=-0.9145`

`x_1=x_0+h=0+0.1=0.1`



for `n=1,x_1=0.1,y_1=-0.9145`

`k_1=hf(x_1,y_1)`

`=(0.1)f(0.1,-0.9145)`

`=(0.1)*(0.7145)`

`=0.0715`

`k_2=hf(x_1+h/2,y_1+k_1/2)`

`=(0.1)f(0.15,-0.8788)`

`=(0.1)*(0.5788)`

`=0.0579`

`k_3=hf(x_1+h/2,y_1+k_2/2)`

`=(0.1)f(0.15,-0.8856)`

`=(0.1)*(0.5856)`

`=0.0586`

`k_4=hf(x_1+h,y_1+k_3)`

`=(0.1)f(0.2,-0.856)`

`=(0.1)*(0.456)`

`=0.0456`

`y_2=y_1+1/6(k_1+2k_2+2k_3+k_4)`

`=-0.9145+1/6[0.0715+2(0.0579)+2(0.0586)+(0.0456)]`

`=-0.8562`

`x_2=x_1+h=0.1+0.1=0.2`



for `n=2,x_2=0.2,y_2=-0.8562`

`k_1=hf(x_2,y_2)`

`=(0.1)f(0.2,-0.8562)`

`=(0.1)*(0.4562)`

`=0.0456`

`k_2=hf(x_2+h/2,y_2+k_1/2)`

`=(0.1)f(0.25,-0.8334)`

`=(0.1)*(0.3334)`

`=0.0333`

`k_3=hf(x_2+h/2,y_2+k_2/2)`

`=(0.1)f(0.25,-0.8395)`

`=(0.1)*(0.3395)`

`=0.034`

`k_4=hf(x_2+h,y_2+k_3)`

`=(0.1)f(0.3,-0.8222)`

`=(0.1)*(0.2222)`

`=0.0222`

`y_3=y_2+1/6(k_1+2k_2+2k_3+k_4)`

`=-0.8562+1/6[0.0456+2(0.0333)+2(0.034)+(0.0222)]`

`=-0.8225`

`x_3=x_2+h=0.2+0.1=0.3`



for `n=3,x_3=0.3,y_3=-0.8225`

`k_1=hf(x_3,y_3)`

`=(0.1)f(0.3,-0.8225)`

`=(0.1)*(0.2225)`

`=0.0222`

`k_2=hf(x_3+h/2,y_3+k_1/2)`

`=(0.1)f(0.35,-0.8113)`

`=(0.1)*(0.1113)`

`=0.0111`

`k_3=hf(x_3+h/2,y_3+k_2/2)`

`=(0.1)f(0.35,-0.8169)`

`=(0.1)*(0.1169)`

`=0.0117`

`k_4=hf(x_3+h,y_3+k_3)`

`=(0.1)f(0.4,-0.8108)`

`=(0.1)*(0.0108)`

`=0.0011`

`y_4=y_3+1/6(k_1+2k_2+2k_3+k_4)`

`=-0.8225+1/6[0.0222+2(0.0111)+2(0.0117)+(0.0011)]`

`=-0.811`

`x_4=x_3+h=0.3+0.1=0.4`



for `n=4,x_4=0.4,y_4=-0.811`

`k_1=hf(x_4,y_4)`

`=(0.1)f(0.4,-0.811)`

`=(0.1)*(0.011)`

`=0.0011`

`k_2=hf(x_4+h/2,y_4+k_1/2)`

`=(0.1)f(0.45,-0.8104)`

`=(0.1)*(-0.0896)`

`=-0.009`

`k_3=hf(x_4+h/2,y_4+k_2/2)`

`=(0.1)f(0.45,-0.8154)`

`=(0.1)*(-0.0846)`

`=-0.0085`

`k_4=hf(x_4+h,y_4+k_3)`

`=(0.1)f(0.5,-0.8194)`

`=(0.1)*(-0.1806)`

`=-0.0181`

`y_5=y_4+1/6(k_1+2k_2+2k_3+k_4)`

`=-0.811+1/6[0.0011+2(-0.009)+2(-0.0085)+(-0.0181)]`

`=-0.8196`

`x_5=x_4+h=0.4+0.1=0.5`

`:.y(0.5)=-0.8196`

`n``x_n``y_n``k_1``k_2``k_3``k_4``x_(n+1)``y_(n+1)`
00-10.10.0850.08580.07140.1-0.9145
10.1-0.91450.07150.05790.05860.04560.2-0.8562
20.2-0.85620.04560.03330.0340.02220.3-0.8225
30.3-0.82250.02220.01110.01170.00110.4-0.811
40.4-0.8110.0011-0.009-0.0085-0.01810.5-0.8196





This material is intended as a summary. Use your textbook for detail explanation.
Any bug, improvement, feedback then Submit Here





Share this solution or page with your friends.
 
 
Copyright © 2026. All rights reserved. Terms, Privacy
 
 

.