0% found this document useful (0 votes)
32 views9 pages

ODE - 4th Order Runge Kutta Method

Uploaded by

lsl
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
32 views9 pages

ODE - 4th Order Runge Kutta Method

Uploaded by

lsl
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

Solve Initial Value ODE Using

th
4 Order Runge-Kutta (RK) Method

1
Objectives

• Solve a First order ODE Using 4th Order Runge − Kutta RK Method
• Runge-Kutta methods are a family of single-point methods
• Runge-Kutta methods are explicit methods
• The Fourth − Order Runge − Kutta RK Method is a popular 4th order
method.

2
The Fourth − Order Runge − Kutta Method

• Consider a general nonlinear first order ODE of the form


• 𝑦 ′ = 𝑓 𝑡, 𝑦 , y(t0) = y0
1
• 𝑦𝑛+1 = 𝑦𝑛 + * Δ𝑦1 + 2 ∗ Δ𝑦2 + 2 ∗ Δ𝑦3 + Δ𝑦4
6

• Δ𝑦1 = ℎ ∗ 𝑓 𝑡𝑛 , 𝑦𝑛
ℎ Δ𝑦1
• Δ𝑦2 = ℎ ∗ 𝑓 𝑡𝑛 + ,𝑦 +
2 𝑛 2

ℎ Δ𝑦2
• Δ𝑦3 = ℎ ∗ 𝑓 𝑡𝑛 + , 𝑦𝑛 +
2 2

• Δ𝑦4 = ℎ ∗ 𝑓 𝑡𝑛 + ℎ, 𝑦𝑛 + Δ𝑦3
The Fourth − Order Runge − Kutta Method

• The (Finite Difference Equations) FDEs are explicit and require four derivative
function evaluations per step.

• The FDEs are consistent, 0(Δt5) locally and 0(Δt4) globally.

• The FDEs are conditionally stable (i.e., α Δt <= 2.785...).

• The FDEs are consistent and conditionally stable, and thus, convergent.

• Algorithms based on the repetitive application of Runge-Kutta FDEs are called


Runge-Kutta methods.
The Fourth − Order Runge − Kutta Method

• Example ODE Problem


𝑑𝑦
• = - 2 * 𝑥 3 + 12 * 𝑥 2 - 20 * 𝑥 + 8.5
𝑑𝑥

• From x = 0 to 4 with a step size of 0.5;

• The initial condition at x = 0 is y = 1.

• The exact solution is given as

• y = - 0.5 * 𝑥 4 + 4 * 𝑥 3 - 10 *𝑥 2 + 8.5 * 𝑥 + 1
The Fourth − Order Runge − Kutta Method

• fn = - 2 * 𝑥 3 + 12 * 𝑥 2 - 20 * 𝑥 + 8.5 ; y(x=0) = 1;
• Let n = 0;
• Δ𝑦1 = ℎ ∗ 𝑓 𝑡𝑛 , 𝑦𝑛 = ℎ ∗ 𝑓 𝑡0 , 𝑦0 = ℎ ∗ 𝑓 0,1
= 0.5 * (- 2 * 03 + 12 * 02 - 20 * 0 + 8.5) = 4.25
ℎ Δ𝑦1 0.5 Δ𝑦1
• Δ𝑦2 = ℎ ∗ 𝑓 𝑡𝑛 + , 𝑦𝑛 + = ℎ ∗ 𝑓 𝑡0 + , 𝑦0 +
2 2 2 2
Δ𝑦1
= ℎ ∗ 𝑓 0.25, 𝑦0 +
2

= 0.5 * (- 2 * 0.253 + 12 * 0.252 - 20 * 0.25 + 8.5)


= 0.5 * (- 0.03125 + 0.75 – 5 + 8.5) = 2.109375
The Fourth − Order Runge − Kutta Method

ℎ Δ𝑦2 0.5 Δ𝑦2


• Δ𝑦3 = ℎ ∗ 𝑓 𝑡𝑛 + ,𝑦 + = ℎ ∗ 𝑓 𝑡0 + , 𝑦0 +
2 𝑛 2 2 2

Δ𝑦2
= ℎ ∗ 𝑓 0.25, 𝑦0 + = 2.109375 (same as previous step)
2

• Δ𝑦4 = ℎ ∗ 𝑓 𝑡𝑛 + ℎ, 𝑦𝑛 + Δ𝑦3 = ℎ ∗ 𝑓 𝑡0 + 0.5, 𝑦0 + Δ𝑦3

= ℎ ∗ 𝑓 0.5, 𝑦0 + Δ𝑦3 = 0.5 * (- 2 * 0.53 + 12 * 0.52 - 20 * 0.5 + 8.5)

= 0.5 * (- 0.25 + 3 – 10 + 8.5) = 0.625


The Fourth − Order Runge − Kutta Method

1
• 𝑦𝑛+1 = 𝑦𝑛 + * Δ𝑦1 + 2 ∗ Δ𝑦2 + 2 ∗ Δ𝑦3 + Δ𝑦4
6

• Let n = 0
1
• 𝑦1 = 𝑦0 + * Δ𝑦1 + 2 ∗ Δ𝑦2 + 2 ∗ Δ𝑦3 + Δ𝑦4
6

1
• 𝑦1 = 1 + * 4.25 + 2 ∗ 2.109375 + 2 ∗ 2.109375 + 0.625
6

• 𝑦1 = 3.21875

• Likewise, y2, y3 etc can be evaluated


Summary
In this video,

• We presented the Fourth Order Runge-Kutta method to solve an Initial


Value ODE
• The Fourth Order Runge − Kutta method is conditionally stable.

• The global error is 0(Δt4).

• In the next video, we can look at a system of ODEs

You might also like