Академический Документы
Профессиональный Документы
Культура Документы
DIFFERENTIAL EQUATIONS
A. J. Clark School of Engineering Department of Civil and Environmental Engineering
by
ENCE 203 - Computation Methods in Civil Engineering II Department of Civil and Environmental Engineering University of Maryland, College Park
Fundamental Case
Assume that the problem is a first-order differential equation of the form
dy = f (x ) dx subject to y = y0 at x = x0 (5)
If the variables are separated and the integration is carried out on both sides, then y x (6) dy = f (x )dx
y0 x0
Assakkaf
Slide No. 22
Fundamental Case
Or
yy =
0
x0
f (x ) dx
x0
y y0 =
f (x ) dx
x
y ( x) = y0 + f (x ) dx
x0
ENCE 203 CHAPTER 8b. DIFFERENTIAL EQUATIONS
(7)
Assakkaf
Slide No. 23
Fundamental Case
Recall Taylors Series Expansion
h 2 (2 ) h 3 (3 ) h n (n ) f (x0 ) + f (x0 ) + ... + f (x0 ) + Rn +1 2! 3! n!
where x0 = base value or starting value x = the point at which the value of the function is needed h = x x0 = distance between x0 and x (step size) n! = factorial of n = n(n-1) (n 2)1 f(n) = indicates the nth derivative of the function f(x) Rn+1 = the remainder of Taylor series expansion
ENCE 203 CHAPTER 8b. DIFFERENTIAL EQUATIONS
(8)
Assakkaf
Slide No. 24
Fundamental Case
(x x0 )2 g (x ) 0
2!
(x x0 ) +
Or
3!
dy y (x ) = y0 + (x x0 ) dx + 3!
(9a)
g (x0 ) + L
+
(x x0 )2
2! +L
x = x0
x = x0 3
d2y dx 2
x = x0
(x x0 )
d y dx 3
(9b)
Assakkaf
Slide No. 25
Fundamental Case
Taylors Series Expansion
Comparing Eq. 9b and Eq. 7, we can evaluate the integral of Eq. 7 by a Taylor Series Expansion: 2 3 ( ( dy x x0 ) d 2 y x x0 ) d 3 y + + +L y (x ) = y0 + (x x0 ) dx x = x0 2! dx 2 x = x 3! dx 3 x = x
y ( x) = y0 + f (x )
x0
Assakkaf
Slide No. 26
Fundamental Case
Taylors Series Expansion
In view of the integral of the second equation, the comparison implies that
x0
f (x ) = (x x0 )
dy dx
+
x = x0
(x x0 )2 d 2 y
2! dx 2
x = x0
(x x0 )3 d 3 y
3! dx 3
x = x0
+L
Slide No. 27
x0 = 1 y0 = 1
Slide No. 28
dx
x = x0
2!
dx 2
x = x0
3!
dx 3
x = x0
y (x ) = 1 + (x 1) 3 x
2 0
2 3 x 1) x 1) ( ( (6 x0 ) + (6) )+
Assakkaf
Slide No. 29
y (x ) = 1 + (x 1)(3) + 3(x 1) + (x 1)
2
Assakkaf
Slide No. 30
One Term 1 1 1 1 1 1 1 1 1 1 1
Two Terms 1 1.3 1.6 1.9 2.2 2.5 2.8 3.1 3.4 3.7 4
y (x ) Three Terms 1 1.33 1.72 2.17 2.68 3.25 3.88 4.57 5.32 6.13 7
Four Terms 1 1.331 1.728 2.197 2.744 3.375 4.096 4.913 5.832 6.859 8
Assakkaf
Slide No. 31
Example 1(contd)
The exact solution can be obtained as follows:
y
dy = 3x dx
2 1 1 x 3x 3 y 1 = = x3 1 3 1 x
y 1 = x3 1 y = x3
Assakkaf
Slide No. 32
Example 1(contd)
One Term 1 1 1 1 1 1 1 1 1 1 1 Two Terms 1 1.3 1.6 1.9 2.2 2.5 2.8 3.1 3.4 3.7 4
y = x3
Four Terms 1 1.331 1.728 2.197 2.744 3.375 4.096 4.913 5.832 6.859 8 TRUE 1 1.331 1.728 2.197 2.744 3.375 4.096 4.913 5.832 6.859 8
Assakkaf
y (x ) Three Terms 1 1.33 1.72 2.17 2.68 3.25 3.88 4.57 5.32 6.13 7
Slide No. 33
Slide No. 34
General Case
Assume that the problem is a first-order ordinary differential equation of the following form:
dy = f (x, y ) dx subject to y = y0 at x = x0
g (x ) = g (x0 , y0 ) + (x x0 )g (x0 , y0 ) + 3!
(x x0 )3 g (x , y ) + L + 0 0
ENCE 203 CHAPTER 8b. DIFFERENTIAL EQUATIONS
(10)
Assakkaf
Slide No. 35
General Case
Or in equivalent form, Taylor series can be given as
dy y (x, y ) = y0 + (x x0 ) dx + 3! +
(x x0 )2
2! +L
x = x0 y = y0
d2y dx 2
x = x0 y = y0
(x x0 )3 d 3 y
dx
3 x = x0 y = y0
(11)
Assakkaf
Slide No. 36
x0 = 1 y0 = 1
Slide No. 37
= 15
d3y dx 3
x0 =1 y0 =1
= 87
Assakkaf
Slide No. 38
(x x0 )2
2!
d2y dx 2
x = x0 y = y0
(x x0 )3 d 3 y
3! dx 3
x = x0 y = y0
Assakkaf
Slide No. 39
Assakkaf
Slide No. 40
10
y (x ) One Term Two Terms Three Terms 1 1 1 1 1.3 1.375 1 1.6 1.9 1 1.9 2.575 1 2.2 3.4 1 2.5 4.375 1 2.8 5.5 1 3.1 6.775 1 3.4 8.2 1 3.7 9.775 1 4 11.5
Four Terms 1 1.3895 2.016 2.9665 4.328 6.1875 8.632 11.7485 15.624 20.3455 26
Assakkaf
Slide No. 41
Example 2 (contd)
The exact solution can be obtained as follows:
dy dy = 3x 2 y = 3x 2 dx dx y 1 1 0 x x 3x3 ln y ln 1 = = x3 1 3 1 ln y = x 3 1 y = ex
3
1
Assakkaf
Slide No. 42
11
y (x ) One Term Two Terms Three Terms 1 1 1 1 1.3 1.375 1 1.6 1.9 1 1.9 2.575 1 2.2 3.4 1 2.5 4.375 1 2.8 5.5 1 3.1 6.775 1 3.4 8.2 1 3.7 9.775 1 4 11.5
Four Terms 1 1.390 2.016 2.967 4.328 6.188 8.632 11.749 15.624 20.346 26.000
TRUE 1 1.392 2.071 3.310 5.720 10.751 22.109 50.049 125.462 350.374 1096.633
Assakkaf
Slide No. 43
Slide No. 44
12
Eulers Method
As we noticed in the previous example, in some cases the derivatives are not easily computed. Therefore, the Taylor series of Eqs. 9, 10, and 11 can be truncated so that only the term with the first derivative is used.
Assakkaf
Slide No. 45
Eulers Method
The value of the dependent variable y = g(x) can be computed using
g (x ) = g (x0 , y0 ) + (x x0 )g (x0 , y0 ) + e or dy y (x ) = y0 + (x x0 ) dx
x = x0 y = y0
(12a) (12b)
+e
Assakkaf
Slide No. 46
13
Eulers Method
For better accuracy, (x x0) should be made small. Notice that (x x0) = x = h The above equations can be rewritten in a more compact form for computer implementation as
yi +1 = yi + hf (xi , yi )
Assakkaf
Slide No. 47
Eulers Method
The iterative procedure for basic Eulers method is given by
yi +1 = yi + hf (xi , yi )
where
h = x x0 f (x0 , y0 ) = g (x0 , y0 ) =
ENCE 203 CHAPTER 8b. DIFFERENTIAL EQUATIONS
(13)
dy dx
x = x0 y = y0
Assakkaf
Slide No. 48
14
Here we have
y (0 ) = 1
ENCE 203 CHAPTER 8b. DIFFERENTIAL EQUATIONS
or
x0 = 0 y0 = 1
Assakkaf
Slide No. 49
1 1 1 y = (1) = 2 2 2
Slide No. 50
15
1 1 y = (1.05) = 0.5250 2 2
Slide No. 51
1 1 y = (1.1025) = 0.55125 2 2
Slide No. 52
16
ln 1 = 0
ln y ln 1 =
x
1 (x x0 ) ln y = 1 x 2 2
y = e2
Assakkaf
Slide No. 53
f (x i , y i ) 0.5 0.525000 0.551250 0.578813 0.607753 0.638141 0.670048 0.703550 0.738728 0.775664 0.814447
y (Euler) 1.050000 1.102500 1.157625 1.215506 1.276282 1.340096 1.407100 1.477455 1.551328 1.628895
y (True) % Error 1 1.051271 0.12 1.105171 0.24 1.161834 0.36 1.221403 0.48 1.284025 0.60 1.349859 0.72 1.419068 0.84 1.491825 0.96 1.568312 1.08 1.648721 1.20
True Function : y = e 2
Assakkaf
Slide No. 54
17
dy = 3x 2 dx
such that y = 1 at x = 1
y (1) = 1 or x0 = 1 y0 = 1
Assakkaf
Slide No. 55
= 3x 2 = 3(1) = 3
2
Slide No. 56
18
= 3x 2 = 3(1.1) = 3.630
2
Slide No. 57
= 3 x 2 = 3(1.2) = 4.320
2
Slide No. 58
19
dy = 3x dx
2 1 1
x0 = 1
y0 = 1
x 1
y 1 =
3x 3
3 x
= x3
y 1 = x3 1 y = x3
Assakkaf
Slide No. 59
i 0 1 2 3 4 5 6 7 8 9 10
True Function : y = x 3
Assakkaf
Slide No. 60
20