NUMERICAL SOLUTION OF O.D.E

advertisement
Department of Engineering Mathematics and
Physics, Faculty of Engineering
Zagazig University
2009-2010
Numerical solution of linear equations.
Numerical solution of non linear equations.
Numerical integrations.
Curve fitting.
Numerical solution of ordinary differential equations.
Numerical solution of partial differential equations.
Next
The Main Menu
‫ا‬Previous
Numerical ordinary differential equations is the part of numerical
analysis which studies the numerical solution of ordinary differential
equations (ODEs). It is very important for industrial and practical
engineering applications , Mechanics, Chemistry and Physics.
Boundary value problem
It is an ordinary differential equation which satisfies the boundary
conditions. A boundary value problem has conditions specified at the
extremes of the independent variable
Initial value problem
It is an ordinary differential equation together with specified value, called
the initial condition, of the unknown function at a given point in the
. domain of the solution. Initial value problem has all of the conditions
specified at the same value of the independent variable in the equation and
that value is at the lower boundary of the domain
Next
The Main Menu
‫ا‬Previous
It is a numerical methods for solving ordinary differential
equations (O.D.Es) with a given conditions.
y\ = f(x, y),
y(x0) = y0.
Taylor series expansion of the function f(x) around a point of expansion x
has the following form:
2
y(x)  y(x 0 ) 
(x  x 0 )
(x  x 0 )
y(x 0 ) 
y(x 0 )  .......
1!
2!
Assume h = x – x0
2
3
h
h
h
Hint:
 y(x 0  h)  y(x 0 )  y(x 0 )  y(x 0 )  y(x 0 )  .......
1!
2!
3!
1- When the step h becomes small, the numerical solution becomes nearly
the same as the exact solution.
2- y = f(x).
3- computing approximate values of the solution f(x) at the points:
x1 = x0 +h, x2 = x0 +2h, x3 = x0 + 3h,…………….
 y1  y(x 0  h), y 2  y(x 1  h), y3  y(x 2  h),....... ...
Next
The Main Menu
‫ا‬Previous
Solve the following boundary value problem y\ = - y at x = 0.2, 0.4 given
that y(0) = 1
Taylor expansion given by:
h
h2
h3
y(x 0  h)  y(x 0 )  y(x 0 )  y(x 0 )  y(x 0 )  .......
1!
2!
3!
Consider the point of expansion zero
 h  x  x0  0.2  0  0.2
Evaluate the derivatives at the point of expansion zero
y(x)   y  y(x 0 )   y(x 0 )  1,
Then
y(x)   y(x)  y(x 0 )   y(x 0 )  1,
y(x)   y(x)  y(x 0 )   y(x 0 )  1,
0.2
(0.2) 2
(0.2)3
y (0.2)  y (0  0.2)  1 
(1) 
(1) 
(1)  .......  0.81867
1!
2!
3!
0.2
(0.2) 2
(0.2)3
y(0.4)  y (0.2  0.2)  0.81867 
(0.81867) 
(0.81867) 
(0.81867)  .......  0.67022
1!
2!
3!
Next
The Main Menu
‫ا‬Previous
It is a first-order numerical procedure for solving ordinary
differential equations (O.D.Es) with a given conditions .
y\ = f(x, y), y(x0) = y0.
The general Euler formula for solving boundary value problem is:
yn 1  yn  hf(x n , yn )
Hint:
Assume h = xn+1 – xn
1- When the step h becomes small, the numerical solution becomes nearly
the same as the exact solution.
2- y = f(x).
3- computing approximate values of the solution f(x) at the points:
x1 = x0 +h, x2 = x0 +2h, x3 = x0 + 3h,…………….
 y1  y(x 0  h), y 2  y(x 0  2 h), y3  y(x 0  3 h),....... ...
i.e. y1  y(x 0  h), y 2  y(x 1  h), y3  y(x 2  h),....... ...
Next
The Main Menu
‫ا‬Previous
Solve the following boundary value problem y\= x2 + y at x = 0.02, 0.04,
0.06 and 0.08 given that y(0) = 1 .
General Euler formula given by:
yn 1  yn  hf(x n , yn )
 y n 1  y n  h[x 2n  y n ]
 h  x n 1  x n
For n = 1
 h  0.04  0.02  0.02  x1  0.02, x 2  0.04
Then
y 2  y1  hf(x 1 , y1 )  1.02  0.02((0.02) 2  1.02)  1.0404
For n = 0
 h  0.02  0  0.02  x 0  0, x1  0.02
Then
y1  y 0  hf(x 0 , y 0 )  1  0.02(02  1)  1.02
Next
The Main Menu
‫ا‬Previous
For n = 2
 h  0.06  0.04  0.02  x 2  0.04, x 3  0.06
Then
y3  y 2  hf(x 2 , y 2 )  1.0404  0.02((0.04) 2  1.0404)  1.0612
For n = 3
 h  0.08  0.06  0.02  x 3  0.06, x 4  0.08
Then
y 4  y3  hf(x 3 , y3 )  1.0612  0.02((0.06) 2  1.0612)  1.0825
For n = 4
 h  1.00  0.08  0.02  x 4  0.08, x 5  1.00
Then
y 4  y3  hf(x 3 , y3 )  1.0825  0.02((0.08) 2  1.0825)  1.1043
Next
The Main Menu
‫ا‬Previous
We can put the results in a table:
n
Next
xn
yn
yn+1
0
0.00
1.000
1.0200
1
0.02
1.0200
1.0404
2
0.04
1.0404
1.0612
3
0.06
1.0612
1.0825
4
0.08
1.0825
1.1043
The Main Menu
‫ا‬Previous
This method tries to improve the error of Euler method.
The general modified Euler formula for solving boundary value problem
is:
i 1
y n 1


h
 y n  f(x n , y n )  f(x n 1 , yin 1 ) , i  0,1,2,....
2
and y0n 1  y n  hf(x n , y n ) Euler method
This method is an iterative method, starts by getting y01 using Euler
method. Then we calculate f (xn+1,y0n+1 ). Then determine y11. After that
we use y11 to get the new value y21 and so on. The solution is terminated
after a certain number of steps or certain accuracy required.
Next
The Main Menu
‫ا‬Previous
Find y(0.1) and y(0.2), if y\ = y – x , y(0)= 2, take h = 0.1, three
decimal places are required
To get y1 = y(0.1)
y10  y 0  hf(x 0 , y 0 )  2  0.1(2  0)  2.2
h
0.1
0
y  y 0  [f(x 0 , y 0 )  f(x 1 , y1 )]  2 
[( 2  0)  (2.2  0.1)]  2.205
2
2
h
0.1
y12  y 0  [f(x 0 , y 0 )  f(x 1 , y11 )]  2 
[( 2  0)  (2.205  0.1)]  2.20525
2
2
Then y(0.1) = 2.205
To get y2 = y(0.2)
y12  y1  hf(x 1 , y1 )  2.205  0.1(2.205  0.1)  2.416
h
0.1
1
0
y 2  y1  [f(x 1 , y1 )  f(x 2 , y 2 )]  2.205 
[( 2.205  0.1)  (2.416  0.2)]  2.42105
2
2
h
0.1
2
1
y 2  y1  [f(x 1 , y1 )  f(x 2 , y 2 )]  2.205 
[( 2.205  0.1)  (2.421  0.2)]  2.4213
2
2
Then y(0.2) = 2.241
‫ا‬Previous
The Main Menu
1
1
Next
The accuracy of this method is equivalent to five terms of Talyor’s
series.
The general Rung- kutta formula for solving boundary value problem is:
y n 1
where
k1  2(k 2  k 3 )  k 4
 yn 
.
6
k1  hf(x n , yn )
h
k 

k 2  hf (x n  ), (y n  1 )
2
2 

h
k2 

k 3  hf (x n  ), (y n  )
2
2 

k 4  hf (x n  h), (y n  k 3 )
Next
The Main Menu
‫ا‬Previous
Find y(0.1) and y(0.2), if y\ = y – x , y(0)= 2, take h = 0.1, four
decimal places are required
To get y1 = y(0.1)
k1  hf(x n , yn )  0.1(2  0)  0.2
h
k 

k 2  hf (x n  ), (y n  1 )  0.1(2.1  0.05)  0.205
2
2 

h
k2 

k 3  hf (x n  ), (y n  )  0.1(2.1025  0.05)  0.2053
2
2 

k 4  hf (x n , h), (y n , k 3 )  0.1(2.2053  0.1)  0.2105
k1  2(k 2  k 3 )  k 4
 y 1  y0 
6
0.2  2(0.205  0.2053)  0.2105
 2
 2.2051833.
6
Next
The Main Menu
‫ا‬Previous
Then y(0.1) = 2.2052
To get y2 = y(0.2)
k1  hf(x n , yn )  0.1(2.2052  0.1)  0.2105
h
k1 

k 2  hf (x n  ), (y n  )  0.1(2.3105  0.15)  0.2161
2
2 

h
k 

k 3  hf (x n  ), (y n  2 )  0.1(2.3133  0.15)  0.2163
2
2 

k 4  hf (x n , h), (y n , k 3 )  0.1(2.4215  0.2)  0.2222
k1  2(k 2  k 3 )  k 4
 y 2  y1 
6
0.2105  2(0.2161  0.2163)  0.2222
 2.2052 
 2.42145.
6
Then y(0.2) = 2.4215
Next
The Main Menu
‫ا‬Previous
Download