chapter 3 (1)
chapter 3 (1)
Numerical Analysis
Chapter 3
Finite Difference Method
Assistant prof. Dr. Eng. Ibrahim Thamer Nazzal
1
15.03.2023
Numerical Analyses Assistant Prof. Dr. Eng. Ibrahim Thamer Nazzal
What is a Finite Difference Equation?
A finite difference method (FDM) is is one of the available numerical methods for solving
differential equations by approximating derivatives with finite differences. Both the spatial
domain
. and time interval (if applicable) are discretized, or broken into a finite number of steps.
In general real life EM problems cannot be solved by using the analytical methods, because:
1. The PDE is not linear,
2. The solution region is complex,
3. The boundary conditions are of mixed types,
4. The boundary conditions are time dependent,
For finite difference method, this is done by replacing the derivatives by differences.
A function f that depends on x.
The first derivative of f(x) at a point is equivalent to the slope of a line tangent to the curve at
that point.
𝑑𝑓(𝑥) ∆𝑓 𝑓 𝑥+∆𝑥) −𝑓(𝑥)
= lim = lim
𝑑𝑥 ∆𝑥
∆𝑥→0 ∆𝑥→0 ∆𝑥
If we don’t take the indicated limit, we will have the following approximate relation for the derivative:
𝑑𝑓(𝑥) 𝑓 𝑥 + ∆𝑥) − 𝑓(𝑥) 𝑑(𝑓) ∆𝑓
≅ The differential ≈ the difference
𝑑𝑥 ∆𝑥 𝑑𝑥 ℎ
2
Assistant Prof. Dr. Eng. Ibrahim Thamer Nazzal 15.03.2023
Numerical Analyses
Finite Difference Approximation Of The Derivative
Steps of finite difference solution:
Divide the solution region into a grid of nodes,
Approximate the given differential equation by finite difference equivalent,
Solve the differential equations subject to the boundary conditions and/or initial conditions.
The rate of the change of the function with respect to the variable x is accounted between the
current value at: 𝑥 = 𝑥𝑖 f(x)
and the step forward at 𝑥 𝑖 + 1 = 𝑥𝑖 + Δ𝑥
f(x)
f(xi+1) f(xi+1
fi+1 at x = xi+1 fi at x = xi fi-1 at x = xi-1 )
Tangent of
x i+1 = xi + Δx, and x i-1 = x – Δx,
f(xi) f(x) at xi
The derivative 𝑓′(𝑥) of a function 𝑓(𝑥) f(xi-1) f(xi)
at the point 𝑥 = xi is defined by: f(xi-1)
f\’(xi)
𝑑(𝑓)
= lim
𝑓 𝑥𝑖 +∆𝑥) −𝑓(𝑥𝑖 ) Dx Dx x
𝑑𝑥 𝑥=𝑥𝑖 ∆𝑥→0 ∆𝑥
xi-1 xi xi+1
= lim
𝑓 𝑥𝑖 +∆𝑥) −𝑓(𝑥𝑖 )
=
∆𝑓
lim ∆𝑥 =
∆𝑓 ∆𝑓 𝑑(𝑓) ∆𝑓
∆𝑥→0 ∆𝑥 ∆𝑥→0 ∆𝑥 = The differential ≈ the difference
ℎ 𝑑𝑥 ℎ
where h = Δx
It is important to be aware of the fact that smaller the steps Δx the closer the values between the
differential and difference of the rate change of the function 15.03.2023
3
Assistant Prof. Dr. Eng. Ibrahim Thamer Nazzal
Numerical Analyses
Three Basic Finite Difference Methods
In finite difference approximations of the slope, we can use values of the function in the
neighborhood of the point to achieve the goal. There are 3 ways to express differentials of a function:
1. Forward difference is the rate of change of the function
values between the “current” step at 𝑥𝑖 , and the function
value at a step “forward” at 𝑥𝑖+1 and equal to the slope of
the line that connects points: 𝑥𝑖 , 𝑓 𝑥𝑖 and
(𝑥𝑖+1 , 𝑓 𝑥𝑖+1 ):
𝒉
𝑑(𝑓)
ቚ =
𝑓 𝑥𝑖+1 −𝑓(𝑥𝑖 ) 𝑓 𝑥𝑖+1 − 𝑓(𝑥𝑖 )
𝑑𝑥 𝑥=𝑥𝑖 𝑥𝑖+1 −𝑥𝑖 =
ℎ
𝒙𝒊−𝟏 𝒙𝒊 𝒙𝒊+𝟏 𝒙
𝑑(𝑓) 𝑓 𝑥𝑖+2 − 𝑓(𝑥𝑖+1 )
ቤ = Forward difference
𝑑𝑥 𝑥=𝑥 +1 ℎ
𝑖
𝑑(𝑓) 𝑓 𝑥𝑖+3 − 𝑓(𝑥𝑖+2 ) 𝒇(𝒙)
ቤ =
𝑑𝑥 𝑥=𝑥 +2 ℎ
𝑖
2. Backward difference is the rate of change of the function
values between the “current” step at 𝑥𝑖 , and the function value
at a step “back” at 𝑥𝑖−1 , which is the slope of the line that
𝒉
connects points: ((𝑥𝑖 , 𝑓(𝑥𝑖 ))and (𝑥𝑖−1 , 𝑓(𝑥𝑖−1 ):
𝑑(𝑓) 𝑓 𝑥𝑖 −𝑓(𝑥𝑖−1 )
ቚ = 𝒙𝒊−𝟏 𝒙 𝒙𝒊+𝟏
𝑑𝑥 𝑥=𝑥𝑖 𝑥𝑖 −𝑥𝑖−1 𝒊 𝒙
𝑓 𝑥𝑖 −𝑓(𝑥𝑖−1 ) Backward difference
4
= 15.03.2023
ℎ Numerical Analyses Assistant Prof. Dr. Eng. Ibrahim Thamer Nazzal
3. Central difference is the rate of change of function f(x) is accounted for between the step at
back at (x-Δx) and the step ahead of x, i.e. (x+Δx), which is the slope of the line that connects
points:(𝑥𝑖−1 , 𝑓(𝑥𝑖−1 )and (𝑥𝑖+1 , 𝑓(𝑥𝑖+1 ): 𝒇(𝒙)
Central difference
𝑑(𝑓)
ቚ =
𝑓 𝑥𝑖+1 −𝑓(𝑥𝑖−1 ) 𝑓 𝑥𝑖+1 − 𝑓(𝑥𝑖−1 )
𝑑𝑥 𝑥=𝑥𝑖 𝑥𝑖+1 −𝑥𝑖−1 =
2ℎ
The step size in above is “2h” which is “big” in
compromising the accuracy.
𝒉
𝑓 𝑥 1 − 𝑓(𝑥 1 )
𝑑(𝑓) 𝑖+
2 𝑖− 2
ቚ =
𝑑𝑥 𝑥=𝑥𝑖 ℎ
5
Assistant Prof. Dr. Eng. Ibrahim Thamer Nazzal 15.03.2023
Engineering Analysis
The second order derivative
Using the derivatives the forward, backward, and central finite difference formulas are:
Forward finite difference
29.3125 − 27
𝑒𝑟𝑟𝑜𝑟 = × 100 = 8.565%
27
Backward finite difference
𝑑(𝑓) 𝑓 𝑥𝑖 −𝑓(𝑥𝑖−1 ) 𝑑(𝑓) 𝑓 3 −𝑓(2.75) 27 −2.753
ቚ = ቚ = = = 24.8125
𝑑𝑥 𝑥=𝑥𝑖 ℎ 𝑑𝑥 𝑥=3 3−2.75 0.25
24.8125 − 27
𝑒𝑟𝑟𝑜𝑟 = × 100 = 8.102 %
27
Central finite difference
𝑑(𝑓) 𝑓 𝑥𝑖+1 − 𝑓(𝑥𝑖−1 ) 𝑑(𝑓) 𝑓 3.25 −𝑓(2.75) 3.253 −2.753
ቚ = = = 27.0625
ቤ = 𝑑𝑥 𝑥=3 3.25 −2.75 0.5
𝑑𝑥 𝑥=𝑥 2ℎ
𝑖
27.0625 − 27
𝑒𝑟𝑟𝑜𝑟 = × 100 = 0.2315% 8
27 Numerical Analyses Assistant Prof. Dr. Eng. Ibrahim Thamer Nazzal 15.03.2023
Finite Difference Schemes of partial derivatives
For a function f(x,y) with two independent variables, the partial derivatives with respect to x and
y at the point (𝑥𝑖 , 𝑦𝑖 ) can be approximated into three basic scheme :
1. Forward difference is the rate of change of the function
values between the “current” step at (𝑥𝑖 , 𝑦𝑗 ) , and the function
value at a step “forward” at 𝑥𝑖+1 , 𝑦𝑗 ):
9
Assistant Prof. Dr. Eng. Ibrahim Thamer Nazzal 15.03.2023
Numerical Analyses
3. Central difference is the rate of change of function f(x) is accounted for between the step at
𝜕𝑓
back at (𝑥𝑖−1 , 𝑦𝑗 ) and the step ahead of 𝑥𝑖+1 , 𝑦𝑗 𝑓𝑜𝑟 𝜕𝑥ቚ 𝑥=𝑥𝑖
𝑦=𝑦𝑗
𝜕𝑓 𝑓 𝑥𝑖+1 ,𝑦𝑗 −𝑓(𝑥𝑖−1 ,𝑦𝑗 ) 𝑓 𝑥𝑖+1, 𝑦𝑗 − 𝑓(𝑥𝑖−1,𝑦𝑗 )
ቚ =
𝜕𝑥 𝑥=𝑥𝑖 𝑥𝑖+1 −𝑥𝑖−1 =
𝑦=𝑦𝑗 2ℎ𝑥
And is accounted for between the step atback at
𝜕𝑓
(𝑥𝑖 , 𝑦𝑗−1 ) and the step ahead of 𝑥𝑖 , 𝑦𝑗+1 𝑓𝑜𝑟 𝜕𝑦ቚ 𝑥=𝑥𝑖
𝑦=𝑦𝑗
𝜕𝑓 𝑓 𝑥𝑖 ,𝑦𝑗+1 −𝑓(𝑥𝑖 ,𝑦𝑗−1 )
ቚ = 𝑓 𝑥𝑖 , 𝑦𝑗+1 − 𝑓(𝑥𝑖 , 𝑦𝑗−1 )
𝜕𝑦 𝑥=𝑥𝑖 𝑦𝑗+1 − 𝑦𝑗−1 =
𝑦=𝑦𝑗 2ℎ𝑦
The step size in above is “2h” which is “big” in 𝑦 𝑛
compromising the accuracy. 𝑖,𝑗+1
A more accurate “central difference
scheme” is to reduce the step size in 𝑖−1,𝑗 𝑖+1,𝑗
each forward and backward direction by 𝑖,𝑗
half as show
We will have the corresponding expressions: 𝑦𝑖 𝑖,𝑗−1
𝑓 𝑥 1 ,𝑦𝑗 −𝑓(𝑥 1 ,𝑦𝑗 )
𝑖+ 𝑖−
∆𝑦
𝜕𝑓 2 2
ቚ =
𝜕𝑥 𝑥=𝑥𝑖 ℎ𝑥 𝑦2
𝑦=𝑦𝑗
∆𝑥
𝑓 𝑥𝑖 ,𝑦 1 −𝑓(𝑥𝑖 ,𝑦 1)
𝜕𝑓 𝑗+2 𝑗−2 𝑦1
ቚ = 𝑥1 𝑥2 𝑥𝑖 𝑥𝑚
𝜕𝑦 𝑥=𝑥𝑖 ℎ𝑦 10
𝑦=𝑦𝑗 15.03.2023
Assistant Prof. Dr. Eng. Ibrahim Thamer Nazzal
Engineering Analysis
The second order derivative
The second order derivative of the function 𝑦𝑛
at x and y can be derived by the following 𝑖,𝑗+1
procedure
𝜕2 𝑓 𝑓 𝑥𝑖+1 ,𝑦𝑗 −2𝑓 𝑥𝑖 ,𝑦𝑗 +𝑓(𝑥𝑖−1 ,𝑦𝑗 )
ቚ
2 𝑥=𝑥𝑖 = 2
𝜕𝑥 ℎ 𝑥 𝑖−1,𝑗 𝑖+1,𝑗
𝑦=𝑦𝑗
𝑖,𝑗
i,j+1
11
Assistant Prof. Dr. Eng. Ibrahim Thamer Nazzal 15.03.2023
Engineering Analysis
Example 1
The deflection y in a simply supported beam with a uniform load q and a tensile axial load T is
given by y
d 2 y Ty qx( L x) q
dx 2 EI 2 EI
T x T
Where
X = location along the beam (in). L
T = tension applied (lbs)
E = Young’s modulus of elasticity of the beam (psi). B C
I= second moment of area (in4) y ( x 0) 0 y ( x L ) 0
Q= uniform loading intensity (lb/in)
L= length of beam (in) Figure 3 Simply supported beam for Example
Given, T 7200 lb, q 5400 lbsin, E 30 Msi , and I 120 in 4
L 75 in
a) Find the deflection of the beam at x 50" Use a step size of Dx 25"
and approximate the derivatives by central divided difference approximation.
Solution
a) Substituting the given values,
d2y 7200y (5400) x(75 x )
dx 2 (30 106 )(120) 2(30 106 )(120)
d2y
2
2 106 y 7.5 10 7 x(75 x) (1) 12
dx Engineering Analysis Assistant Prof. Dr. Eng. Ibrahim Thamer Nazzal 15.03.2023
𝑑2 y
Approximating the derivative at node i by the central divided difference approximation,
𝑑𝑥 2
d 2 y yi 1 2 yi yi 1 d2y
2 106 y 7.5 10 7 x(75 x)
dx 2 ( Dx ) 2 dx 2
yi 1 2 yi yi 1 i 1 i i 1
2 106 yi 7.5 107 xi (75 xi ) Figure central difference method.
(Dx) 2
2
2 106 y3 7.5 107 x3 (75 x3 )
(25)
0.0016y2 0.003202y3 0.0016y4 7.5 107 (50)(75 50)
0.0016y2 0.003202y3 0.0016y4 9.375104
Node 4: From the simply supported boundary condition at x = 75, we obtain y4 0
y1 0
0.0016y1 0.003202y2 0.0016y3 9.375104
0.0016y2 0.003202y3 0.0016y4 9.375104
y4 0
Above Equations are 4 simultaneous equations with 4 unknowns and can be written in matrix
form as
1 0 0 0 y1 0
0.0016 0.003202 0.0016 0 y 9.375 10 4
2
0 0.0016 0.003202 0.0016 y3 9.375 10 4
0 0 0 1 y 4 0
The above equations can be solved using on of the iterative methods such as the Gauss-Siedel
method). Solving the equations we get,
y1 0
y
2 0.5852
y3 0.5852
y(50) y( x2 ) y2 0.5852"
y 4 0 15.03.2023
14
Assistant Prof. Dr. Eng. Ibrahim Thamer Nazzal
Engineering Analysis
𝑑2 𝑦
Example :- Solve the following differential equation 𝑥 𝑑𝑥 2 +𝑦 =0
where
Subject to boundary condition 𝑦 1 = 1, 𝑦 2 = 2
Solution-
𝑥𝑖−1 𝑥𝑖−12 𝑥𝑖 𝑥 1 𝑥𝑖+1
𝑖+
𝜕2 𝑓 𝑓 𝑥𝑖+1 −2𝑓 𝑥𝑖 +𝑓(𝑥𝑖−1 ) 2
=
𝜕𝑥 2 ℎ2
𝜕2 𝑓 𝑦𝑖+1 −2𝑦𝑖 +𝑦𝑖−1
=
𝜕𝑥 2 ℎ2
f ( xi 1 ) f ( xi ) + 0(h)
f ' ( xi )
h
17
Assistant Prof. Dr. Eng. Ibrahim Thamer Nazzal 15.03.2023
Engineering Analysis
Finite Difference Approximations of the First Derivative using the Taylor Series
(backward difference)
Assume we can expand a function y f(x) h
f(x) into a Taylor Series about the
point xi-1
xi-1 xi x
f(xi-1)
f(xi)
( 3)
f ' ' ( xi ) f ( xi )
f ( xi 1 ) f ( xi ) f ' ( xi )( xi 1 xi ) ( xi 1 xi ) 2 ( xi 1 xi ) 3
2! 3!
( n)
f ( xi )
... ( xi 1 xi ) n Rn
n! -h
( 3)
f " ( xi ) 2 f ( xi ) 3 f ( n ) ( xi ) n
f ( xi 1 ) f ( xi ) f ' ( xi )h h h h
2! 3! n!
f ( xi ) f ( xi 1 ) f " ( xi ) f (3) ( xi ) 2 f ( n ) ( xi ) n 1
f ' ( xi ) h h h
h 2! 3! n!
f i f ( xi ) f ( xi 1 )
f ( xi ) f ( xi 1 )
f ' ( xi ) O(h ) First backward f ' ( x )
f i
O ( h)
h difference i
h
18
15.03.2023
Numerical Analyses Assistant Prof. Dr. Eng. Ibrahim Thamer Nazzal
Finite Difference Approximations of the Second Derivative using the Taylor
Series (forward difference)
f(x)
y
xi xi+1 xi+2 x
f(xi) h f(xi+2)
f(xi+1)
f " ( xi ) 2 f (3) ( xi ) 3 f ( n ) ( xi ) n
f ( xi 1 ) f ( xi ) f ' ( xi )h h h h (1)
2! 3! n!
f " ( xi ) 2 f (3) ( xi ) 3 f ( n ) ( xi ) n n
f ( xi 2 ) f ( xi ) f ' ( xi )2h 4h 8h 2 h
2! 3! n! (2)
D2 f i D(Df i )
f " ( xi ) 2 O(h) 2
O ( h)
h h
Recursive formula for d2 f Dn f i
any order derivative
2 O ( h)
dxn x xi
h
19
15.03.2023
Numerical Analyses Assistant Prof. Dr. Eng. Ibrahim Thamer Nazzal
Second Derivative Centered Difference Approximation (central difference)
f " ( xi ) 2 f (3) ( xi ) 3
f ( xi 1 ) f ( xi ) f ' ( xi )h h h (1)
2! 3!
( 3)
f " ( xi ) 2 f ( xi ) 3
f ( xi 1 ) f ( xi ) f ' ( xi )h h h (2)
2! 3!
( 4)
f ( xi ) 4
f ( xi 1 ) f ( xi 1 ) 2 f ( xi ) f ( xi )h 2
2
h (1)+(2)
4!
f ( xi 1 ) 2 f ( xi ) f ( xi 1 ) f ( 4) ( xi ) 2
f ( xi ) 2
2 h
h 4!
f ( xi 1 ) 2 f ( xi ) f ( xi 1 )
f ( xi ) 2
O ( h 2
)
h
20
Assistant Prof. Dr. Eng. Ibrahim Thamer Nazzal 15.03.2023
Numerical Analyses
Centered Difference Approximation
f " ( xi ) 2 f (3) ( xi ) 3
f ( xi 1 ) f ( xi ) f ' ( xi )h h h (1)
2! 3!
f " ( xi ) 2 f (3) ( xi ) 3
f ( xi 1 ) f ( xi ) f ' ( xi )h h h (2)
2! 3!
f (3) ( xi ) 3 (1)-(2)
f ( xi 1 ) f ( xi 1 ) 2 f ' ( xi )h 2 h
3!
f ( xi 1 ) f ( xi 1 ) f (3) ( xi ) 2
f ' ( xi ) 2 h
2h 3!
f ( xi 1 ) f ( xi 1 )
f ' ( xi ) O(h 2 )y
2h f(x)
xi xi+1 xi+2
h
x
f(xi)
f(xi+2)
f(xi+1)
21
Assistant Prof. Dr. Eng. Ibrahim Thamer Nazzal 15.03.2023
Numerical Analyses
Higher Order Finite Difference Approximations
f ( xi 1 ) f ( xi ) f " ( xi ) f (3) ( xi ) 2 f ( n ) ( xi ) n 1
f ' ( xi ) h h h
h 2! 3! n!
f ( xi 2 ) 2 f ( xi 1 ) f ( xi 1 )
f " ( xi ) 2
hf ( 3)
( xi )
h
f ( xi 2 ) 2 f ( xi 1 ) f ( xi )
hf ( 3)
( x ) ...
f ( xi 1 ) f ( xi ) h
i
f ' ( xi ) h
h 2!
f (3) ( xi ) 2 f ( n ) ( xi ) n 1
h h
3! n!
f ( xi 2 ) 4 f ( xi 1 ) 3 f ( xi ) h 2
f ' ( xi ) f ' ' ' ( x) ...
2h 3
f ( xi 2 ) 4 f ( xi 1 ) 3 f ( xi )
f ' ( xi ) O(h 2 )
2h
22
Assistant Prof. Dr. Eng. Ibrahim Thamer Nazzal 15.03.2023
Numerical Analyses
First Derivative
23
Assistant Prof. Dr. Eng. Ibrahim Thamer Nazzal 15.03.2023
Numerical Analyses
Second Derivative
24
Assistant Prof. Dr. Eng. Ibrahim Thamer Nazzal 15.03.2023
Numerical Analyses
Finite Difference Methods for Solving PDE's
A partial differential equation (PDE) is an equation that involves an unknown function (the dependent
variable) and some of its partial derivatives with respect to two or more independent variables. The
classification of PDEs is important for the numerical solution you choose. 3 Parabolic
1 Elliptic 2 Hyperbolic For example, the heat or
For example the 1-D
For example, Laplace's diffusion Equation 𝜕𝑢 𝜕2𝑢
wave equation =𝐷
equation: 𝜕 2 𝑢 𝜕 2 𝑢 𝑦 𝜕𝑡 𝜕𝑥 2
𝜕2 𝑢 𝜕2 𝑢
+ 𝑐 2
= 𝑦𝑛
𝜕𝑥 2 𝜕𝑦 2 𝜕𝑥 2 𝜕𝑡 2
Using finite difference method to solve the system
1. Discretize domain into grid of evenly spaced points. 𝑢 𝑖,𝑗+1
2 2
2. For nodes where u is unknown for example :𝜕 𝑢 + 𝜕 𝑢
𝜕𝑥 2 𝜕𝑦 2 𝑦 𝑖 𝑢 𝑖−1,𝑗 𝑢 𝑖,𝑗 𝑢 𝑖+1,𝑗
discretize
𝜕2 𝑢 𝑢𝑖+1,𝑗 −2 𝑢𝑖,𝑗 + 𝑢𝑖−1,𝑗
∆𝑦
= +0 (∆𝑥 2 )
𝜕𝑥 2 (∆𝑥)2 𝑦2 𝑢 𝑖,𝑗−1
𝜕2 𝑢 𝑢𝑖,𝑗+1 −2 𝑢𝑖,𝑗 + 𝑢𝑖,𝑗−1 ∆𝑥
= +0 (∆𝑦 2 ) 𝑦1
𝜕𝑦 2 (∆𝑦)2 𝑥
When ∆𝑥 = ∆𝑦 = ℎ, substitute into main eqaution 𝑥1 𝑥2 𝑥𝑖 𝑥𝑚
𝑢𝑖+1,𝑗 −2 𝑢𝑖,𝑗 + 𝑢𝑖−1,𝑗 𝑢𝑖,𝑗+1 −2 𝑢𝑖,𝑗 + 𝑢𝑖,𝑗−1
𝑢𝑖,𝑗+1
+ + 0 (ℎ2 )
(∆𝑥)2 (∆𝑦)2
𝑢𝑖−1,𝑗 𝑢 𝑖,𝑗 𝑢𝑖+1,𝑗
3. Using Boundary Conditions, write, n*m equations for
u(xi=1:m, yj=1:n) or n*m unknowns.
4. Solve this banded system with an efficient scheme. Using
Gauss-Seidel iteratively. 𝑢𝑖,𝑗−1 25
Assistant Prof. Dr. Eng. Ibrahim Thamer Nazzal 15.03.2023
Numerical Analyses
1 Elliptic equation 𝑢𝑖,𝑗+1
𝜕2 𝑢 𝜕2 𝑢
The Laplace Equation + =0
𝜕𝑥 2 𝜕𝑦 2
The Laplace molecule for ∆𝑥 = ∆𝑦 = ℎ 𝑢𝑖−1,𝑗 𝑢𝑖+1,𝑗
𝑢𝑖+1,𝑗 + 𝑢𝑖−1,𝑗 + 𝑢𝑖,𝑗+1 + 𝑢𝑖,𝑗−1 − 4 𝑢𝑖,𝑗 = 0 𝑢 𝑖,𝑗
1
𝑢𝑖,𝑗 = (𝑢𝑖+1,𝑗 +𝑢𝑖−1,𝑗 + 𝑢𝑖,𝑗+1 + 𝑢𝑖,𝑗−1 ) 𝑢𝑖,𝑗−1
4
This shows that the value of 𝑢𝑖,𝑗 is the average of
its values at the four neighboring diagonal mesh 𝑦 𝑏2,5 𝑏 3,5 𝑏 4,5 𝑏 5,5
points. is called the diagonal five-point formula 𝑏 1,5
which is represented in Figure.
The temperature distribution can be estimated by 𝑏 1,4 𝑏 5,4
discretizing the Laplace equation at 9 points and 𝑢 2,4 𝑢 3,4 𝑢 4,4
solving the system of linear equations.
1 𝑏 1,3 𝑏 5,3
𝑢2,3 = (𝑏 +𝑢3,3 + 𝑢2,4 + 𝑢2,2 ) 𝑢 2,3 𝑢 3,3 𝑢 4,3
4 1,3
∆𝑦
1
𝑢3,4 = (𝑢2,4 +𝑢4,4 + 𝑏3,5 + 𝑢3,3 ) 𝑏 1,2 𝑏5,2
4
𝑢 2,2 𝑢 3,2 𝑢 4,2
1
𝑢4,3 = (𝑢3,3 +𝑏5,3 + 𝑢4,4 + 𝑢4,2 ) ∆𝑥 𝑥
4
𝑏 1,1
1
𝑢3,2 = (𝑢2,2 +𝑢4,2 + 𝑢3,3 + 𝑢3,1 ) 𝑏 2,1 𝑏 3,1 𝑏 4,1 𝑏 5,1
4
26
Assistant Prof. Dr. Eng. Ibrahim Thamer Nazzal 15.03.2023
Numerical Analyses
Having found all the nine values of 𝑢𝑖,𝑗 once, their accuracy is improved by either of the
following iterative methods. In each case, the method is repeated until the difference between
two consecutive iterates becomes negligible.
(i) Jacobi’s method. Denoting the nth iterative value of 𝑢𝑖,𝑗 , by 𝑢𝑛 𝑖,𝑗 , the iterative formula to
solve is
1
𝑢𝑛+1 𝑖,𝑗 = (𝑢 𝑛
𝑖+1,𝑗
+ 𝑢 𝑛
𝑖−1,𝑗 + 𝑢𝑛 𝑖,𝑗+1 + 𝑢𝑛 𝑖,𝑗−1 )
4
It gives improved values of 𝑢𝑖,𝑗 at the interior mesh points and is called the point Jacobi’s
formula.
1
𝑢𝑛+1 𝑖,𝑗 = (𝑢𝑛 𝑖+1,𝑗 + 𝑢𝑛+1 𝑖−1,𝑗 + 𝑢𝑛+1 𝑖,𝑗+1 + 𝑢𝑛 𝑖,𝑗−1 )
4
It utilizes the latest iterative value available and scans the mesh points symmetrically from left
to right along successive rows.
27
Assistant Prof. Dr. Eng. Ibrahim Thamer Nazzal 15.03.2023
Numerical Analyses
Example: A vertical steel plate of dimensions 2.7 cm X 2.7 cm and negligible thickness is in
steady state conditions. On the top edge, the temperature is 1000 C and on the bottom the
temperature is fixed at 500 C. The temperature on the left and right edges are 500 C. Solve to
obtain heat distribution.
𝜕2 𝑇 𝜕2 𝑇
The governing equation is + =0
𝜕𝑥 2 𝜕𝑦 2
𝑇 𝑥 = 2.7, 𝑦 = 500 C ; 𝑇 𝑥 = 0, 𝑦 = 500 C ;
𝑇 𝑥, 𝑦 = 2.7 = 1000 C ; 𝑇 𝑥, 𝑦 = 0 = 500 C.
∆ 𝑥 = ∆ 𝑦 = 0.9 𝑐𝑚.
We know that the diagonal five-point formula
1
𝑢𝑖,𝑗 = 4 (𝑢𝑖+1,𝑗 +𝑢𝑖−1,𝑗 + 𝑢𝑖,𝑗+1 + 𝑢𝑖,𝑗−1 )
𝑦 1000 C
The vertical plate is discretizes below:
We need to find temperatures 𝑇 1,1 , 𝑇 1,2 , 𝑇 2,1 and 𝑇 2,2
𝑇 1,2 𝑇 2,2 2.7 𝑐m
,,, (four unknowns
Apply FDE at node (1,1), 500 C 500 C
𝑇 1,1 𝑇 2,1
50 + 50 + 𝑇1 2 + 𝑇2 1 − 4𝑇1 1 = 0
or
−4𝑇1 1 + 𝑇1 2 + 𝑇2 1 = −100 (1) 𝑥
Node or grid point (1,2), 500 C
50 + 𝑇1 1 + 𝑇2 2 + 100 − 4𝑇1 2 = 0 2.7 𝑐m
or 𝑇1 1 − 4𝑇1 2 + 𝑇2 2 = −150 (2)
28
Assistant Prof. Dr. Eng. Ibrahim Thamer Nazzal 15.03.2023
Numerical Analyses
Node or grid point (2,1),
𝑇1 1 + 50 − 4 𝑇21 + 𝑇2 2 + 50 = 0
or 𝑇1 1 − 4𝑇2 1 + 𝑇2 2 = −100 (3)
Node or grid point (2,2),
𝑇1 2 + 𝑇2 1 − 4 𝑇22 + 100 + 50 = 0
𝑇1 2 + 𝑇2 1 − 4𝑇2 2 = −150 (4)
From equations 1, 2, 3 and 4 we have
−4𝑇1 1 + 𝑇1 2 + 𝑇2 1 = −100 (1)
−4 1 1 0 𝑇1 1 −100
1 −4 0 1 𝑇1 2 −150
=
1 0 −4 1 𝑇2 1 −100
0 1 1 −4 𝑇2 2 −150
solve this system of linear equations. 15.03.2023
29
Assistant Prof. Dr. Eng. Ibrahim Thamer Nazzal
Numerical Analyses
Example Consider steady two-dimensional heat transfer in a long solid body whose cross section
is given in the figure. The temperatures at the selected nodes and the thermal conditions on the
boundaries are as shown. The thermal conductivity of the body is k 180 W/m · °C, and heat is
generated in the body uniformly at a rate of g = 107 10W/m3. Using the finite difference method
with a mesh size of Δx =Δy = 10 cm, determine the temperatures at nodes 1, 2, 3, and 4 and
Analysis: The nodal spacing is given to be Δx =Δx = l = 0.1
m, and the general finite difference form of an interior node
equation for steady two-dimensional heat conduction for the
case of constant heat generation is expressed as
1
𝑢𝑖,𝑗 = (𝑢𝑖+1,𝑗 +𝑢𝑖−1,𝑗 + 𝑢𝑖,𝑗+1 + 𝑢𝑖,𝑗−1 )
4
𝑔𝑛𝑜𝑑𝑒 𝑙 2
𝑇𝑙𝑒𝑓𝑡 + 𝑇𝑡𝑜𝑝 + 𝑇𝑏𝑜𝑡𝑡𝑜𝑚 + 𝑇𝑟𝑖𝑔ℎ𝑡 − 4 𝑇𝑛𝑜𝑑𝑒 + =0
𝑘
There is symmetry about a vertical line passing through
the middle of the region, and thus we need to consider
only half of the region. Then,
𝑇1 = 𝑇2 𝑎𝑛𝑑 𝑇3 = 𝑇4
𝑔𝑙 2
𝑛𝑜𝑑𝑒 1 100 + 120 + 𝑇2 + 𝑇3 − 4 𝑇1 + =0
𝑘
𝑔𝑙 2
𝑛𝑜𝑑𝑒 3 150 + 200 + 𝑇1 + 𝑇4 − 4 𝑇3 + =0
noting that 𝑇1 = 𝑇2 and 𝑇 = 𝑇 and substituting 𝑘
3 4
0.12 × 107 The solution of the above system is
200 + 𝑇3 − 3𝑇1 + =0
180
0.1 × 107
2 𝑇1 = 𝑇2 = 411.5 C and 𝑇3 = 𝑇4 = 439 C
350 + 𝑇1 − 3𝑇3 + =0 30
180 Assistant Prof. Dr. Eng. Ibrahim Thamer Nazzal 15.03.2023
Engineering Analysis
Explicit and Implicit methods
Explicit and implicit methods are approaches used in numerical analysis for obtaining
numerical approximations to the solutions of time-dependent differential equations.
Explicit Method = a formulation of equation into a FD equation that expresses one unknown in
terms of the known values or express all future (t + Δt) values, T(x, t + Δt), in terms of current (t)
and previous (t - Δt) information, which is known.
Implicit methods calculate a solution by solving an equation involving both the current state of
the system and the later one or Implicit Schemes express all future (t + Δt) values, T(x, t + Δt),
in terms of other future (t + Δt), current (t), and sometimes previous (t - Δt) information.
𝜕𝑢 𝜕2𝑢
• Solve the p.d.e. =𝐷 unknown values
𝜕𝑡 𝜕𝑥 2
The finite difference approximation to the PDE is then known values
Evaluate the p.d.e. at (i,j), (i = spatial index and j = temporal index
𝜕𝑢
Depending on how is approximated, we have three basic schemes:
𝜕𝑡
1. The explicit method - one unknown or nodal value is directly expressed in terms of known
pivotal values. • The process advancing from a known time level(s) to the unknown time level
is called “time marching”.
In this approaches using a forward difference at time t and a second order central
difference for the space derivatives. 𝜕𝑢 𝜕2𝑢
𝜕2 𝑢
=𝐷
Use a central difference approximation to evaluate at 𝑖, 𝑗 𝜕𝑡 𝜕𝑥 2
𝜕𝑥 2
𝜕2 𝑢 𝑢𝑖+1,𝑗 −2 𝑢𝑖,𝑗 + 𝑢𝑖−1,𝑗 𝑦
ቚ =
𝜕𝑥 2 𝑖,𝑗 (∆𝑥)2 𝑢 𝑖,𝑗+1
unknown values
• Let’s use a forward difference approximation
𝜕𝑢
to evaluate at 𝑖, 𝑗 𝑢 𝑖−1,𝑗 𝑢 𝑖,𝑗 𝑢 𝑖+1,𝑗
𝜕𝑡 known values 𝑢=0
𝜕𝑢 𝑢 𝑥𝑖,𝑗+1 − 𝑢(𝑥𝑖,𝑗 ) 𝑢 =0 ∆𝑡 𝑢 𝑖,𝑗−1
ቤ =
𝜕𝑡 𝑖,𝑗 ∆𝑡
∆𝑥
Substituting into the main equation, one obtain 𝑥
𝑢 = 𝑓(𝑥) 𝑥𝑚
𝑢𝑖,𝑗 +1−𝑢𝑖,𝑗 𝑢𝑖+1,𝑗 −2 𝑢𝑖,𝑗 + 𝑢𝑖−1,𝑗
=D
∆𝑡 (∆𝑥)2
𝑢𝑖+1,𝑗 −2 𝑢𝑖,𝑗 + 𝑢𝑖−1,𝑗 𝐷∆𝑡
𝑢𝑖,𝑗+1 =𝑢𝑖,𝑗 + ∆𝑡 D Define the parameter r as 𝑟=
(∆𝑥)2 (∆𝑥)2
32
Assistant Prof. Dr. Eng. Ibrahim Thamer Nazzal 15.03.2023
Numerical Analyses
(𝑢𝑖,𝑗+1 − 𝑢𝑖,𝑗 ) = 𝑟 (𝑢𝑖+1,𝑗 − 2 𝑢𝑖,𝑗 + 𝑢𝑖−1,𝑗 )
33
Assistant Prof. Dr. Eng. Ibrahim Thamer Nazzal 15.03.2023
Numerical Analyses
2
Example :- Solve the heat conduction equation 𝜕𝑢 = 𝜕 𝑢 using the Explicit Method
𝜕𝑡 𝜕𝑥 2
where
i) 𝑢 = 0 𝑎𝑡 𝑥 = 0 𝑎𝑛𝑑 𝑥 = 1 , 𝑡 > 0 (the boundary condition) 0 < x < 1
1
ii) 𝑢 = 2𝑥 , for 0 ≤ 𝑥 ≤ 2 𝑡 = 0 (the initial condition)
1
𝑢 = 2 1 – 𝑥 , 𝑓𝑜𝑟 ≤ 𝑥 ≤ 1 𝑦
2 ∆𝑡 1 𝑢 𝑖,𝑗+1
Δ 𝑥 = ℎ = 0.1 Δ𝑡 = 0.001 𝑟 = (∆𝑥)2 = 10 𝑢=0
solution 𝑢 𝑖−1,𝑗 𝑢 𝑖+1,𝑗
𝑢 𝑖,𝑗
𝑢=0
u0,0 = 0 , u1,0 = 0.2 , u3,0 = 0.6 , u2,0 = 0.4 u4,0 = 0.8 , u5,0 = 1 , ∆𝑡
u6,0 = 0.8 , u7,0 = 0.6 u8,0 = 0.4 , u9,0 = 0.2 , u10,0 = 0
1
𝑢𝑖,𝑗+1 = 𝑟 𝑢𝑖+1,𝑗 + 1 − 2𝑟 𝑢𝑖,𝑗 + 𝑟 𝑢𝑖−1,𝑗 𝑟= ∆𝑥
10 𝑥
1 1 𝑢 = 𝑓(𝑥) 𝑥𝑚
𝑢𝑖,𝑗+1 = 𝑢𝑖+1,𝑗 + 0.8 𝑢𝑖,𝑗 + 𝑢𝑖−1,𝑗
10 10
when 𝑗 = 0 1 1
1 1 𝑢4,1 = 𝑢5,0 + 0.8 𝑢4, 0 + 𝑢3,0 = 0.8
𝑢1,1 = 𝑢2,0 + 0.8 𝑢1,0 + 𝑢0,0 = 0.2 10 10
10 10 1 1
1 1 𝑢5,1 = 𝑢6,0 + 0.8 𝑢5, 0 + 𝑢4,0 = 1
𝑢2,1 = 𝑢3,0 + 0.8 𝑢2,0 + 𝑢1,0 = 0.4 10 10
10 10
1 1 1 1
𝑢3,1 = 𝑢4,0 + 0.8 𝑢3, 0 + 𝑢2,0 = 0.6 𝑢6,1 = 𝑢7,0 + 0.8 𝑢6, 0 + 𝑢5,0 = 0.8
10 10 10 10
34
Assistant Prof. Dr. Eng. Ibrahim Thamer Nazzal 15.03.2023
Numerical Analyses
35
Assistant Prof. Dr. Eng. Ibrahim Thamer Nazzal 15.03.2023
Numerical Analyses
Example: Consider a steel rod that is subjected to a temperature of 100 𝐶 on the left end and 25
C on the right end. If the rod is of length 0.05 m, use the explicit method to find the temperature
distribution in the rod from 𝑡 = 0 and 𝑡 = 9 seconds. Use ∆𝑥 = 0.01 𝑎𝑛𝑑 ∆𝑡 = 3 𝑠 .
𝑊 𝑘𝑔 𝑗
Given: 𝑘 = 54 𝑚2 𝐾 𝜌 = 7800 𝑚3,𝐶 = 490 𝑘𝑔.𝐾
The initial temperature of the rod is 20 C.
i0 1 2 3 4 5
Solution
T 100 C T 25
0.01m
38
Assistant Prof. Dr. Eng. Ibrahim Thamer Nazzal 15.03.2023
Numerical Analyses
Nodal temperatures when t 9 sec, j :3
T03 100C Boundary Condition
T13 65.953C
T23 39.132C
Interior nodes
T33 27.266C
T43 22.872C
T53 25C Boundary Condition
To better visualize the temperature variation at different locations at different times, the
temperature distribution along the length of the rod at different times is plotted below.
39
Assistant Prof. Dr. Eng. Ibrahim Thamer Nazzal 15.03.2023
Numerical Analyses