0% found this document useful (0 votes)
25 views49 pages

Chapter 5 ODE

Chapter 5 discusses numerical methods for solving ordinary differential equations (ODEs), focusing on Euler and Runge-Kutta methods. It provides detailed examples of applying these methods to both simultaneous and higher-order differential equations. The chapter emphasizes the use of truncated Taylor series expansions as a foundation for these numerical techniques.

Uploaded by

gooorr66
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)
25 views49 pages

Chapter 5 ODE

Chapter 5 discusses numerical methods for solving ordinary differential equations (ODEs), focusing on Euler and Runge-Kutta methods. It provides detailed examples of applying these methods to both simultaneous and higher-order differential equations. The chapter emphasizes the use of truncated Taylor series expansions as a foundation for these numerical techniques.

Uploaded by

gooorr66
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

Chapter 5: Numerical Methods for Solving

Ordinary Differential Equations

Slides designed by Medhat Helal

1
Numerical Solutions
 Numerical method are used to obtain a graph or a
table of the unknown function
 Most of the Numerical methods used to solve ODE are
based directly (or indirectly) on truncated Taylor series
expansion
 Methods:
 Euler methods
 Runge-Kutta methods

2
Euler Method
y2

y1
am
y0 jog
x0 x1 x2 x

3
Euler Method

Slope=y’(x0,y0)
y1 y1=y0+hy’ (x0,y0)
hy’(x0,y0)
y0

x0 x1 x2 x
h

4
Euler Method
y2 y2=y1+hy’(x1,y1)
Slope=y’(x1,y1)
hy’(x1,y1)
Slope=y’(x0,y0)
y1 y1=y0+hy’(x0,y0)
hy’(x0,y0)
y0

x0 x1 x2 x
h h

5
1. Euler’s Method

6
1. Euler’s Method

7
8
9
u

10
11
12
13
14
15
16
𝑎𝑡 𝑥 = 1.2

𝑥 = 1. 1 𝑦 = 1.2 ℎ = 1.2 − 1.1 = 0.1

𝑦′ = 2.2

𝑦 = 𝑦 + ℎ𝑦′(𝑥 , 𝑦 )

𝑦 = 1.2 + 0.1 ∗ 2.2 = 1.42

17
18
19
20
21
22
Runge-Kutta Methods

23
Rung-Kutta Method
Slope=y’(x0+h,y0+h)

y1
Slope=y’(x0+h/2,y0+h/2)
y0

Slope=y’(x0,y0)

x0 x1 x2 x
h

24
Runge-Kutta Methods

25
26
27
28
29
30
31
32
33
Unit-5
Numerical Solution of
O.D.E

1
Application of Euler’s method to
simultaneous differential equations
Assume

= 𝑓 (𝑡, 𝑥, 𝑦), 𝑥(𝑡 ) = 𝑥

= 𝑓 (𝑡, 𝑥, 𝑦), 𝑦(𝑡 ) = 𝑦

Euler's method tabulates 𝑥(𝑡) and 𝑦(𝑡) according to

𝑥 = 𝑥 + ℎ𝑓 (𝑡 , 𝑥 , 𝑦 )

𝑦 = 𝑦 + ℎ𝑓 (𝑡 , 𝑥 , 𝑦 )
where 𝑛 = 0,1,2, . . .

2 2
Example
Use Euler’s method to calculate x and y at 𝑡 = 0.1 and 0.3 of

= 2𝑥 + 𝑦 − 𝑡, 𝑥(0) = 1

= 𝑥 − 2𝑦 + 𝑡, 𝑦(0) = 2

Solution :

𝑓 (𝑡, 𝑥, 𝑦) = 2𝑥 + 𝑦 − 𝑡
𝑓 (𝑡, 𝑥, 𝑦) = 𝑥 − 2𝑦 + 𝑡

3 3
at 𝑡 = 0.1:

𝑡 = 0, 𝑥 = 1, 𝑦 =2

ℎ = 0.1 − 0 = 0.1

∵ 𝑥 = 𝑥 + ℎ𝑓 (𝑡 , 𝑥 , 𝑦 )

∴ 𝑥 = 1 + 0.1 ∗ (2 + 4 − 0) = 1.6

∵ 𝑦 = 𝑦 + ℎ𝑓 (𝑡 , 𝑥 , 𝑦 )

∴ 𝑦 = 2 + 0.1 ∗ (1 − 4 + 0) = 1.7

4 4
at 𝑡 = 0.3:

𝑡 = 0.1, 𝑥 = 1.6, 𝑦 = 1.7

ℎ = 0.3 − 0.1 = 0.2

∵ 𝑥 = 𝑥 + ℎ𝑓 (𝑡 , 𝑥 , 𝑦 )

∴ 𝑥 = 1.6 + 0.2 ∗ (3.2 + 2.89 − 0.1) = 2.798

∵ 𝑦 = 𝑦 + ℎ𝑓 (𝑡 , 𝑥 , 𝑦 )

∴ 𝑦 = 1.7 + 0.2 ∗ 2.56 − 3.4 + 0.1 = 1.552

5 5
Application of Euler’s method to Higher
Order Ordinary Differential Equations

The problem appears as follows:

𝑦 = f (x, y, y/); y(x0) = y0 and y/(x0) = y/0 .

The Euler method starts by letting,

y/ = z. then 𝑦 = 𝑧

This assumption results in a two simultaneous equation of

first order.

6 6
Example
Use Euler’s method to find y at 𝑥 = 0.2, and 0.4 if
𝑦 = 4𝑦𝑦 + 𝑥𝑦 and 𝑦 = 2, 𝑦 = 1 at 𝑥 = 0.1

Solution :

Put 𝑦 = 𝑧

Then 𝑧 = 4𝑦𝑧 + 𝑥𝑦

𝑓 (𝑥, 𝑦, 𝑧) = 𝑧

𝑓 (𝑥, 𝑦, 𝑧) = 4𝑦𝑧 + 𝑥𝑦

7 7
at 𝑥 = 0.2:

𝑥 = 0.1, 𝑦 = 2, 𝑧 =1

ℎ = 0.2 − 0.1 = 0.1

∵ 𝑦 = 𝑦 + ℎ𝑓 (𝑥 , 𝑦 , 𝑧 )

𝑧 = 𝑧 + ℎ𝑓 (𝑥 , 𝑦 , 𝑧 )

∴ 𝑦 = 2 + 0.1 ∗ (1) = 2.1

𝑧 = 1 + 0.1 ∗ (4(2)(1) + 0.1(2)) = 1.82

8 8
at 𝑥 = 0.4:

𝑥 = 0.2, 𝑦 = 2.1, 𝑧 = 1.82

ℎ = 0.4 − 0.2 = 0.2

∵ 𝑦 = 𝑦 + ℎ𝑓 (𝑥 , 𝑦 , 𝑧 )

𝑧 = 𝑧 + ℎ𝑓 (𝑥 , 𝑦 , 𝑧 )

∴ 𝑦 = 2.1 + 0.2(1.82) = 2.464

𝑧 = 1.82 + 0.2 4 2.1 1.82 + 0.2 2.1 = 4.9616

9 9
Application of Runge-Kutta’s method to
simultaneous differential equations
Given

= 𝑓 (𝑡, 𝑥, 𝑦), 𝑥(𝑡 ) = 𝑥

= 𝑓 (𝑡, 𝑥, 𝑦), 𝑦(𝑡 ) = 𝑦

Runge-Kutta,s method tabulates 𝑥(𝑡 ) and 𝑦(𝑡 ) as follows

𝑥 =𝑥 + 𝑘 + 2(𝑘 + 𝑘 ) + 𝑘 ,

𝑦 =𝑦 + 𝐿 + 2(𝐿 + 𝐿 ) + 𝐿 ,

10 10
where
𝑘 = ℎ𝑓 (𝑡 , 𝑥 , 𝑦 ),

𝐿 = ℎ𝑓 (𝑡 , 𝑥 , 𝑦 ),

𝑘 = ℎ𝑓 (𝑡 + , 𝑥 + , 𝑦 + ),

𝐿 = ℎ𝑓 (𝑡 + , 𝑥 + , 𝑦 + ),

𝑘 = ℎ𝑓 (𝑡 + , 𝑥 + , 𝑦 + ),

𝐿 = ℎ𝑓 (𝑡 + , 𝑥 + , 𝑦 + ),

𝑘 = ℎ𝑓 (𝑡 + ℎ, 𝑥 + 𝑘 , 𝑦 + 𝐿 ),

𝐿 = ℎ𝑓 (𝑡 + ℎ, 𝑥 + 𝑘 , 𝑦 + 𝐿 ),
11 11
Example
Use Runge-Kutta’s method to find 𝑥(0.2) and 𝑦(0.2) if

= 𝑥 + 𝑦 + 5𝑡, 𝑥(0) = 2,

= 𝑥 + 𝑦 − 6𝑡, 𝑦(0) = 3,

Solution :

𝑓 (𝑡, 𝑥, 𝑦) = 𝑥 + 𝑦 + 5𝑡
𝑓 (𝑡, 𝑥, 𝑦) = 𝑥 + 𝑦 − 6𝑡

12 12
at 𝑡 = 0.2:
𝑡 = 0, 𝑥 = 2, 𝑦 =3
ℎ = 0.2 − 0 = 0.2
𝑘 = 0.2[4 + 3 + 0] = 1.4,

𝐿 = 0.2[2 + 9 − 0] = 2.2,
𝑘 = 0.2[(2.7) + 4.1 + 0.5] = 2.378,

𝐿 = 0.2[2.7 + (4.1) − 0.6] = 3.782,


𝑘 = 0.2[(3.189) + 4.891 + 0.5] = 3.11214,

𝐿 = 0.2[3.189 + (4.891) − 0.6] = 5.3021762,


𝑘 = 0.2[(5.1121442) + 8.3021762 + 1] = 7.087238,

𝐿 = 0.2[5.1121442 + (8.3021762) − 1.2] = 14.567655,


13 13
Therefore,

1
𝑥 = 2 + [1.4 + 2(2.378 + 3.11214) + 7.087238]
6

= 5.2445879

1
𝑦 = 3 + [2.2 + 2(3.782 + 5.3021762) + 14.567655]
6

= 8.8226679

14 14
Example
Find y (0.07) and y/ (0.07). Given,
y// = 9 cos x + e-x , y (0)=-1 and y/ (0)=1

Solution :
Let y/ = z
 z/ = 9 cos x + e-x
y (0) = -1, z (0) = 1

𝑓 (𝑥, 𝑦, 𝑧) = z
𝑓 (𝑥, 𝑦, 𝑧) = 9 cos x +e−x

15 15
At x1 = 0.07
𝑥 = 0, 𝑦 = −1, 𝑧 =1
h = 0.07 - 0 = 0.07

k1=0.07 (1) = 0.07 L1=0.07 (9cos 0.0+e-0.0) = 0.7


k2=0.07 (1.35)=0.0945 L2=0.07 (9cos (0.035)+e-0.035)
=0.6972
k3=0.07(1.3486)=0.0944 L3=0.07(9cos (0.035)+e-035)= 0.6972
k4=0.07(1.6972)=0.1188 L4=0.07 (9cos (0.07)+e-0.07)=0.6937
y1=-1+(0.07+2(0.0945 z1 = y/1=1+ (0.7+2 (0.6972+ 0.6972)
+0.0944)+0.1188)/6 +0.6937)/6
y1= -0.905567 z1=1.697083

16 16

You might also like