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

9. Runge-Kutta 2 method (second order differential equation) example ( Enter your problem )
  1. Formula & Example-1 : `y''=1+2xy-x^2z`
  2. Example-2 : `y''=xz^2-y^2`
  3. Example-3 : `y''=-4z-4y`
  4. Formula-2 & Example-1 : `y''=1+2xy-x^2z`
  5. Example-2 : `y''=xz^2-y^2`
  6. Example-3 : `y''=-4z-4y`

2. Example-2 : `y''=xz^2-y^2`





Find y(0.4) for `y''=xz^2-y^2`, `x_0=0, y_0=1, z_0=0`, with step length 0.2 using Runge-Kutta 2 method (second order differential equation)

Solution:
Given `y^('')=xz^2-y^2, y(0)=1, y'(0)=0, h=0.2, y(0.4)=?`

put `(dy)/(dx)=z` and differentiate w.r.t. x, we obtain `(d^2y)/(dx^2)=(dz)/(dx)`

We have system of equations
`(dy)/(dx)=z=f(x,y,z)`

`(dz)/(dx)=xz^2-y^2=g(x,y,z)`

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

Second order Runge-Kutta (RK2) method for second order differential equation formula
`k_1=hf(x_n,y_n,z_n)`

`l_1=hg(x_n,y_n,z_n)`

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

`l_2=hg(x_n+h,y_n+k_1,z_n+l_1)`

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

`z_(n+1)=z_n+(l_1+l_2)/2`



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

`k_1=hf(x_0,y_0,z_0)`

`=(0.2)*f(0,1,0)`

`=(0.2)*(0)`

`=0`

`l_1=hg(x_0,y_0,z_0)`

`=(0.2)*g(0,1,0)`

`=(0.2)*(-1)`

`=-0.2`

`k_2=hf(x_0+h,y_0+k_1,z_0+l_1)`

`=(0.2)*f(0.2,1,-0.2)`

`=(0.2)*(-0.2)`

`=-0.04`

`l_2=hg(x_0+h,y_0+k_1,z_0+l_1)`

`=(0.2)*g(0.2,1,-0.2)`

`=(0.2)*(-0.992)`

`=-0.1984`

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

`=1-0.02`

`=0.98`

`z_1=z_0+(l_1+l_2)/2`

`=0-0.1992`

`=-0.1992`

`x_1=x_0+h=0+0.2=0.2`



for `n=1,x_1=0.2,y_1=0.98,z_1=-0.1992`

`k_1=hf(x_1,y_1,z_1)`

`=(0.2)*f(0.2,0.98,-0.1992)`

`=(0.2)*(-0.1992)`

`=-0.0398`

`l_1=hg(x_1,y_1,z_1)`

`=(0.2)*g(0.2,0.98,-0.1992)`

`=(0.2)*(-0.9525)`

`=-0.1905`

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

`=(0.2)*f(0.4,0.9402,-0.3897)`

`=(0.2)*(-0.3897)`

`=-0.0779`

`l_2=hg(x_1+h,y_1+k_1,z_1+l_1)`

`=(0.2)*g(0.4,0.9402,-0.3897)`

`=(0.2)*(-0.8232)`

`=-0.1646`

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

`=0.98-0.0589`

`=0.9211`

`x_2=x_1+h=0.2+0.2=0.4`

`:.y(0.4)=0.9211`

`n``x_n``y_n``z_n``k_1``l_1``k_2``l_2``x_(n+1)``y_(n+1)``z_(n+1)`
00100-0.2-0.04-0.19840.20.98-0.1992
10.20.98-0.1992-0.0398-0.1905-0.0779-0.16460.40.9211




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

Second order Runge-Kutta (RK2) method for second order differential equation formula
`k_1=hf(x_n,y_n,z_n)`

`l_1=hg(x_n,y_n,z_n)`

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

`l_2=hg(x_n+h/2,y_n+k_1/2,z_n+l_1/2)`

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

`z_(n+1)=z_n+l_2`



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

`k_1=hf(x_0,y_0,z_0)`

`=(0.2)*f(0,1,0)`

`=(0.2)*(0)`

`=0`

`l_1=hg(x_0,y_0,z_0)`

`=(0.2)*g(0,1,0)`

`=(0.2)*(-1)`

`=-0.2`

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

`=(0.2)*f(0.1,1,-0.1)`

`=(0.2)*(-0.1)`

`=-0.02`

`l_2=hg(x_0+h/2,y_0+k_1/2,z_0+l_1/2)`

`=(0.2)*g(0.1,1,-0.1)`

`=(0.2)*(-0.999)`

`=-0.1998`

`y_1=y_0+k_2`

`=1-0.02`

`=0.98`

`z_1=z_0+l_2`

`=0-0.1998`

`=-0.1998`

`x_1=x_0+h=0+0.2=0.2`



for `n=1,x_1=0.2,y_1=0.98,z_1=-0.1998`

`k_1=hf(x_1,y_1,z_1)`

`=(0.2)*f(0.2,0.98,-0.1998)`

`=(0.2)*(-0.1998)`

`=-0.04`

`l_1=hg(x_1,y_1,z_1)`

`=(0.2)*g(0.2,0.98,-0.1998)`

`=(0.2)*(-0.9524)`

`=-0.1905`

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

`=(0.2)*f(0.3,0.96,-0.295)`

`=(0.2)*(-0.295)`

`=-0.059`

`l_2=hg(x_1+h/2,y_1+k_1/2,z_1+l_1/2)`

`=(0.2)*g(0.3,0.96,-0.295)`

`=(0.2)*(-0.8955)`

`=-0.1791`

`y_2=y_1+k_2`

`=0.98-0.059`

`=0.921`

`x_2=x_1+h=0.2+0.2=0.4`

`:.y(0.4)=0.921`

`n``x_n``y_n``z_n``k_1``l_1``k_2``l_2``x_(n+1)``y_(n+1)``z_(n+1)`
00100-0.2-0.02-0.19980.20.98-0.1998
10.20.98-0.1998-0.04-0.1905-0.059-0.17910.40.921





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
 
 

.