Second Order Runge-Kutta Method: Example
Second Order Runge-Kutta Method: Example
Example
Solve the following system to find x (1.02) using RK2
x (t ) 1 x 2 t 3 , x (1) 4, h 0.01, 1
STEP 1 :
K1 h f (t0 1, x0 4) 0.01(1 x02 t03 ) 0.18
K 2 h f (t0 h, x0 K1 )
0.01(1 ( x0 0.18)2 (t0 .01)3 ) 0.1662
x (1 0.01) x (1) K1 K 2 / 2
4 (0.18 0.1662) / 2 3.8269
CISE301_Topic8L4&5 1
Second order Runge-Kutta Method
Example
STEP 2
CISE301_Topic8L4&5 2
x (t ) 1 x (t ) t , x (1) 4,
2 3
CISE301_Topic8L4&5 3
Example
4th-Order Runge-Kutta Method RK4
dy
1 y x 2
dx
y (0) 0.5
h 0.2
Use RK 4 to compute y (0.2) and y (0.4)
CISE301_Topic8L4&5 4
Example: RK4
Problem :
dy
1 y x2 , y (0) 0.5
dx
Use RK 4 to find y (0.2), y (0.4)
CISE301_Topic8L4&5 5
4th Order Runge-Kutta RK4
k1 f ( xi , yi )
h 1
k2 f ( xi , yi k1h )
2 2
h 1
k3 f ( xi , yi k2h )
2 2
k4 f ( xi h, yi k3h )
1 1
k3 f ( x1 h, y1 k2h ) 1.9311
2 2
k4 f ( x1 h, y1 k3h ) 2.0555
y2 y1
0.2
k1 2k2 2k3 k4 1.2141
6
CISE301_Topic8L4&5 8
Example: RK4
Problem :
dy
1 y x2 , y (0) 0.5
dx
Use RK 4 to find y (0.2), y (0.4)