Linear Algebraic Equations: 1.1 Tridiagonal Matrix Algorithm (TDMA)
Linear Algebraic Equations: 1.1 Tridiagonal Matrix Algorithm (TDMA)
Linear Algebraic Equations: 1.1 Tridiagonal Matrix Algorithm (TDMA)
A system of linear algebraic equations can be solved by direct or iterative methods. The direct
methods discussed in this chapter are the TriDiagonal Matrix Algorithm (TDMA) and Gauss
Elimination methods, and the iterative method discussed is the Gauss-Seidel method.
A tridiagonal or block tridiagonal set of linear algebraic equations is formed during the
discretization of ordinary and partial differential equations. The discretization of differential
equations using the finite difference method is discussed in Chapters 5 to 10. All types of linear
algebraic equations can be solved using the Gauss Elimination method, but if the equations are
of tridiagonal type, then TDMA is very fast as compared to the Gauss Elimination method. The
GaussSeidel method is used for the solution of two-dimensional steady heat transfer, which
is discussed in Chapter 10.
ªD E º ª Z º ª F º
«C D E » «Z » «F »
« »« » « »
« C D E » « Z » « F »
« »« » « »
« C D E » « Z » « F »
« » « » « » (1.1)
« »« » « »
« » « » « »
« » « » « »
« »« » « »
« C0 D0 E0 » « Z 0 » « F 0 »
« »« » « »
¬« C0 D0 ¼» ¬« Z 0 ¼» ¬« F 0 ¼»
N linear algebraic equations can be written in the form Ax = d. The matrix A contains elements
on the diagonal (bi, i = 1 to N), sub-diagonal (ai, i = 2 to N), and super-diagonal (ci, i = 1 to
N 1), and thus is called a tridiagonal matrix. The algorithm for the solution of this sort of
linear algebraic equation is called the TriDiagonal Matrix Algorithm or the Thomas algorithm.
1
2 Introduction to Numerical Methods in Chemical Engineering
© C ¹ K
Thus
F C H E
Z Z
K K K K
§ · § C E ·
K K
C E
¨D ¸ ¨D
K K K K
¸ K K
© C ¹ © C ¹ K K
F CH F CH
HK K K K K K K
§ C E · CK
¨D ¸ K
K K
(1.5)
© C ¹ K
a1 = 0; therefore
b1 = b1 (1.6)
and
F
H (1.7)
D
The algorithm for the solution of a tridiagonal set of linear algebraic equations is given below:
(i) Calculate bi and gi for i = 1 to N.
E Z
(ii) Calculate Z 0 H 0 0 0 . Since cN = 0, therefore xN = g N.
C0
E Z
(iii) Calculate Z HK for i = N 1, N 2,
, 3, 2, 1.
K K
K
CK
Linear Algebraic Equations 3
EXAMPLE 1.1 Solve the following set of linear algebraic equations using TDMA
ª º ª Z º ª º
« » «Z » « »
« »« » « »
« » « Z » « »
« »« » « »
« » « Z » « »
« » « Z » « »
« »« » « »
« » « Z » « »
««
¬ »»¼ ««¬ Z »»¼ «« »»
¬ ¼
Solution We have
C D
F
H
D
C E
C D
C
C E
C D
C
F CH
H
C
C E
C D
C
C E
C D
C
4 Introduction to Numerical Methods in Chemical Engineering
C E
C D
C
F CH
H
C
C E
C D
C
F CH
H
C
Now let us compute the solution starting with x7.
Z H
E Z
Z H u
C
E Z u
Z H
C
E Z u
Z H
C
E Z u
Z H
C
E Z
Z H
C
E Z
Z H
C
Linear Algebraic Equations 5
Program 1.1 uses the above method for solving the tridiagonal system of linear algebraic
equations and is given in the Appendix.
EXAMPLE 1.2 Solve the following set of three linear algebraic equations in three variables
using the Gauss Elimination method:
Z Z Z
Z Z Z
Z Z Z
Solution The augmented matrix is
ª º
« »
« »
« »
¬ ¼
Multiply the first equation by and then add it to the second equation. We get
ª º
« »
« »
« »¼
¬
Multiply the first equation by and then add it to the third equation. We get
ª º
« »
« »
« »
¬ ¼
This completes the first stage. Multiply the second equation by and then add it to the
third equation. We get
ª º
« »
« »
« »¼
¬
From the previous equation we get
9.68367x3 = 48.418367
Solving, we get x3 = 5.
From the second equation we get
9.8x2 + 0.6x3 = 42.2
u
Thus Z
From the first equation we get
10x1 + x2 + 2x3 = 44
Linear Algebraic Equations 7
u
Thus Z .
Program 1.2 uses the Gauss elimination method for solving a system of linear algebraic
equations and is given in the Appendix.
EXAMPLE 1.3 Solve the following set of three linear algebraic equations in three variables
using the Gauss Elimination method:
Z Z Z
Z Z Z
Z Z Z
Solution The augmented matrix is
ª º
« »
« »
« »
¬ ¼
Multiply the first equation by and then add it to the second equation. We get
ª º
« »
« »
« »¼
¬
Multiply the first equation by and then add it to the third equation. We get
ª º
« »
« »
« »
¬ ¼
Multiply the second equation by 0.3076923 and then add it to the third equation. We get
ª º
« »
« »
« »¼
¬
x1 = 0.16
B1 x2 = 0.42
x1 = 0.20 x3 = 0.24
x2 = 0.40 70 mol/min x4 = 0.18
x3 = 0.25
x4 = 0.15 D2 x1 = 0.21
x2 = 0.54
x3 = 0.10
x4 = 0.15
x1 = 0.01
x2 = 0.10
B2 x3 = 0.65
x4 = 0.24
Fig. 1.1 Schematic diagram for Example 1.4.
Solution The material balance equations for benzene (1), toluene (2), styrene (3), and xylene
(4) are given below.
Linear Algebraic Equations 9
& $
Z&
&
& $
Z &
&
10 Introduction to Numerical Methods in Chemical Engineering
EXAMPLE 1.5 Solve the following set of three linear algebraic equations in three variables
using the GaussSeidel method:
10x1 + x2 + 2x3 = 44
2x1 + 10x2 + x3 = 51
x1 + 2x2 + 10x3 = 61
Solution It can be seen that the coefficient of x1 is dominant in the first equation, and the
coefficient of x2 and x3 are dominant in the second and third equations, respectively. Thus
ZP ZP
ZP
ZP ZP
ZP
ZP ZP
ZP
Let us assume x2 = 0, x3 = 0. The initial values used will not affect the converged solution, but
will affect the number of iterations required for convergence.
First Iteration:
Z
u
Z
Z
Second Iteration:
u
Z
u
Z
u
Z
The final converged solution is x1 = 3, x 2 = 4, x3 = 5.
Program 1.3 uses the GaussSeidel method for solving a system of linear algebraic equations
and is given in the Appendix.
EXAMPLE 1.6 Solve the following set of three linear algebraic equations in three variables
using the GaussSeidel method:
Z Z Z
Z Z Z
Z Z Z
12 Introduction to Numerical Methods in Chemical Engineering
Solution Let us write the first, second and third equations in the form
ZP ZP
ZP
ZP ZP
ZP
ZP ZP
ZP
Let us assume x2 = 0, x3 = 0.
First Iteration:
Z
Z
Z
Second Iteration:
u
Z
u
Z
Z
The final converged solution is x1 = 3, x2 = 2, x3 = 1.
Exercises
1.1 Solve the following using TDMA:
ª º ª Z º ª º
« » « Z » « »
« »« » « »
« » « Z » « »
« »« » « »
« » « Z » « »
« » « Z » « »
« »« » « »
« » « Z » « »
« » « Z » « »
« »« » « »
¬« ¼» ¬« Z ¼» ¬« ¼»
(Ans: x1 = 111.11, x2 = 122.22, x3 = 133.33, x4 = 144.44, x5 = 155.55,
x6 = 166.66, x7 = 177.77, x8 = 188.88)
Linear Algebraic Equations 13
1.2 Solve the following linear algebraic equations using the Gauss elimination method:
2x1 x2 = 100
x1 + 2x2 x3 = 0
x2 + 2x3 x4 = 0
x3 + 2x4 x5 = 0
x4 + 2x5 x6 = 0
x5 + 2x6 x7 = 0
x6 + 2x7 x8 = 0
x7 + 2x8 = 200
Note that the augmented matrix for this problem is
ª º
« »
« »
« »
« »
« »
« »
« »
« »
« »
« »
«¬ »¼
ZP ZP
ZP
ZP ZP
Z P
ZP ZP
ZP
14 Introduction to Numerical Methods in Chemical Engineering
ZP Z P
ZP
ZP ZP
Z P
Z P
ZP
(Ans: x1 = 111.11, x2 = 122.22, x3 = 133.33, x4 = 144.44, x5 = 155.55,
x6 = 166.66, x7 = 177.77, x8 = 188.88)
1.4 Solve the following linear algebraic equations using the Gauss elimination method:
4x1 + 2x2 + x3 = 11
x1 + 2x2 = 3
2x1 + x2 + 4x3 = 16
Note that the augmented matrix is
ª º
« »
« »
« »
¬ ¼
(Ans: x1 = 1, x2 = 2, x3 = 3)
1.5 Solve the linear algebraic equations of Problem 1.4 using the GaussSeidel method:
Note that for GaussSeidel to converge the equations are expressed in the form
ZP ZP
ZP
ZP
ZP
ZP ZP
ZP
(Ans: x1 = 1, x2 = 2, x3 = 3)
1.6 Solve the following linear algebraic equations using the Gauss elimination method:
Z Z Z
Z Z Z
Z Z Z
(Ans: x1 = 1.2857, x2 = 1.9286, x3 = 2.8571)
Linear Algebraic Equations 15
1.7 Solve the linear algebraic equations of Problem 1.6 using the Gauss-Seidel method:
Note that for GaussSeidel to converge the equations are expressed in the form
ZP ZP
ZP
ZP ZP
ZP
ZP ZP
ZP
(Ans: x1 = 1.2857, x2 = 1.9286, x3 = 2.8571)
1.8 Solve the following linear algebraic equations using the Gauss elimination method:
ª º ª6
º ª º
« « »
« »» «6
»
« »
« »
« » «6 » « »
»« »
« « »
« » «6 » « »
« » «6 » « »
« »« » « »
« » «6 » « »
« » ««6 »
»
« »
« »
« »
« » «6
» « »
« »« » « »
¬« ¼» ¬«6 ¼» ¬« ¼»
Note that for using the Gauss elimination method the equations have to expressed
in the form of augmented matrix as
ª º
« »
« »
« »
« »
« »
« »
« »
« »
« »»
«
« »
« »
«¬ »¼
(Ans: T1,1 = 47.14, T1,2 = 91.25, T1,3 = 182.86, T2,1 = 57.32, T2,2 = 115.00,
T2,3 = 220.18, T3,1 = 47.14, T3,2 = 91.25, T3,3 = 182.86)
16 Introduction to Numerical Methods in Chemical Engineering
1.9 Solve the following linear algebraic equations using the GaussSeidel method:
6 6 6
6 6
6 6
6
6 6
6 6
6
6
6
6
6
6
6
6 6
6
6
6
6 6
6
6 6
6
6 6 6
Note that for GaussSeidel to converge the equations are to be expressed in the
form
6P 6 P
6 P
6P 6 P 6 P
6 P
6P 6 P
6 P
6P 6 P 6 P
6 P
6P 6 P 6 P 6 P
6 P
6P 6 P 6 P
6 P
P P
P 6 6
6
P P P
P 6 6 6
6
P P
P 6 6
6
(Ans: T1,1 = 47.14, T1,2 = 91.25, T1,3 = 182.86, T2,1 = 57.32, T2,2 = 115.00,
T2,3 = 220.18, T3,1 = 47.14, T3,2 = 91.25, T3,3 = 182.86)