Tridiagonal matrix algorithm

From Wikipedia, the free encyclopedia

The tridiagonal matrix algorithm (TDMA), also known as the Thomas algorithm, is a simplified form of Gaussian elimination that can be used to solve tridiagonal systems of equations. A tridiagonal system may be written as

a_i x_{i - 1}  + b_i x_i  + c_i x_{i + 1}  = d_i , \,\!,

where a_1  = 0\, and c_n = 0\,. In matrix form, this system is written as

\left[  \begin{matrix}    {b_1} & {c_1} & {   } & {   } & { 0 } \\     {a_2} & {b_2} & {c_2} & {   } & {   } \\     {   } & {a_3} & {b_3} & \cdot & {   } \\     {   } & {   } & \cdot & \cdot & {c_{n-1}}\\     { 0 } & {   } & {   } & {a_n} & {b_n}\\  \end{matrix} \right] \left[  \begin{matrix}    {x_1 }  \\     {x_2 }  \\     \cdot   \\    \cdot   \\    {x_n }  \\ \end{matrix} \right] = \left[  \begin{matrix}    {d_1 }  \\     {d_2 }  \\     \cdot   \\    \cdot   \\    {d_n }  \\ \end{matrix} \right].

For such systems, the solution can be obtained in O(n) operations instead of O(n3) required by Gaussian elimination. A first sweep eliminates the ai's, and then an (abbreviated) backward substitution produces the solution. Example of such matrices commonly arise from the discretization of 1D problems (e.g. the 1D Poisson problem).

[edit] Algorithm

Forward elimination phase

b'_1 = b_1 \,\!
d'_1 = d_1\,\!
for k = 2 step 1 until n do
m = {{a_k } \over {b'_{k - 1} }}  \,\!
b'_k  = b_k  - mc_{k - 1}    \,\!
d'_k  = d_k  - md'_{k - 1}    \,\!
end loop (k)

Backward substitution phase

x_n  = {{d'_n } \over {b'_n }}   \,\!
for k = n−1 step −1 until 1 do
x_k  = {{d'_k  - c_k x_{k + 1} } \over {b'_k }}  \,\!
end loop (k)

[edit] Variants

In some situations, particularly those involving periodic boundary conditions, a slightly perturbed form of the tridiagonal system may need to be solved:

a_1 x_{n}  + b_1 x_1  + c_1 x_2  = d_1, \,\!
a_i x_{i - 1}  + b_i x_i  + c_i x_{i + 1}  = d_i,\quad\quad i = 2,\ldots,n-1 \,\!
a_n x_{n-1}  + b_n x_n  + c_n x_1  = d_n. \,\!

In this case, we can make use of the Sherman-Morrison formula to avoid the additional operations of Gaussian elimination and still use the Thomas algorithm.

In other situations, the system of equations may be block tridiagonal (see block matrix), with smaller submatrices arranged as the individual elements in the above matrix system(e.g. the 2D Poisson problem). Simplified forms of Gaussian elimination have been developed for these situations.

[edit] References

In other languages