APPLIED NUMERICAL METHODS
Dr. Khaled Ahmida Ashouri
Numerical Methods Course
Dr. Khaled Ahmida
FINITE DIFFERENCE METHOD
The philosophy of Finite Difference Method (FDM) is to replace the derivatives of the
governing equations with algebraic difference quotients
This results in a system of algebraic equations, which is solved at the discrete grid points in
the flow field
So, FDM converts ODE or PDE, which may be non-linear, into system of linear equations
Derivation from Taylor’s polynomial: for fluid flow parameters u(i,j),
Let’s apply Taylor series expansion of ui+1,j about point (i,j) as follows,
𝜕𝑢 𝜕 𝑢 ∆𝑥 𝜕 𝑢 ∆𝑥
𝑢 , 𝑢, ∆𝑥 ⋯ (1)
𝜕𝑥 ,
𝜕𝑥 ,
2! 𝜕𝑥 ,
3!
Numerical Methods Course
Dr. Khaled Ahmida
FINITE DIFFERENCE METHOD
Solving for 1st order partial derivative, Truncation error
𝜕𝑢 𝑢 , 𝑢, 1 𝜕 𝑢 ∆𝑥 𝜕 𝑢 ∆𝑥
⋯
𝜕𝑥 ,
∆𝑥 ∆𝑥 𝜕𝑥 ,
2! 𝜕𝑥 ,
3!
Finite difference representation
of partial derivative
Called: discrete equation.
First order Forward Difference
This is normally expressed as:
𝜕𝑢 𝑢 , 𝑢,
𝑂 ∆𝑥 Truncation error
𝜕𝑥 ,
∆𝑥
Numerical Methods Course
Dr. Khaled Ahmida
FINITE DIFFERENCE METHOD
If we now apply Taylor series expansion of ui-1,j about point (i,j) we get,
𝜕𝑢 𝜕 𝑢 ∆𝑥 𝜕 𝑢 ∆𝑥
𝑢 , 𝑢, ∆𝑥 ⋯ (2)
𝜕𝑥 ,
𝜕𝑥 ,
2! 𝜕𝑥 ,
3!
Similarly,
𝜕𝑢 𝑢, 𝑢 ,
𝑂 ∆𝑥 Truncation error
𝜕𝑥 ,
∆𝑥
Finite difference representation
of partial derivative
First order Backward Difference
Numerical Methods Course
Dr. Khaled Ahmida
FINITE DIFFERENCE METHOD
Subtracting eqn.(2) from (1), we get, Truncation error
𝜕𝑢 𝑢 , 𝑢 ,
𝑂 ∆𝑥
𝜕𝑥 ,
2∆𝑥
Second order Central Difference
𝜕 𝑢 𝜕 𝑢 ∆𝑥
Adding up eqns.(1) & (2), we get, 𝑢 , 𝑢 , 2𝑢 , ∆𝑥 ⋯
𝜕𝑥 ,
𝜕𝑥 ,
12
Solving for the 2nd derivative,
𝜕 𝑢 𝑢 , 2𝑢 , 𝑢 ,
𝑂 ∆𝑥
𝜕𝑥 ,
∆𝑥
Numerical Methods Course
Dr. Khaled Ahmida
FINITE DIFFERENCE METHOD
Summarizing:
𝜕𝑢 𝑢 , 𝑢,
≅ Forward Finite Difference
𝜕𝑥 ,
∆𝑥
𝜕𝑢 𝑢, 𝑢 ,
≅ Backward Finite Difference
𝜕𝑥 ,
∆𝑥
𝜕𝑢 𝑢 , 𝑢 ,
≅ Central Finite Difference
𝜕𝑥 ,
2∆𝑥
𝜕 𝑢 𝑢 , 2𝑢 , 𝑢 ,
≅ Second Derivative FD
𝜕𝑥 ,
∆𝑥
Numerical Methods Course
Dr. Khaled Ahmida
FINITE DIFFERENCE METHOD
𝜕𝑢 𝑢 , 𝑢,
≅
𝜕𝑥 ,
∆𝑥
Forward difference
𝜕𝑢 𝑢 , 𝑢,
≅
𝜕𝑦 ,
∆𝑦
Numerical Methods Course
Dr. Khaled Ahmida
FINITE DIFFERENCE METHOD
𝜕𝑢 𝑢, 𝑢 ,
≅
𝜕𝑥 ,
∆𝑥
Backward difference
𝜕𝑢 𝑢, 𝑢 ,
≅
𝜕𝑦 ,
∆𝑦
Numerical Methods Course
Dr. Khaled Ahmida
FINITE DIFFERENCE METHOD
𝜕𝑢 𝑢 , 𝑢 ,
≅
𝜕𝑥 ,
2∆𝑥
Central difference
𝜕𝑢 𝑢 , 𝑢 ,
≅
𝜕𝑦 ,
2∆𝑦
Numerical Methods Course
Dr. Khaled Ahmida
FINITE DIFFERENCE METHOD
𝜕 𝑢 𝑢 , 2𝑢 , 𝑢 ,
≅
𝜕𝑥 ,
∆𝑥
Second Derivative
𝜕 𝑢 𝑢 , 2𝑢 , 𝑢 ,
≅
𝜕𝑦 ,
∆𝑦
Numerical Methods Course
Dr. Khaled Ahmida
FINITE DIFFERENCE METHOD
Numerical Methods Course
Dr. Khaled Ahmida
FINITE DIFFERENCE METHOD
If we have mixed derivative, i.e, the parameter u depends on x- and y-directions,
Let’s differentiate eqn.(1) and (2) with respect to y,
𝜕𝑢 𝜕 𝑢 ∆𝑥 𝜕 𝑢 ∆𝑥
𝑢 , 𝑢, ∆𝑥 ⋯ (1)
𝜕𝑥 ,
𝜕𝑥 ,
2! 𝜕𝑥 ,
3!
𝜕𝑢 𝜕𝑢 𝜕 𝑢 𝜕 𝑢 ∆𝑥 𝜕 𝑢 ∆𝑥
∆𝑥 ⋯ (3)
𝜕𝑦 ,
𝜕𝑦 ,
𝜕𝑥𝜕𝑦 ,
𝜕𝑥 𝜕𝑦 ,
2 𝜕𝑥 𝜕𝑦 ,
6
𝜕𝑢 𝜕 𝑢 ∆𝑥 𝜕 𝑢 ∆𝑥
𝑢 , 𝑢, ∆𝑥 ⋯ (2)
𝜕𝑥 ,
𝜕𝑥 ,
2! 𝜕𝑥 ,
3!
𝜕𝑢 𝜕𝑢 𝜕 𝑢 𝜕 𝑢 ∆𝑥 𝜕 𝑢 ∆𝑥
∆𝑥 ⋯ (4)
𝜕𝑦 ,
𝜕𝑦 ,
𝜕𝑥𝜕𝑦 ,
𝜕𝑥 𝜕𝑦 ,
2 𝜕𝑥 𝜕𝑦 ,
6
Numerical Methods Course
Dr. Khaled Ahmida
FINITE DIFFERENCE METHOD
𝜕𝑢 𝜕𝑢 𝜕 𝑢 𝜕 𝑢 ∆𝑥 𝜕 𝑢 ∆𝑥 (3)
∆𝑥 ⋯
𝜕𝑦 ,
𝜕𝑦 ,
𝜕𝑥𝜕𝑦 ,
𝜕𝑥 𝜕𝑦 ,
2 𝜕𝑥 𝜕𝑦 ,
6
𝜕𝑢 𝜕𝑢 𝜕 𝑢 𝜕 𝑢 ∆𝑥 𝜕 𝑢 ∆𝑥
∆𝑥 ⋯ (4)
𝜕𝑦 ,
𝜕𝑦 ,
𝜕𝑥𝜕𝑦 ,
𝜕𝑥 𝜕𝑦 ,
2 𝜕𝑥 𝜕𝑦 ,
6
𝜕𝑢 𝜕𝑢
subtracting (3) from (4), and using the central FD for 𝜕𝑦
and we end up
𝜕𝑦
with, , ,
𝜕 𝑢 𝑢 , 𝑢 , 𝑢 , 𝑢 ,
𝑂 ∆𝑥, ∆𝑦
𝜕𝑥𝜕𝑦 ,
4∆𝑥∆𝑦
Numerical Methods Course
Dr. Khaled Ahmida
FINITE DIFFERENCE METHOD
Mixed Derivative
𝜕 𝑢 𝑢 , 𝑢 , 𝑢 , 𝑢 ,
≅
𝜕𝑥𝜕𝑦 ,
4∆𝑥∆𝑦
Numerical Methods Course
Dr. Khaled Ahmida
FINITE DIFFERENCE METHOD
If we have a time variable in our equation, the Backward FD is stable and called “implicit”
FD. The forward FD is then called “explicit” and is some times unstable.