Chapter 1 Numerical Methods
Chapter 1 Numerical Methods
- Euler’s Method
- 2nd Order Runge-Kutta Method
- Separable Runge-
- Exact Euler’s
Kutta
- Homogeneous Method
Method
- Linear
- Bernoulli
1
BMCG 1013 Differential Equations
Formula:
𝑦𝑖+1 = 𝑦𝑖 + ℎ𝑓(𝑥𝑖 , 𝑦𝑖 )
2
BMCG 1013 Differential Equations
Example:
Use Euler’s method to numerically integrate
𝑑𝑦
+ 𝑦 = 3𝑥 3 − 7𝑥 2 + 5𝑥, 𝑦 0 =1
𝑑𝑥
from 𝑥 = 0 to 𝑥 = 2 with a step size of 0.5.
𝑥0 𝑥1 𝑥2 𝑥3 𝑥4
|| || || || ||
0 0.5 1.0 1.5 2.0
Let 𝑖 = 0,
𝑦1 = 𝑦0 + ℎ𝑓 𝑥0 , 𝑦0
= 1 + 0.5𝑓(0, 1)
= 1 + 0.5 3 0 3 − 7 0 2
+5 0 −1
[email protected]
= 0.5
3
BMCG 1013 Differential Equations
𝑥0 𝑥1 𝑥2 𝑥3 𝑥4
|| || || || ||
0 0.5 1.0 1.5 2.0
Let 𝑖 = 1,
𝑦2 = 𝑦1 + ℎ𝑓(𝑥1 , 𝑦1 )
= 0.5 + 0.5𝑓(0.5, 0.5)
= 0.5 + 0.5 3 0.5 3 − 7 0.5 2
+ 5 0.5 − 0.5
= 0.8125
[email protected]
𝑥0 𝑥1 𝑥2 𝑥3 𝑥4
|| || || || ||
0 0.5 1.0 1.5 2.0
Let 𝑖 = 2,
𝑦3 = 𝑦2 + ℎ𝑓(𝑥2 , 𝑦2 )
= 0.8125 + 0.5𝑓(1, 0.8125)
= 0.8125 + 0.5 3 1 3 − 7 1 2
+ 5 1 − 0.8125
= 0.9063
[email protected]
4
BMCG 1013 Differential Equations
𝑥0 𝑥1 𝑥2 𝑥3 𝑥4
|| || || || ||
0 0.5 1.0 1.5 2.0
Let 𝑖 = 3,
𝑦4 = 𝑦3 + ℎ𝑓(𝑥3 , 𝑦3 )
= 0.9063 + 0.5𝑓(1.5, 0.9063)
= 0.9063 + 0.5 3 1.5 3 − 7 1.5 2
+ 5 1.5 − 0.9063
= 1.3907
[email protected]
𝑥0 𝑥1 𝑥2 𝑥3 𝑥4
|| || || || ||
0 0.5 1.0 1.5 2.0
5
BMCG 1013 Differential Equations
𝑑𝑦
= 3𝑦 2 − 5𝑥 − 1, 𝑦 0 =0
𝑑𝑥
from 𝑥 = 0 to 𝑥 = 1 with a step size of 0.25.
6
BMCG 1013 Differential Equations
Example:
Use the second order Runge-Kutta method to numerically
integrate
𝑦 ′ − 𝑦 = −𝑥 2 , 𝑦 0 =0
from 𝑥 = 0 to 𝑥 = 2 with a step size of 0.5.
[email protected]
7
BMCG 1013 Differential Equations
𝑥0 𝑥1 𝑥2 𝑥3 𝑥4
|| || || || ||
0 0.5 1.0 1.5 2.0
Let 𝑖 = 0,
𝑘1 = 𝑓 𝑥0 , 𝑦0 = 𝑓 0, 0 1 2
𝑦1 = 𝑦0 + 𝑘1 + 𝑘2 ℎ
=0 3 3
1 2
3 3 = 0 + 3 0 + 3 −0.1406 (0.5)
𝑘2 = 𝑓 𝑥0 + ℎ, 𝑦0 + 𝑘1 ℎ = −0.0469
4 4
= 𝑓 0.375, 0
= −0.1406
[email protected]
𝑥0 𝑥1 𝑥2 𝑥3 𝑥4
|| || || || ||
0 0.5 1.0 1.5 2.0
Let 𝑖 = 1, 1 2
𝑦2 = 𝑦1 + 𝑘1 + 𝑘2 ℎ
𝑘1 = 𝑓 𝑥1 , 𝑦1 3 3
= 𝑓 0.5, −0.0469 = −0.0469
= −0.2969 1 2
+ −0.2969 + −0.9238 (0.5)
3 3
3 3 = −0.4043
𝑘2 = 𝑓 𝑥1 + ℎ, 𝑦1 + 𝑘1 ℎ
4 4
= 𝑓 0.875, −0.1582
= −0.9238
[email protected]
8
BMCG 1013 Differential Equations
𝑥0 𝑥1 𝑥2 𝑥3 𝑥4
|| || || || ||
0 0.5 1.0 1.5 2.0
Let 𝑖 = 2, 1 2
𝑦3 = 𝑦2 + 𝑘1 + 𝑘2 ℎ
𝑘1 = 𝑓 𝑥2 , 𝑦2 3 3
= 𝑓 1, −0.4043 = −0.4043
= −1.4043 1 2
+ 3 −1.4043 + 3 −2.8215 (0.5)
3 3 = −1.5789
𝑘2 = 𝑓 𝑥2 + ℎ, 𝑦2 + 𝑘1 ℎ
4 4
= 𝑓 1.375, −0.9309
= −2.8215
[email protected]
𝑥0 𝑥1 𝑥2 𝑥3 𝑥4
|| || || || ||
0 0.5 1.0 1.5 2.0
Let 𝑖 = 3, 1 2
𝑦4 = 𝑦3 + 𝑘1 + 𝑘2 ℎ
𝑘1 = 𝑓 𝑥3 , 𝑦3 3 3
= 𝑓 1.5, −1.5789 = −1.5789
= −3.8289 1 2
+ −3.8289 + −6.5303 (0.5)
3 3
3 3 = −4.3938
𝑘2 = 𝑓 𝑥3 + ℎ, 𝑦3 + 𝑘1 ℎ
4 4
= 𝑓 1.875, −3.0147
= −6.5303
[email protected]
9
BMCG 1013 Differential Equations
Exercise 1.8:
Use the second order Runge-Kutta method to numerically
integrate
𝑑𝑦
+ 𝑦 = sin 𝑥 , 𝑦 0 =1
𝑑𝑥
from 𝑥 = 0 to 𝑥 = 3 with a step size of ℎ = 1.
10