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

2. Runge-Kutta 2 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 2 method (first order differential equation)

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

Method-1 : Using formula `k_2=hf(x_0+h,y_0+k_1)`

Second order Runge-Kutta (RK2) method formula
`k_1=hf(x_n,y_n)`

`k_2=hf(x_n+h,y_n+k_1)`

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



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,y_0+k_1)`

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

`=(0.1)*(0.7)`

`=0.07`

`y_1=y_0+(k_1+k_2)/2`

`=-1+0.085`

`=-0.915`

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



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

`k_1=hf(x_1,y_1)`

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

`=(0.1)*(0.715)`

`=0.0715`

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

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

`=(0.1)*(0.4435)`

`=0.0444`

`y_2=y_1+(k_1+k_2)/2`

`=-0.915+0.0579`

`=-0.8571`

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



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

`k_1=hf(x_2,y_2)`

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

`=(0.1)*(0.4571)`

`=0.0457`

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

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

`=(0.1)*(0.2114)`

`=0.0211`

`y_3=y_2+(k_1+k_2)/2`

`=-0.8571+0.0334`

`=-0.8237`

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



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

`k_1=hf(x_3,y_3)`

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

`=(0.1)*(0.2237)`

`=0.0224`

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

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

`=(0.1)*(0.0013)`

`=0.0001`

`y_4=y_3+(k_1+k_2)/2`

`=-0.8237+0.0112`

`=-0.8124`

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



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

`k_1=hf(x_4,y_4)`

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

`=(0.1)*(0.0124)`

`=0.0012`

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

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

`=(0.1)*(-0.1888)`

`=-0.0189`

`y_5=y_4+(k_1+k_2)/2`

`=-0.8124-0.0088`

`=-0.8212`

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

`:.y(0.5)=-0.8212`

`n``x_n``y_n``k_1``k_2``x_(n+1)``y_(n+1)`
00-10.10.070.1-0.915
10.1-0.9150.07150.04440.2-0.8571
20.2-0.85710.04570.02110.3-0.8237
30.3-0.82370.02240.00010.4-0.8124
40.4-0.81240.0012-0.01890.5-0.8212




Method-2 : Using formula `k_2=hf(x_0+h/2,y_0+k_1/2)`

Second order Runge-Kutta (RK2) method formula
`k_1=hf(x_n,y_n)`

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

`y_(n+1)=y_n+k_2`



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`

`y_1=y_0+k_2`

`=-1+0.085`

`=-0.915`

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



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

`k_1=hf(x_1,y_1)`

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

`=(0.1)*(0.715)`

`=0.0715`

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

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

`=(0.1)*(0.5792)`

`=0.0579`

`y_2=y_1+k_2`

`=-0.915+0.0579`

`=-0.8571`

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



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

`k_1=hf(x_2,y_2)`

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

`=(0.1)*(0.4571)`

`=0.0457`

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

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

`=(0.1)*(0.3342)`

`=0.0334`

`y_3=y_2+k_2`

`=-0.8571+0.0334`

`=-0.8237`

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



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

`k_1=hf(x_3,y_3)`

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

`=(0.1)*(0.2237)`

`=0.0224`

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

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

`=(0.1)*(0.1125)`

`=0.0112`

`y_4=y_3+k_2`

`=-0.8237+0.0112`

`=-0.8124`

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



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

`k_1=hf(x_4,y_4)`

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

`=(0.1)*(0.0124)`

`=0.0012`

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

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

`=(0.1)*(-0.0882)`

`=-0.0088`

`y_5=y_4+k_2`

`=-0.8124-0.0088`

`=-0.8212`

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

`:.y(0.5)=-0.8212`

`n``x_n``y_n``k_1``k_2``x_(n+1)``y_(n+1)`
00-10.10.0850.1-0.915
10.1-0.9150.07150.05790.2-0.8571
20.2-0.85710.04570.03340.3-0.8237
30.3-0.82370.02240.01120.4-0.8124
40.4-0.81240.0012-0.00880.5-0.8212





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
 
 

.