Vous êtes sur la page 1sur 34

Presentation

of
Numerical Methods
4/22/2014 2
Presented To: Maam Ayesha Kanwal

Presented By: Muhammad Sarwar
10EL20


Finite Difference Method



Read Euler: he is our master in everything.
Pierre-Simon Laplace (1749-1827)
3
Introduction To Differential Eq.
An equation that consists of derivatives is called a
differential equation.
Differential equations have applications in all areas
of science and engineering.
Mathematical formulation of most of the physical
and engineering problems leads to differential
equations.
So, it is important for engineers and scientists to
know how to set up differential equations

4
Types of Diff. Eqs
Differential equations are of two types
A. Ordinary differential equations (ODE)
B. Partial differential equations (PDE)
An ordinary differential equation is that in which all
the derivatives are with respect to a single
independent variable.
Examples of Ordinary Differential Equations.



5
ODEs with Initial Value
Conditions
These are the types of problems we have been solving
with RK methods.
All conditions are specified at the same value of the
independent variable!

6
ODEs with Boundary Value
Conditions
In the field of differential equations, a boundary
value problem is a differential equation together with
a set of additional constraints, called the boundary
conditions.
A solution to a boundary value problem is a solution
to the differential equation which also satisfies the
boundary conditions.


7
a
y a y = ) ( and
b
y b y = ) (
Types of Boundary Conditions
Three types of spatial boundary conditions:

Dirichlet Condition

Neumann Condition

Mixed Boundary Condition

No. of Boundary conditions required is order of highest derivative
appearing in each independent variable
Here Well discuss BVPs with Dirichlet Conditions only
Note that boundary value problems as position-dependent and
initial value problems as time-dependent in most cases.
8
What are Finite Differences?
A finite difference is a mathematical expression of
the form f(x + b) f(x + a). If a finite difference is
divided by b a, one gets a difference quotient. T
he approximation of derivatives by finite differences
plays a central role in finite difference methods for
the numerical solution of differential equations,
especially boundary value problems.
9
Finite Differences
To find derivative (Slope) of function y=f(x) at Xn,
take a small increment in value of f(x) at Xn and then
divide that
increment by
the difference
of values of
function at
both points..
10
Types of Finite Differences
Three forms are commonly considered: forward,
backward, and central differences.
A forward difference is an expression of the form

A backward difference uses the function values
at x and x h, instead of the values at x + h and x:

Finally, the central difference is given by



11
Geometrical Interpretation of
Finite Differences
12
Derivative in terms of FDs
13
First Order derivate with First order Accuracy


First Order Derivate with 2
nd
order accuracy


2
nd
order derivative expressed as finite difference
x
y y
dx
dy
i i
A

~
+1
( )
2
1 1
2
2
2
x
y y y
dx
y d
i i i
A
+
~
+
( ) x
y y
dx
dy
i i
A

~
+
2
1 1
Errors in Finite Differences
The two sources of error in finite difference methods
are round-off error, the loss of precision due to
computer rounding of decimal quantities, and
truncation error or discretization error, the
difference between the exact solution of the finite
difference equation and the exact quantity assuming
perfect arithmetic (that is, assuming no round-off).

14
Accuracy
The accuracy of the finite difference approximations
is given by:
forward difference: truncation error:

backwards difference: truncation error:

central difference: truncation error:

15
( ) x O A
( ) x O A
( ) 2 x O A
Solving an ODE using FDs
For example, consider the ordinary differential
equation

For solving this equation we use the finite difference
quotient

to approximate the differential equation by first
substituting in for u'(x) and applying a little algebra
to get

16
Finite Difference Method for
Boundary Value ODEs
17
The finite difference method is used to solve ordinary
differential equations that have conditions imposed
on the boundary rather than at the initial point.
These problems are called boundary-value problems.
In this chapter, we solve second-order ordinary
differential equations of the form


with boundary conditions


a
y a y = ) ( and
b
y b y = ) (
FD Method
18
General graphical interpretation of FD method
Substitute finite difference
equations for derivatives in
the original ODE.
This will give us a set of
simultaneous algebraic
equations that are solved a nodes.
FD Method
19
Proof
FD Method--Basic Procedure
20
Replace derivatives of governing equations with
algebraic difference quotients
Results in a system of algebraic equations solvable
for dependent variables at discrete grid points
Analytical solutions provide closed-form expressions
variation of dependent variables in the domain
Numerical solutions (finite difference) - values at
discrete points in the domain
21
Example
For a Circuit containing two storing elements (either both capacitor or both
inductors or one capacitor and one inductor), the mathematical model for
the circuit takes the form of a second order equation. The boundary values
for the given equation are known by measuring voltage across the output
terminals.
0
1
2 2
2
= +
r
u
dr
du
r dr
u d
The equation can be modeled using finite differences for derivatives
( )
2
1 1
2
2
2
r
u u u
dr
u d
i i i
A
+
~
+
r
u u
dr
du
i i
A

~
+1
Substituting these approximations gives you,
( )
0
1 2
2
1
2
1 1
=
A

+
A
+
+ +
i
i i i
i
i i i
r
u
r
u u
r r
u u u
( ) ( ) ( )
0
1 1 1 2 1 1
1 2 2 2 1 2
=
A
+
|
|
.
|

\
|

A
+
|
|
.
|

\
|
A
+
A
+ i i
i i
i
i
u
r
u
r r r r
u
r r r
22
Solution
Step 1
At node
" 5 , 0
0
= = = a r i
" 0038731 . 0
0
= u
Step 2 At node
" 6 . 5 6 . 0 5 , 1
0 1
= + = A + = = r r r i
( ) ( )
( )( )
( )
( )( )
0
6 . 0 6 . 5
1
6 . 0
1
6 . 5
1
6 . 0 6 . 5
1
6 . 0
2
6 . 0
1
2
2
1
2 2
0
2
=
|
|
.
|

\
|
+ +
|
|
.
|

\
|
+ u u u
0 0754 . 3 8851 . 5 7778 . 2
2 1 0
= + u u u
Step 3 At node , 2 = i
" 2 . 6 6 . 0 6 . 5
1 2
= + = A + = r r r
( )( ) ( )( )
0
6 . 0 2 . 6
1
6 . 0
1
2 . 6
1
6 . 0 2 . 6
1
6 . 0
2
6 . 0
1
3
2
2
2 2
1
2
=
|
|
.
|

\
|
+ +
|
|
.
|

\
|
+ u u u
0 0466 . 3 8504 . 5 7778 . 2
3 2 1
= + u u u
23
Solution Cont
Step 4 At node , 3 = i
" 8 . 6 6 . 0 2 . 6
2 3
= + = A + = r r r
( )( ) ( )( )
0
6 . 0 8 . 6
1
6 . 0
1
8 . 6
1
6 . 0 8 . 6
1
6 . 0
2
6 . 0
1
4
2
3
2 2
2
2
=
|
|
.
|

\
|
+ +
|
|
.
|

\
|
+ u u u
0 0229 . 3 8223 . 5 7778 . 2
4 3 2
= + u u u
Step 5 At node
Step 6 At node
, 4 = i
" 4 . 7 6 . 0 8 . 6
3 4
= + = A + = r r r
( )( ) ( ) ( )( )
0
6 . 0 4 . 7
1
6 . 0
1
4 . 7
1
6 . 0 4 . 7
1
6 . 0
2
6 . 0
1
5 2 4 2 2 3 2
=
|
|
.
|

\
|
+ +
|
|
.
|

\
|
+ u u u
0 0030 . 3 7990 . 5 7778 . 2
5 4 3
= + u u u
, 5 = i
8 6 . 0 4 . 7
4 5
= + = A + = r r r
" 0030769 . 0 |
5
= =
=b r
u u
24
Solving system of equations
(
(
(
(
(
(
(
(

=
(
(
(
(
(
(
(
(

(
(
(
(
(
(
(
(

0030769 . 0
0
0
0
0
0038731 . 0
1 0 0 0 0 0
0030 . 3 7990 . 5 7778 . 2 0 0 0
0 0229 . 3 8223 . 5 7778 . 2 0 0
0 0 0466 . 3 8504 . 5 7778 . 2 0
0 0 0 0754 . 3 8851 . 5 7778 . 2
0 0 0 0 0 1
5
4
3
2
1
0
u
u
u
u
u
u
0038731 . 0
0
= u
0036165 . 0
1
= u
0034222 . 0
2
= u
0032743 . 0
3
= u
0031618 . 0
4
= u
0030769 . 0
5
= u
25
Solution Cont
r
u u
dr
du
a r
A

~
=
0 1
6 . 0
0038731 . 0 0036165 . 0
=
00042767 . 0 =
( ) 21307 00042767 . 0 3 . 0
5
0038731 . 0
3 . 0 1
10 30
2
6
max
=
|
.
|

\
|
+

= o
21307 20538 =
t
E 59 . 768 =
% 744 . 3 100
20538
21307 20538
=

= e
t
Solving the Diff. Eq. Analytically gives the
True Value=20538
26
Need more accurate
answers???
( )
2
1 1
2
2
2
x
y y y
dx
y d
i i i
A
+
~
+
Using the approximation of
( ) x
y y
dx
dy
i i
A

~
+
2
1 1
and
( )
( )
0
2
1 2
2
1 1
2
1 1
=
A

+
A
+
+ +
i
i i i
i
i i i
r
u
r
u u
r
r
u u u
( )
( ) ( ) ( )
0
2
1 1 1 2 1
2
1
1
2 2 2
1
2
=
|
|
.
|

\
|
A
+
A
+
|
|
.
|

\
|

A
+
|
|
.
|

\
|
A
+
A

+ i
i
i
i
i
i
u
r r
r
u
r r
u
r
r r
Gives you
27
Solution Cont
5 , 0
0
= = = a r i
Step 1 At node
0038731 . 0
0
= u
Step 2 At node
Step 3 At node
" 6 . 5 6 . 0 5 , 1
0 1
= + = A + = = r r r i
( )( )
( ) ( ) ( )
( )( )
0
6 . 0 6 . 5 2
1
6 . 0
1
6 . 5
1
6 . 0
2
6 . 0
1
6 . 0 6 . 5 2
1
2
2
1
2 2
0
2
=
|
|
.
|

\
|
+ +
|
|
.
|

\
|
+
|
|
.
|

\
|
+ u u u
0 9266 . 2 5874 . 5 6297 . 2
2 1 0
= + u u u
, 2 = i
2 . 6 6 . 0 6 . 5
1 2
= + = A + = r r r
( )( ) ( )( )
0
6 . 0 2 . 6 2
1
6 . 0
1
2 . 6
1
6 . 0
2
6 . 0
1
6 . 0 2 . 6 2
1
3
2
2
2 2
1
2
=
|
|
.
|

\
|
+ +
|
.
|

\
|
+
|
|
.
|

\
|
+ u u u
0 9122 . 2 5816 . 5 6434 . 2
3 2 1
= + u u u
28
Solution Cont
Step 4 At node , 3 = i 8 . 6 6 . 0 2 . 6
2 3
= + = A + = r r r
( )( ) ( )( )
0
6 . 0 8 . 6 2
1
6 . 0
1
8 . 6
1
6 . 0
2
6 . 0
1
6 . 0 8 . 6 2
1
4
2
3
2 2
2
2
=
|
|
.
|

\
|
+ +
|
.
|

\
|
+
|
|
.
|

\
|
+ u u u
0 9003 . 2 5772 . 5 6552 . 2
4 3 2
= + u u u
Step 5 At node
Step 6 At node
, 4 = i
4 . 7 6 . 0 8 . 6
3 4
= + = A + = r r r
( )( )
( )
( )( )
0
6 . 0 4 . 7 2
1
6 . 0
1
4 . 7
1
6 . 0
2
6 . 0
1
6 . 0 4 . 7 2
1
5
2
4
2 2
3
2
=
|
|
.
|

\
|
+ +
|
|
.
|

\
|
+
|
|
.
|

\
|
+ u u u
0 8903 . 2 5738 . 5 6651 . 2
5 4 3
= + u u u
, 5 = i
" 8 6 . 0 4 . 7
4 5
= + = A + = r r r
" 0030769 . 0 |
5
= =
=b r
u u
29
Solving system of equations
(
(
(
(
(
(
(
(

=
(
(
(
(
(
(
(
(

(
(
(
(
(
(
(
(

0030769 . 0
0
0
0
0
0038731 . 0
1 0 0 0 0 0
8903 . 2 5738 . 5 6651 . 2 0 0 0
0 9003 . 2 5772 . 5 6552 . 2 0 0
0 0 9122 . 2 5816 . 5 6434 . 2 0
0 0 0 9266 . 2 5874 . 5 6297 . 2
0 0 0 0 0 1
5
4
3
2
1
0
u
u
u
u
u
u
0038731 . 0
0
= u
0036115 . 0
1
= u
0034159 . 0
2
= u
0032689 . 0
3
= u
0031586 . 0
4
= u
0030769 . 0
5
= u
30
Solution Cont
( )
0004925 . 0
) 6 . 0 ( 2
0034159 . 0 0036115 . 0 4 0038731 . 0 3
2
4 3
2 0 0
=
+
=
A
+
~
=
r
u u u
dr
du
a r
( ) 20666 0004925 . 0 3 . 0
5
0038731 . 0
3 . 0 1
10 30
2
6
max
=
|
.
|

\
|
+

= o
128 20666 20538 = =
t
E
% 62323 . 0 100
20538
20666 20538
=

= e
t
31
The Finite Difference Table
Table 1 Comparisons of answers from two methods
r u
exact
u
1st order
|
t
| u
2nd order
|
t
|
5 0.0038731 0.0038731 0.0000 0.0038731 0.0000
5.6 0.0036110 0.0036165 1.516010
1
0.0036115 1.454010
2

6.2 0.0034152 0.0034222 2.026010
1
0.0034159 1.876510
2

6.8 0.0032683 0.0032743 1.815710
1
0.0032689 1.633410
2

7.4 0.0031583 0.0031618 1.090310
1
0.0031586 9.566510
3

8 0.0030769 0.0030769 0.0000 0.0030769 0.0000
Solution of given BVP using
MATLAB
32
Applying BVPs in Real Life
There are uncountable applications of differential
equations in Real life
In electrical engineering, the behavior of a RLC
circuit is studied using differential equations.
Finding size of capacitor in designing a power
supply.
Finding the time instant at which voltage across a
capacitor becomes zero.

33
Thank You!

Any Questions?
34

Vous aimerez peut-être aussi