Download as pdf or txt
Download as pdf or txt
You are on page 1of 20

Runge-Kutta Order 4 th

Method for ODE

Sivaselvi K
Department of Mechanical Engineering,
Amrita Vishwa Vidyapeetham, Amritapuri
Introduction
Runge-Kutta (RK) methods is a numerical technique used to solve ordinary
differential equation of the form
Fourth-Order Runge-Kutta Method
The following is the most commonly used form, and we therefore call it the
classical fourth-order RK method:
1
𝑦𝑖+1 = 𝑦𝑖 + 𝑘1 + 2𝑘2 + 2𝑘3 + 𝑘4 ℎ
6
where
𝑘1 = 𝑓 𝑥𝑖, 𝑦𝑖
1 1
𝑘2 = 𝑓 𝑥𝑖 + ℎ, 𝑦𝑖 + 𝑘1 ℎ
2 2
1 1
𝑘3 = 𝑓 𝑥𝑖 + ℎ, 𝑦𝑖 + 𝑘2ℎ
2 2

𝑘4 = 𝑓 𝑥𝑖 + ℎ, 𝑦𝑖 + 𝑘3ℎ
Fourth-Order Runge-Kutta Method

Graphical depiction of the slope estimates comprising the fourth-order RK method.


Example
Solve the following initial value problem with initial condition y = 1 at x = 0. Using
fourth order RK method with h = 0.5.
𝑓 𝑥, 𝑦 = −2𝑥 3 + 12𝑥 2 − 20𝑥 + 8.5

Solution:
1
𝑦𝑖+1 = 𝑦𝑖 + 𝑘1 + 2𝑘2 + 2𝑘3 + 𝑘4 ℎ
6
𝑖 = 0, 𝑥𝑜 = 0, 𝑦0 = 1, ℎ = 0.5
𝑘1 = 𝑓 𝑥𝑖, 𝑦𝑖
= 𝑓 0,1
= −2(0)3 + 12(0)2 − 20(0) + 8.5
= 8.5
Example
1 1
𝑘2 = 𝑓 𝑥0 + ℎ, 𝑦0 + 𝑘1 ℎ
2 2
1 1
= 𝑓 0 + (0.5), 1 + (8.5)(0.5)
2 2

= 𝑓 0.25,3.125

= −2(0.25)3 + 12(0.25)2 − 20(0.25) + 8.5

= 4.21875
Example
1 1
𝑘3 = 𝑓 𝑥0 + ℎ, 𝑦0 + 𝑘2ℎ
2 2
1 1
= 𝑓 0 + (0.5), 1 + (4.21875)(0.5)
2 2

= 𝑓 0.25,2.055

= −2(0.25)3 + 12(0.25)2 − 20(0.25) + 8.5

= 4.21875
Example
𝑘4 = 𝑓 𝑥0 + ℎ, 𝑦0 + 𝑘3 ℎ

= 𝑓 0 + 0.5,1 + (4.21875)(0.5)

= 𝑓 0.5,3.1094

= −2(0.5)3 + 12(0.5)2 − 20(0.5) + 8.5

= 1.25
1
𝑦1 = 𝑦0 + 𝑘1 + 2𝑘2 + 2𝑘3 + 𝑘4 ℎ
6
1
= 1 + 8.5 + 2(4.21875) + 2(4.21875) + 1.25 0.5
6
𝑦(0.5) = 3.21875
Example
A ball at 1200K is allowed to cool down in air at an ambient temperature of 300K.
Assuming heat is lost only due to radiation, the differential equation for the
temperature of the ball is given by
𝑑𝜃
= −2.2067 × 10−12 (𝜃 4 − 81 × 108)
𝑑𝑡
where θ is in K and t in seconds. Find the temperature at t = 480 seconds using
Runge-Kutta 4th order method. Assume a step size of h = 240 seconds

Solution:
𝑑𝜃
= −2.2067 × 10−12 (𝜃 4 − 81 × 108)
𝑑𝑡
𝑓(𝑡, 𝜃) = −2.2067 × 10−12 (𝜃 4 − 81 × 108)
Example
1
𝜃𝑖+1 = 𝜃𝑖 + 𝑘1 + 2𝑘2 + 2𝑘3 + 𝑘4 ℎ
6
𝑖 = 0, 𝑡𝑜 = 0, 𝜃0 = 1200

𝑘1 = 𝑓 𝑡0, 𝜃0

= 𝑓 0,1200

= −2.2067 × 10−12(12004 − 81 × 108)

= −4.5579
Example
1 1
𝑘2 = 𝑓 𝑡0 + ℎ, 𝜃0 + 𝑘1ℎ
2 2
1 1
= 𝑓 0 + (240), 1200 + (−4.5579)(240)
2 2

= 𝑓 120,653.05

= −2.2067 × 10−12(653.054 − 81 × 108)

= −0.38347
Example
1 1
𝑘3 = 𝑓 𝑡0 + ℎ, 𝜃0 + 𝑘2 ℎ
2 2
1 1
= 𝑓 0 + (240), 1200 + (−0.38347)(240)
2 2

= 𝑓 120,1154.0

= −2.2067 × 10−12(1154.04 − 81 × 108)

= −3.8954
Example
𝑘4 = 𝑓 𝑡0 + ℎ, 𝜃0 + 𝑘3 ℎ

= 𝑓 0 + 240,1200 + (−3.894)(240)

= 𝑓 240,265.10

= −2.2067 × 10−12(265.104 − 81 × 108)

= 0.0069750
Example
1
𝜃1 = 𝜃0 + 𝑘1 + 2𝑘2 + 2𝑘3 + 𝑘4 ℎ
6
1
= 1200 + −4.5579 + 2(−0.38347) + 2(−3.8954) + 0.0069750 240
6

= 1200 + (−2.1848) × 240

= 675.65 𝐾
Example
𝑖 = 1, 𝑡1 = 240, 𝜃1 = 675.65 𝐾

𝑘1 = 𝑓 𝑡1, 𝜃1

= 𝑓 240,675.65

= −2.2067 × 10−12(675.654 − 81 × 108)

= −0.44199
Example
1 1
𝑘2 = 𝑓 𝑡1 + ℎ, 𝜃1 + 𝑘1 ℎ
2 2
1 1
= 𝑓 240 + (240), 675.65 + (−0.44199)(240)
2 2

= 𝑓 360, 622.61

= −2.2067 × 10−12(622.614 − 81 × 108)

= −0.31372
Example
1 1
𝑘3 = 𝑓 𝑡1 + ℎ, 𝜃1 + 𝑘2ℎ
2 2
1 1
= 𝑓 240 + (240), 675.65 + (−0.31372)(240)
2 2

= 𝑓 360,638.00

= −2.2067 × 10−12(638.004 − 81 × 108)

= −0.34775
Example
𝑘4 = 𝑓 𝑡1 + ℎ, 𝜃1 + 𝑘3ℎ

= 𝑓 240 + 240,675.65 + (−0.34775)(240)

= 𝑓 480,592.19

= −2.2067 × 10−12(592.194 − 81 × 108)

= −0.25351
Example
1
𝜃2 = 𝜃1 + 𝑘1 + 2𝑘2 + 2𝑘3 + 𝑘4 ℎ
6
1
= 675.65 + −0.44199 + 2(−0.31372) + 2(−0.34775) + (−0.25251) 240
6

1
= 675.65 + (−2.0184) × 240
6

= 594.91 𝐾
References
• Steven Chapra and Raymond Canale – ‘Numerical Methods for Engineers’ -
McGraw Hill - 2009 - 6th Edition
• Autar K Kaw – ‘Numerical Methods with Applications’ - Second Edition, 2010

You might also like