Documente Academic
Documente Profesional
Documente Cultură
=
N
a b
h
x
2
x
1
x
0
= a x
3
x
N+1
=b
where N=3
Finite Difference Method
Step two: Form the algebraic equations required to satisfy
the differential equation and the BC by replacing
derivatives with differential quotients involving only the
nodes.
If y(x) has continuous derivatives of order four, by Taylor s
theorem
4
4 4
3
3 3
2
2 2
) (
! 4
) (
! 3
) (
! 2
) (
) ( ) (
dx
y d h
dx
x y d h
dx
x y d h
dx
x dy
h x y h x y
+ + + + = +
4
4 4
3
3 3
2
2 2
) (
! 4
) (
! 3
) (
! 2
) (
) ( ) (
dx
y d h
dx
x y d h
dx
x y d h
dx
x dy
h x y h x y
+ + =
h x x
i i
+ s s
i i
x h x s s
(1)
(2)
Finite Difference Method
Step two: continued
) (
) 2 ( ) (
2
2
1 1
2
2
h
h
y y y
dx
x dy
i i i i
o +
+
=
+
) (
2
) ( ) (
2
1 1
h
h
y y
dx
x dy
i i i
o +
=
+
Adding equations (1) and (2) in the previous slide and
divided by h
2
yields
Subtracting equations (2) from (1) in the previous slide and
divided by 2h yields
Both of the approximation are second order accurate.
It is called central difference approximation.
To solve the given BVP at each interior node, replace
the 2
nd
and 1
st
order derivatives by the central difference
approximation (O(h
2
) accurate).
Finite Difference Method
Step two: continued
2
1 1
2
2
) 2 ( ) (
h
u u u
dx
x dy
i i i i +
+
~
h
u u
dx
x dy
i i i
2
) ( ) (
1 1 +
~
Both of the approximation are second order accurate.
u
i
y
i
Finite Difference Method
A second order ODE:
) ' , , (
2
2
y y x f
dx
y d
=
| =
+
) (
1
b u
N
N i
h
u u
y x f
h
u u u
i i i i i
,... 1 ),
2
) (
, , (
) 2 (
1 1
2
1 1
=
=
+
+ +
Introduce the approximation for the derivatives in the
above equations and solve simultaneously for u
i
:
o = ) (
0
a u
|
o
=
=
) (
) (
b y
a y
Boundary Value Problems
Dirichlet boundary conditions:
) ' , , (
2
2
y y x f
dx
y d
=
|
o
=
=
) (
) (
b y
a y
The solutions are in the previous slide.
Boundary Value Problems
Mixed boundary conditions:
) ' , , (
2
2
y y x f
dx
y d
=
| o = = ) ( ' , ) ( b y a y
| =
=
+
=
+
h
u u
dx
dy
N N
b x
N
2
2
1
o = ) (
0
a u
Generate a fictitious point u
N+2.
N equations for N+1 unknowns. Use the central difference
approximation ( 2
nd
order accurate) for the derivative at b.
? ) (
1
=
+
b u
N
N i
h
u u
y x f
h
u u u
i i i i i
,... 1 ),
2
) (
, , (
) 2 (
1 1
2
1 1
=
=
+
+ +
Boundary Value Problems
Mixed boundary conditions:
| =
=
+
=
h
u u
dx
dy
N N
b x
2
2
N i
h
u u
y x f
h
u u u
i i i i i
,... 1 ),
2
) (
, , (
) 2 (
1 1
2
1 1
=
=
+
+ +
o = ) (
0
a u
1 ),
2
) (
, , (
) 2 (
2
2
1 2
+ =
=
+
+ + +
N i
h
u u
y x f
h
u u u
N N N N N
Finite Difference method (fictitious point approach):
Substitute u
N+2
in the equation at i=N+1 by the last
equation, there are N+1 equation to solve N+1 unknowns.
x
2
x
1
x
0
= a x
3
X
N+1
=b
u
2
u
1
u
0
u
3
u
N+1
where u
i
y
i
N=3
Fictitious points
X
N+2
U
N+2
Boundary Value Problems
Mixed boundary conditions:
Finite Difference method (fictitious point approach):
) ' , , (
2
2
y y x f
dx
y d
=
|
o
=
=
) ( '
) (
b y
a y
Use the central difference approximation for the
boundary derivatives.
Boundary Value Problems
Neumann boundary conditions:
) ' , , (
2
2
y y x f
dx
y d
=
|
o
=
=
) ( '
) ( '
b y
a y
Boundary Value Problems
Neumann boundary conditions:
| =
=
+
=
h
u u
dx
dy
N N
b x
2
2
N i
h
u u
y x f
h
u u u
i i i i i
,... 1 ),
2
) (
, , (
) 2 (
1 1
2
1 1
=
=
+
+ +
1 ),
2
) (
, , (
) 2 (
2
2
1 2
+ =
=
+
+ + +
N i
h
u u
y x f
h
u u u
N N N N N
Finite Difference method (fictitious point approach):
There are N+2 equation to solve N+2 unknowns.
0 ),
2
) (
, , (
) 2 (
1 0 1
2
1 0 0 1
=
=
+
i
h
u u
y x f
h
u u u
o =
=
=
h
u u
dx
dy
a x
2
1 0 1
x
2
x
1
x
0
= a x
3
X
N+1
=b
u
2
u
1
u
0
u
3
u
N+1
where u
i
y
i
Fictitious points
X
0-1
U
0-1
X
N+2
U
N+2
Boundary Value Problems
Neumann boundary conditions:
Finite Difference method (fictitious point approach):
) ' , , (
2
2
y y x f
dx
y d
=
|
o
=
=
) ( '
) ( '
b y
a y
Use the central difference approximation for the
boundary derivatives.
Approximations to the 1
st
Derivative
Forward
difference
Backward
difference
Central
difference
Note that the central difference is u(x
2
) accurate
( )
( ) ( )
( ) x
x
x f x x f
x f A O +
A
A +
=
'
( )
( ) ( )
( ) x
x
x x f x f
x f A O +
A
A
=
'
( )
( ) ( )
( )
2
2
x
x
x x f x x f
x f A O +
A
A A +
=
'
Eular method for IVP
Backward Eular method IVP
Finite Difference for BVP
From Taylor series:
Approximations to the 2
nd
Derivative
Central Difference
Note that the central is O(x
2
) accurate
( ) ( )
( )
2
2 2
2
) ( 2
x
x
x x y x y x x y
dx
y d
A O +
A
A + A +
=
Finite Difference for BVP