Thomas Algorithm
LU Decomposition for Tri-Diagonal Systems
S.K.PARIDHI
Banded matrix
A band matrix is a sparse matrix whose non-zero entries are
confined to a diagonal band, comprising the main diagonal
and zero or more diagonals on either side.
1 0 0
0 2 0
0 0 3
1 4 0
6 2 5
0 7 3
The matrix can be symmetric, having
the same number of sub- and super-
diagonals. If a matrix has only one
sub- and one super-diagonal, we have
a tridiagonal matrix etc. The number
of super-diagonals is called the upper
bandwidth (two in the example), and
the number of sub-diagonals is the
lower bandwidth (three in the
example). The total number of
diagonals, six in the example, is the
bandwidth.
Banded matrix
What is a TriDiagonal Matrix…??
A tridiagonal matrix is a band matrix that has nonzero
elements only on the main diagonal, the first diagonal
below this, and the first diagonal above the main
diagonal.
Considering a 4 X 4 Matrix
1 4 0 0
3 4 1 0
0 2 3 4
0 0 1 3
𝑎1 𝑏1 0 0
𝑐2 𝑎2 𝑏2 0
0 𝑐3 𝑎3 𝑏3
0 0 𝑐4 𝑎4
Tridiagonal Matrix Algorithm
• Thomas’ algorithm, also called TriDiagonal Matrix Algorithm
(TDMA) is essentially the result of applying Gaussian
elimination to the tridiagonal system of equations.
• A system of simultaneous algebraic equations with nonzero
coefficients only on the main diagonal, the lower diagonal, and
the upper diagonal is called a tridiagonal system of equations.
Generalizing Tridiagonal Matrix
Consider a tridiagonal system of N equations with N
unknowns, 𝑢1, 𝑢2, 𝑢3,··· 𝑢 𝑁as given below:
Generalizing Tridiagonal Matrix
The Matrix can be written as
𝑎𝑖 𝑢𝑖−1 + 𝑏𝑖 𝑢𝑖 + 𝑐𝑖 𝑢𝑖+1 = 𝑑𝑖
Looking at the system of equations, we see that 𝑖 𝑡ℎ unknown can
be
expressed as a function of (𝑖 + 1) 𝑡ℎunknown. That is
𝑢𝑖 = 𝛾𝑖 𝑢𝑖+1 + 𝜌𝑖
𝑢𝑖−1 = 𝛾𝑖−1 𝑢𝑖 + 𝜌𝑖−1
𝑵𝒐𝒕𝒆: 𝑎1 = 0 & 𝑐 𝑁 = 0
Lets solve a problem for clear
understanding..!!
Let us consider the system of equations
3𝑥1 − 𝑥2 + 0𝑥3 = −1
−𝑥1 + 3𝑥2 − 𝑥3 = 7
0𝑥1 − 𝑥2 + 3𝑥3 = 7
Matrix form is
3 −1 0
−1 3 −1
0 −1 3
𝑥1
𝑥2
𝑥3
=
−1
7
7
STAGE I : Converting Mx = r into Ux=𝜌
• Row 1
𝟑𝒙𝒍 − 𝒙 𝟐 = −𝟏
Divide the Equation by 𝑎1, in this case 𝑎1= 3
⇒ 𝒙 𝟏 −
𝟏
𝟑
𝒙 𝟐 =
−𝟏
𝟑
Assuming the coefficient of 𝑥2 as 𝛾1 and the remaining constants as 𝜌1.
Now the equations converts to,
⇒ 𝒙 𝟏 + 𝜸 𝟏 𝒙 𝟐 = 𝝆 𝟏
⇒ 𝝆 𝟏 = −
𝟏
𝟑
, 𝜸 𝟏 = −
𝟏
𝟑
After Changing Row 1
1 𝛾1 0
−1 3 −1
0 −1 3
𝑥1
𝑥2
𝑥3
=
𝜌1
7
7
Converting Mx = r into Ux=𝜌
• Row 2
Multiplying 𝒂 𝟐 (-1) in Row 1 and eliminating 𝒙 𝟏 Row 2
Row 2 −𝑥1 + 3𝑥2– 𝑥3 = 7
𝑎2 x Row 1 −𝑥1– 𝛾1 𝑥2– 0𝑥3 = −𝜌1
Subtracting 𝑥2 3 + 𝛾1 – 𝑥3 = 7 + 𝜌1
𝑥2 3 + 𝛾1 – 𝑥3 = 7 + 𝜌1
Divide by 3 + 𝛾1 ,
Equation becomes 𝒙 𝟐 + 𝜸 𝟐 𝒙 𝟑 = 𝝆 𝟐
𝜸2 =
−1
3 + γ1
= 0.375 𝝆2 =
7 + 𝜌1
3 + γ1
= 2.5
After Changing Row 2
1 𝛾1 0
0 1 𝛾2
0 −1 3
𝑥1
𝑥2
𝑥3
=
𝜌1
𝜌2
7
Converting Mx = r into Ux=𝜌
• Row 3
Multiplying 𝒂 𝟑 (-1) in Row 1 and eliminating 𝒙 𝟐 Row 3
Row 3 −𝑥2 + 3𝑥3 = 7
𝑎3 x Row 2 −𝑥2– 𝛾2 𝑥3 = −𝜌1
Subtracting 3 + 𝛾2 𝑥3 = 7 + 𝜌2
𝑥3 =
7 + 𝜌2
3 + 𝛾2
⇒ 𝜌3
𝝆3 =
7 + 𝜌2
3 + γ2
= 3.619 ⇒ 𝑥3 = 3.619
After Changing Row 3
1 𝛾1 0
0 1 𝛾2
0 0 1
𝑥1
𝑥2
𝑥3
=
𝜌1
𝜌2
𝜌3
STAGE II -> Backward Substitution
1 𝛾1 0
0 1 𝛾2
0 0 1
𝑥1
𝑥2
𝑥3
=
𝜌1
𝜌2
𝜌3
Row 2:
𝑥2 + 𝛾2 𝑥3 = 𝜌2
𝑥2 = 𝜌2 − 𝛾2 𝑥3
Substituting
𝜌2 = 2.5
𝛾2 = −0.375
𝑥2 = 3.857
STAGE II -> Backward Substitution
1 𝛾1 0
0 1 𝛾2
0 0 1
𝑥1
𝑥2
𝑥3
=
𝜌1
𝜌2
𝜌3
Row 1:
𝑥1 + 𝛾1 𝑥2 = 𝜌1
𝑥1 = 𝜌1 − 𝛾1 𝑥2
Substituting
𝜌1 = −0.333
𝛾1 = −0.333
𝑥1 = 0.952
SOLUTION
𝑥1 = 0.952
𝑥2 = 3.857
𝑥3 = 3.619
Why Thomas Algorithm is used ?
• This type of computation is quick.
• Tridiagonal system of equations are most
common.
• Even most of them convert the general system
of equations to tridiagonal system of
equations.
• It’s importance is clearly visible with a large
number of unknowns.
Limitations of Thomas Algorithm
• Algorithm is unstable when
𝑏𝑖 − 𝑎𝑖 𝛾𝑖−1 = 0
• This occurs if the tridiagonal matrix is
singular and in some cases non-singular also.
Singular
Matrix
(Determinant is Zero)
(*Square Matrix)
(It doesn’t have a
Inverse)
Non-Singular
Matrix
(Determinant is Non-Zero)
(*Square Matrix)
(It has a Inverse)
Condition for algorithm to be stable
𝑏𝑖 > 𝑎𝑖 + 𝐶𝑖 for every i.
What can be done when the algorithm is
numerically unstable..??
Pivoting of matrix

Thomas algorithm

  • 1.
    Thomas Algorithm LU Decompositionfor Tri-Diagonal Systems S.K.PARIDHI
  • 2.
    Banded matrix A bandmatrix is a sparse matrix whose non-zero entries are confined to a diagonal band, comprising the main diagonal and zero or more diagonals on either side. 1 0 0 0 2 0 0 0 3 1 4 0 6 2 5 0 7 3
  • 3.
    The matrix canbe symmetric, having the same number of sub- and super- diagonals. If a matrix has only one sub- and one super-diagonal, we have a tridiagonal matrix etc. The number of super-diagonals is called the upper bandwidth (two in the example), and the number of sub-diagonals is the lower bandwidth (three in the example). The total number of diagonals, six in the example, is the bandwidth. Banded matrix
  • 4.
    What is aTriDiagonal Matrix…?? A tridiagonal matrix is a band matrix that has nonzero elements only on the main diagonal, the first diagonal below this, and the first diagonal above the main diagonal. Considering a 4 X 4 Matrix 1 4 0 0 3 4 1 0 0 2 3 4 0 0 1 3 𝑎1 𝑏1 0 0 𝑐2 𝑎2 𝑏2 0 0 𝑐3 𝑎3 𝑏3 0 0 𝑐4 𝑎4
  • 5.
    Tridiagonal Matrix Algorithm •Thomas’ algorithm, also called TriDiagonal Matrix Algorithm (TDMA) is essentially the result of applying Gaussian elimination to the tridiagonal system of equations. • A system of simultaneous algebraic equations with nonzero coefficients only on the main diagonal, the lower diagonal, and the upper diagonal is called a tridiagonal system of equations.
  • 6.
    Generalizing Tridiagonal Matrix Considera tridiagonal system of N equations with N unknowns, 𝑢1, 𝑢2, 𝑢3,··· 𝑢 𝑁as given below:
  • 7.
    Generalizing Tridiagonal Matrix TheMatrix can be written as 𝑎𝑖 𝑢𝑖−1 + 𝑏𝑖 𝑢𝑖 + 𝑐𝑖 𝑢𝑖+1 = 𝑑𝑖 Looking at the system of equations, we see that 𝑖 𝑡ℎ unknown can be expressed as a function of (𝑖 + 1) 𝑡ℎunknown. That is 𝑢𝑖 = 𝛾𝑖 𝑢𝑖+1 + 𝜌𝑖 𝑢𝑖−1 = 𝛾𝑖−1 𝑢𝑖 + 𝜌𝑖−1 𝑵𝒐𝒕𝒆: 𝑎1 = 0 & 𝑐 𝑁 = 0
  • 8.
    Lets solve aproblem for clear understanding..!! Let us consider the system of equations 3𝑥1 − 𝑥2 + 0𝑥3 = −1 −𝑥1 + 3𝑥2 − 𝑥3 = 7 0𝑥1 − 𝑥2 + 3𝑥3 = 7 Matrix form is 3 −1 0 −1 3 −1 0 −1 3 𝑥1 𝑥2 𝑥3 = −1 7 7
  • 9.
    STAGE I :Converting Mx = r into Ux=𝜌 • Row 1 𝟑𝒙𝒍 − 𝒙 𝟐 = −𝟏 Divide the Equation by 𝑎1, in this case 𝑎1= 3 ⇒ 𝒙 𝟏 − 𝟏 𝟑 𝒙 𝟐 = −𝟏 𝟑 Assuming the coefficient of 𝑥2 as 𝛾1 and the remaining constants as 𝜌1. Now the equations converts to, ⇒ 𝒙 𝟏 + 𝜸 𝟏 𝒙 𝟐 = 𝝆 𝟏 ⇒ 𝝆 𝟏 = − 𝟏 𝟑 , 𝜸 𝟏 = − 𝟏 𝟑
  • 10.
    After Changing Row1 1 𝛾1 0 −1 3 −1 0 −1 3 𝑥1 𝑥2 𝑥3 = 𝜌1 7 7
  • 11.
    Converting Mx =r into Ux=𝜌 • Row 2 Multiplying 𝒂 𝟐 (-1) in Row 1 and eliminating 𝒙 𝟏 Row 2 Row 2 −𝑥1 + 3𝑥2– 𝑥3 = 7 𝑎2 x Row 1 −𝑥1– 𝛾1 𝑥2– 0𝑥3 = −𝜌1 Subtracting 𝑥2 3 + 𝛾1 – 𝑥3 = 7 + 𝜌1 𝑥2 3 + 𝛾1 – 𝑥3 = 7 + 𝜌1 Divide by 3 + 𝛾1 , Equation becomes 𝒙 𝟐 + 𝜸 𝟐 𝒙 𝟑 = 𝝆 𝟐 𝜸2 = −1 3 + γ1 = 0.375 𝝆2 = 7 + 𝜌1 3 + γ1 = 2.5
  • 12.
    After Changing Row2 1 𝛾1 0 0 1 𝛾2 0 −1 3 𝑥1 𝑥2 𝑥3 = 𝜌1 𝜌2 7
  • 13.
    Converting Mx =r into Ux=𝜌 • Row 3 Multiplying 𝒂 𝟑 (-1) in Row 1 and eliminating 𝒙 𝟐 Row 3 Row 3 −𝑥2 + 3𝑥3 = 7 𝑎3 x Row 2 −𝑥2– 𝛾2 𝑥3 = −𝜌1 Subtracting 3 + 𝛾2 𝑥3 = 7 + 𝜌2 𝑥3 = 7 + 𝜌2 3 + 𝛾2 ⇒ 𝜌3 𝝆3 = 7 + 𝜌2 3 + γ2 = 3.619 ⇒ 𝑥3 = 3.619
  • 14.
    After Changing Row3 1 𝛾1 0 0 1 𝛾2 0 0 1 𝑥1 𝑥2 𝑥3 = 𝜌1 𝜌2 𝜌3
  • 15.
    STAGE II ->Backward Substitution 1 𝛾1 0 0 1 𝛾2 0 0 1 𝑥1 𝑥2 𝑥3 = 𝜌1 𝜌2 𝜌3 Row 2: 𝑥2 + 𝛾2 𝑥3 = 𝜌2 𝑥2 = 𝜌2 − 𝛾2 𝑥3 Substituting 𝜌2 = 2.5 𝛾2 = −0.375 𝑥2 = 3.857
  • 16.
    STAGE II ->Backward Substitution 1 𝛾1 0 0 1 𝛾2 0 0 1 𝑥1 𝑥2 𝑥3 = 𝜌1 𝜌2 𝜌3 Row 1: 𝑥1 + 𝛾1 𝑥2 = 𝜌1 𝑥1 = 𝜌1 − 𝛾1 𝑥2 Substituting 𝜌1 = −0.333 𝛾1 = −0.333 𝑥1 = 0.952
  • 17.
    SOLUTION 𝑥1 = 0.952 𝑥2= 3.857 𝑥3 = 3.619
  • 18.
    Why Thomas Algorithmis used ? • This type of computation is quick. • Tridiagonal system of equations are most common. • Even most of them convert the general system of equations to tridiagonal system of equations. • It’s importance is clearly visible with a large number of unknowns.
  • 19.
    Limitations of ThomasAlgorithm • Algorithm is unstable when 𝑏𝑖 − 𝑎𝑖 𝛾𝑖−1 = 0 • This occurs if the tridiagonal matrix is singular and in some cases non-singular also. Singular Matrix (Determinant is Zero) (*Square Matrix) (It doesn’t have a Inverse) Non-Singular Matrix (Determinant is Non-Zero) (*Square Matrix) (It has a Inverse)
  • 20.
    Condition for algorithmto be stable 𝑏𝑖 > 𝑎𝑖 + 𝐶𝑖 for every i. What can be done when the algorithm is numerically unstable..?? Pivoting of matrix