Faculty Name
Prof. A. A. Saati
Part 3 - Approximate Solutions of Differential Equations
1. Introductory Remarks 2. Taylor Series Expansion
3. Solutions of Differential Equations
1. Introductory Remarks
The ODE & PDE must be expressed as
approximate expressions, so that a digital computer can be employed to obtain a
solution
There are two methods for approximating the differentials of the function f
First method of approximation often used is the Taylor series
Second method is the use of a polynomial of degree n.
2. Taylor Series Expansion:
Given a function f(x), which is analytical, can be expanded in a Taylor series about x as
)
(x x
f
n n
n
n
x f n
f(x) x
x f x
x f x
x x f
x f x
x f
1
3 3 3
2 2 2
!
! ...
3
! ) 2
( ) ( )
(
Forward Difference Formulations
Solving for one obtains
The truncation error of order x
f
x ,) o ( )
(
! ...
3
! 2 )
( )
(
3 3 3
2 2 2
x
x f x
x f x
f
x f x
x x
f x
x x
x f x
x f x
f
) ( x o
) ( x o
! ...
3
! ) 2
( ) ( )
( 3
3 3 2
2 2
x
f x
x f x
x x f x
f x
x f
Finite Difference Formulations
If the subscript index i is used to represent the discrete point in the x-direction
The truncation error of order
This equation is known as forward difference of order
x ,1 o
x f f
x
f i i
) ( x o )
( x o
1 i i
Backward Difference Formulations
Now consider the Taylor series expansion of about x.
Solving for one obtains
This is known as backward difference of order x
f
)
(x x
f
n nn
n n
x f n
f(x) x
x f x
x f x
x x f
x f x
x f
1
3 3 3
2 2 2
1 !
! ...
3
! ) 2
( ) ( )
(
x ,o
, x ) o
( )
(
1
x f f
x f
x
x x
f x
f x
f
i i
) ( x o
Central Difference Formulations
Now consider the Taylor series
expansion of and about x.
Subtracting the above equations, one obtains:
Solving for
x
f
/
)
(x x
f
! ...
3
! ) 2
( ) ( )
(
! ...
3
! ) 2
( ) ( )
(
3 3 3
2 2 2
3 3 3
2 2 2
x f x
x f x
x x f
x f x
x f
x f x
x f x
x x f
x f x
x f
)
(x x
f
....! 2 3
) (
2 )
( )
( 3
3 3
x
f x
x x f
x x
f x
x f
) 2 (
) (
)
( 2
x x o
x x
f x
x f x
f
f f f
) ( x2 o
Forward & Backward Difference Formulations
Again consider the Taylor series expansion of and about x.
Multiply the first equation by 2 and subtract it from the second equation:
Solving for )
(x x
f
! ...
3 2
! 2 ) 2
2 ( ) ( )
2 (
! ...
3
! ) 2
( ) ( )
(
3 3 3
2 2 2
3 3 3
2 2 2
x f x
x f x
x x f
x f x
x f
x f x
x f x
x x f
x f x
x f
) 2
(x x
f
....) (
) ( )
2 (
) (
2 3
3 3 2
2
2
x
x f x
x f x
f x
x f x
x f
2 f
) ( x o
Forward Difference Formulations
Solving for
2 2
x f
2 ( )) ) (
( )
( 2 )
2 (
2 1 2
2 2
2 2 2
x x o
f f
f x
f or
x x o
x f x
x f x
x f x
f
i i
i
) ( x o
Backward Difference Formulations
A similar approximation for B.D. using the Taylor series expansions of
and about x. The result is )
(x x
f )
2
(x x
f
( )2
) ) (
2 (
) (
2 )
(
2
2 1
2 2
2 2 2
x x o
f f
f x
f or
x x o
x x
f x
x f x
f x
f
i i
i
) ( x o
Center Difference Formulations
Approximation expression for higher order derivatives
Now consider the Taylor series expansion of and about x.
Add the above equations, one obtains the center difference:
! ...
3
! ) 2
( ) ( )
(
! ...
3
! ) 2
( ) ( )
(
3 3 3
2 2 2
3 3 3
2 2 2
x f x
x f x
x x f
x f x
x f
x f x
x f x
x x f
x f x
x f
2
) ) (
( )
( 2 )
( 2
2 2
2
f f
f
x x o
x x
f x
f x
x f x
f
)
(x x
f f (x x)
) ( x2 o
Forward Difference Formulations
Now by considering additional terms in the Taylor series expansion, a more accurate
approximation of the derivatives is produced.
Consider the Taylor series expansion,
Solving for
! ...
3
! ) 2
( ) ( )
( 3
3 3 2
2 2
x
f x
x f x
x x f
x f x
x f
! ...
3 ) (
2 )
( )
(
3 3 2 2
2
x f x
x f x
x
x f x
x f x
f
x f
) ( x2 o
Substitute a forward difference expression for
And 0ne obtains a second-order for
! ...
3 ) (
2 )
( )
(
3 3 3 2
2
x f x
x f x
x
x f x
x f x
f
2 2
x f
) ) (
(
) 2
( )
( 2 )
(
2 2
2
x x o
x x
f x
x f x
f x
f
3 3 2
2
) ( 3 ) (
4 ) 2 (
or 6 ...
) (
) ) (
(
) ( )
( 2 ) 2 (
2 )
( )
(
x f x
x f x
x f f
x f x
x x o
x f x
x f x
x f x x
x f x
x f x
f
x f
Forward & Backward Difference Formulations
The finite difference approximation to the time derivative is expressed for a forward and
backward difference as t
f f
t
f inj inj
, 1 ,
t f f
t
f inj inj
, , 1
) ( t o
1 –FD
2 – BD
3 – CD
4 – FD
5 - BD
Finite Difference Formulations
) ( x o
1
x f f
x
f i i
x f f
x
f i i
1
) ( x2 o x
f f
x
f i i
2
1 1
) ( x o
x
f f
f x
f i i i
2
3
4 1
2 o(x2)
) ( x2 o
x
f f
f x
f i i i
2
3
4 1
2
6 - FD
7 – BD
8 – CD
9 – FD
10 - BD
) ( x o
) ( t o
) ( x o
) ( x2 o
212 2
2 2
x
f f
f x
f i i i
12 22
2 2
x
f f
f x
f i i i
2
1 1
2
2 2
x
f f
f x
f i i i
t f f
t
f inj inj
, 1 , o(t)
t f f
t
f inj inj
, , 1
Finite Difference Formulations
Read Example:
2.1 , 2.2, 2.3, & 2.4
2.6, 2.7, & 2.8
3. Solutions of Differential Equations
Example:
Given the function compute the first derivative of f at x = 2 using forward and back ward difference of order
Compare the results with a central differencing of order and the exact analytical value. Use a step size of
Solution:
Form Eq.1
With
4 / )
(x x2
f
) (x
) (x2
1 .
0
x
)
1 o( x
x f f
x
f i i
1 .
0
x
Example (cont.)
The back ward of order
1 o( x) x
f f
x
f i i
) 1 . 0 ( 975
. 0 )
1 . 0 1 (
. 0
) 9 . 1 ( )
2
( f o o
f x
f
) (x
Example (cont.)
The central differencing of order
The exact value is
22
) (x2 )
2 (
1 2
1 o x
x f f
x
f i i
) 01 . 0 ( 0
. 1 )
1 . 0 ) (
1 . 0 ( 2
) 9 . 1 ( )
1 . 2
( f o o
f x
f
. 1 /
is 2 at x
which ,
4 / ) 2 (
/
f x x f x
Example (cont.)
Read Example:
2.6, 2.7, & 2.8
Home work
Solve problems:
2.7
2.12
Finite Difference Equations
( FDE ) next……….
Finite Difference Equations
The finite difference approximations are replace the derivatives that appear in the PDEs.
Consider the following example, where f is f = f(t,x,y).
Assume is constant.
Let represent
Assume are constant step.
Now use forward difference in time
And use center difference in space.
2 2 2
2
y f x
f t
f
n j
i, , x, y, t
t y x
, ,
Finite Difference Equations
Now use forward difference in time
And use center difference in space.
2 2 2
2
y f x
f t
f
)
, (
1
, O t
t f f
t
f inj inj
) 2 (
) 2 (
2 2
1 , ,
1 , 2
2
2 2
, 1 ,
, 1 2
2
y f o
f f f
x x o
f f
f x
f
n j i n
j i n
j i
n j i n
j i n
j i
Finite Difference Equations
The finite difference formulation of PDE is:
Note that in this formulation, the spatial approximations are applied at time level n
This lead to one unknown
This equation is classified as explicit formulation
( ),( ),( )
2 2
2 2
2
1 , ,
1 , 2
, 1 ,
, 1 ,
1 ,
y x
t o
y
f f
f x
f f
f t
f
finj inj in j inj in j inj inj inj
1 ,
n
j
fi
Finite Difference Equations
The second case evaluated the spatial approximations at n+1 time level.
Therefore, the first-order backward difference approximation in time is employed
The finite difference formulation for PDE takes the form:
This lead to 5 unknown
( ),( ),( )
2 2
2 2
2
1 1 , 1
, 1
1 , 2
1 , 1 1
, 1
, 1 ,
1 ,
y x
t o
y
f f
f x
f f
f t
f
finj inj in j inj in j inj inj inj
1 1 , 1
1 , 1 , 1 1
, 1 1
,nj , in j, inj, inj and inj
i f f f f
f
Applications
Applications
Example 2.2
Finite Difference Approximation
of Mixed Partial Derivatives
Finite Difference Approximation of Mixed Partial Derivatives
Approximating mixed partial derivatives can be performed by using Taylor series expansion for two variables
Consider
The Taylor series expansion for two variables x and y, become as
)
2 /(
y x f
) ,
(x x y y
f
2 2 2 2
3 3
2 2 2
! , 2 2
! 2
! ) 2
, ( )
, (
y x
y O x
f y
x y
f y
x f x
y y f x
x f y
x f y
y x x
f
Taylor Series Expansion
Using indices to represent a grid point at x, y.
Similarly, the expansion j i and
2 2 2
2 2 2
3 3
2 ,
1 , 1
! , 2
! 2
O x y
y f y
x f x
y x y f y x
y f x
x f f
fi j i j
) ,
(x x y y
f
2 2
2 2
3 3
2 ,
1 , 1
,
x f y f O x y
y x y f y x
y f x
x f f
fi j i j
Taylor Series Expansion
And the expansion
And the expansion
2 2 2
2 2 2
3 3
2 ,
1 , 1
! , 2
! 2
O x y
y f y
x f x
y x y f y x
y f x
x f f
fi j i j
) ,
(x x y y
f
2 2
2 2
3 3
2 ,
1 , 1
,
x f y f O x y
y x y f y x
y f x
x f f
fi j i<