Sei sulla pagina 1di 4

Numerical Analysis / Civil Eng. / 3rd Class Prepared by: Dr.

Ahmed Sagban Saadoon

I-b- Solution of a set of 1st order ODEs


To solve a set of ordinary differential equations we can use the previous
methods (either Euler's or Runge-Kutta method).

Example : For the following set of ordinary differential equations, if at x  0 , y  4


and z  6 , then by one step of the 2nd order Runge-Kutta method, find
y and z at x  0.5 .
dy dz
 x  0.5 y  z ,  x  y  2z .
dx dx
Solution:
Let f ( x, y, z )  y  x  0.5 y  z (which is used to find y),
1

and f ( x, y, z )  z   x  y  2 z (which is used to find z).


2

From the start point x  0 to the end point x  0.5 , by one step, we need a step size
of h  0.5 .

- 55 -
Numerical Analysis / Civil Eng. / 3rd Class Prepared by: Dr. Ahmed Sagban Saadoon

By using the 2nd order Runge-Kutta method,


y j 1  y j  h.(k 2 )1 and z j 1  z j  h.(k 2 ) 2 where,
h h h
(k1 )1  f1 ( x j , y j , z j ) and (k 2 )1  f1 ( x j  , y j  (k1 )1 , z j  (k1 ) 2 ) .
2 2 2
h h h
(k1 ) 2  f 2 ( x j , y j , z j ) and (k 2 ) 2  f 2 ( x j  , y j  (k1 )1 , z j  (k1 ) 2 ) .
2 2 2
xj  0, y j  y( x j )  y(0)  4 , and z j  z ( x j )  z (0)  6 .
(k1 )1  f1 (0,4,6)  0  0.5(4)  6  4 ,
(k1 ) 2  f 2 (0,4,6)  0  4  2(6)  8 ,
0.5 0.5 0.5
(k 2 )1  f1 ((0  ), (4   4), (6   8))  f1 (0.25,5,8)  0.25  0.5(5)  8  5.75 ,
2 2 2
0.5 0.5 0.5
(k 2 ) 2  f 2 ((0  ), (4   4), (6   8))  f 2 (0.25,5,8)  0.25  5  2(8)  11 .25 ,
2 2 2
 y0.5  4  (0.5)(5.75)  6.875 , and
z0.5  6  (0.5)(11 .25)  11 .625 .

I-c- Solution of second order ODEs


To solve a 2nd order ordinary differential equations we can use either the
previous methods (but first we must transform the problem into a set of two 1 st order
ODEs.) or we use suitable finite differences approximations.

Example 1: Using h  0.1 , find y(0.1) to O(h) 2 if

d2y dy
 y  et , y(0)  1, (0)  0 .
dt 2 dt

Solution I: By using the 2nd order Runge-Kutta method which is of O(h) 2 .


We must first transform the problem into a set of two 1st order ODEs.
dy dz
Let z   y  et .
dt dt
Put f ( z )  y  z (which is used to find y),
1

and f (t , y )  z   y  e t (which is used to find z).


2

- 55 -
Numerical Analysis / Civil Eng. / 3rd Class Prepared by: Dr. Ahmed Sagban Saadoon

y j 1  y j  h.(k 2 )1 and z j 1  z j  h.(k 2 ) 2 where,


h h h
(k1 )1  f1 (t j , y j , z j ) and (k 2 )1  f1 (t j  , y j  (k1 )1 , z j  (k1 ) 2 ) .
2 2 2
h h h
(k1 ) 2  f 2 (t j , y j , z j ) and (k 2 ) 2  f 2 (t j  , y j  (k1 )1 , z j  (k1 ) 2 ) .
2 2 2
Since h  0.1 , then we need one step to move from the start point t  0 to the end
point t  0.1 .
dy
tj  0, y j  y(t j )  y(0)  1, and zj  (t j )  0 .
dt
(k1 )1  f1 (0,1,0)  0 ,

(k1 ) 2  f 2 (0,1,0)  1  e 0  2 ,
0.1 0.1 0.1
(k 2 )1  f1 ((0  ), (1   0), (0   2))  f1 (0.05,1,0.1)  0.1,
2 2 2
0.1 0.1 0.1
(k 2 ) 2  f 2 ((0  ), (1   0), (0   2))  f 2 (0.05,1,0.1)  1  e 0.05  2.051271 ,
2 2 2
 y0.1  1  (0.1)(0.1)  1.01 , and
z0.1  0  (0.1)(2.051271)  0.205127 . (Not required, representing the slope)

Solution II: By using the finite differences approximations:

For the given ODE, using central finite differences approximations of O(h) 2 we get,
f 2f  f
j 1 j 1
f  
j
, substituting this derivative into the given ODE yields,
j 2
h
y  2y  y t
j 1 j 1
 yj  e j ,
j

h2 0 0.1 0.2
t
 y j 1  (2  h 2 ) y j  y j 1  h 2 .e j .
At t j  0.1, (Note: from the first condition y0  y(0)  1)

y0  (2  0.12 ) y0.1  y0.2  (0.1) 2 .e 0.1   2.01y0.1  y0.2  0.988948 ……(1)


dy
For the second condition (0)  0 , using forward differences of O(h) 2 , we get
dt

- 55 -
Numerical Analysis / Civil Eng. / 3rd Class Prepared by: Dr. Ahmed Sagban Saadoon

3f  4f f
j 1 j  2
f , substituting into the 2nd condition yields:
j
j 2h
 3y  4 y y
0 0.1 0.2
0  4 y0.1  y0.2  3 ……(2)
2h
Adding Eqs. (1) and (2) gives: 1.99 y0.1  2.011052  y0.1  1.010579 .

- 55 -

Potrebbero piacerti anche