Module

for

Tri-Diagonal Linear Systems

     

Background

    In applications, it is often the case that systems of equations arise where the coefficient matrix has a special structure.  Sparse matrices which contain a majority of zeros occur are often encountered.  It is usually more efficient to solve these systems using a taylor-made algorithm which takes advantage of the special structure.  Important examples are band matrices, and the most common cases are the tridiagonal matrices.  

 

Definition (Tridiagonal Matrix).  An  n×n  matrix A is called a tridiagonal matrix if  [Graphics:Images/Tri-DiagonalMod_gr_1.gif]  whenever [Graphics:Images/Tri-DiagonalMod_gr_2.gif].  A tridiagonal matrix has the for

    
(1)    [Graphics:Images/Tri-DiagonalMod_gr_3.gif].

 

Theorem  Suppose that the tri-diagonal linear system  [Graphics:Images/Tri-DiagonalMod_gr_4.gif]  has  [Graphics:Images/Tri-DiagonalMod_gr_5.gif]  and  [Graphics:Images/Tri-DiagonalMod_gr_6.gif] for [Graphics:Images/Tri-DiagonalMod_gr_7.gif].  If   [Graphics:Images/Tri-DiagonalMod_gr_8.gif],  and  [Graphics:Images/Tri-DiagonalMod_gr_9.gif]  [Graphics:Images/Tri-DiagonalMod_gr_10.gif],  and  [Graphics:Images/Tri-DiagonalMod_gr_11.gif], then there exists a unique solution.  

Proof  Tri-Diagonal Matrices  Tri-Diagonal Matrices  

 

    The enumeration scheme for the elements [Graphics:Images/Tri-DiagonalMod_gr_12.gif] in (1) do not take advantage of the overwhelming number of zeros.  If the two subscripts were retained the computer would reserve storage for  [Graphics:Images/Tri-DiagonalMod_gr_13.gif] elements.  Since practical applications involve large values of  [Graphics:Images/Tri-DiagonalMod_gr_14.gif], it is important to devise a more efficient way to label only those elements that will be used and conceptualize the existence of all those off diagonal zeros.  The idea that is often used is to call elements of the main diagonal [Graphics:Images/Tri-DiagonalMod_gr_15.gif], subdiagonal elements [Graphics:Images/Tri-DiagonalMod_gr_16.gif]  are directly below the main diagonal, and the superdiagonal elements  [Graphics:Images/Tri-DiagonalMod_gr_17.gif]  are directly above the main diagonal.  Taking advantage of the single subscripts on [Graphics:Images/Tri-DiagonalMod_gr_18.gif] we can reduce the storage requirement to merely [Graphics:Images/Tri-DiagonalMod_gr_19.gif]  elements.  This bizarre way of looking at a tridiagonal matrix is  

    [Graphics:Images/Tri-DiagonalMod_gr_20.gif].

Observe that A does not have the usual alphabetical connection with its new elements named  [Graphics:Images/Tri-DiagonalMod_gr_21.gif], and that the length of the subdiagonal and superdiagonal is n-1.

 

Definition (tri-diagonal system).  If A is tridiagonal, then a tridiagonal system is

(2)    [Graphics:Images/Tri-DiagonalMod_gr_22.gif]

A tri-diagonal linear system  [Graphics:Images/Tri-DiagonalMod_gr_23.gif]  can be written in the form    

(3)    

[Graphics:Images/Tri-DiagonalMod_gr_24.gif]

[Graphics:Images/Tri-DiagonalMod_gr_25.gif]

  

  

  

  

  

  

=

[Graphics:Images/Tri-DiagonalMod_gr_26.gif]

[Graphics:Images/Tri-DiagonalMod_gr_27.gif]

[Graphics:Images/Tri-DiagonalMod_gr_28.gif]

[Graphics:Images/Tri-DiagonalMod_gr_29.gif]

  

  

  

  

  

=

[Graphics:Images/Tri-DiagonalMod_gr_30.gif]

  

[Graphics:Images/Tri-DiagonalMod_gr_31.gif]

[Graphics:Images/Tri-DiagonalMod_gr_32.gif]

[Graphics:Images/Tri-DiagonalMod_gr_33.gif]

  

  

  

  

=

[Graphics:Images/Tri-DiagonalMod_gr_34.gif]

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

[Graphics:Images/Tri-DiagonalMod_gr_35.gif]

[Graphics:Images/Tri-DiagonalMod_gr_36.gif]

[Graphics:Images/Tri-DiagonalMod_gr_37.gif]

=

[Graphics:Images/Tri-DiagonalMod_gr_38.gif]

  

  

  

  

  

  

[Graphics:Images/Tri-DiagonalMod_gr_39.gif]

[Graphics:Images/Tri-DiagonalMod_gr_40.gif]

=

[Graphics:Images/Tri-DiagonalMod_gr_41.gif]

    

Goals

To understand the "Gaussian elimination process."  
To understand solutions to"large matrices" that are contain mostly zero elements, called "sparse matrices."  
To be aware of the uses for advanced topics in numerical analysis:  
(i)    Used in the construction of cubic splines,
(ii)   Used in the Finite difference solution of boundary value problems,  
(iii)  Used in the solution of parabolic P.D.E.'s.

 

Algorithm (tridiagonal linear system).  Solve a tri-diagonal system  [Graphics:Images/Tri-DiagonalMod_gr_42.gif]  given in (2-3).  
Below diagonal elements:    

[Graphics:Images/Tri-DiagonalMod_gr_43.gif]

[Graphics:Images/Tri-DiagonalMod_gr_44.gif]

[Graphics:Images/Tri-DiagonalMod_gr_45.gif]

  
Main diagonal elements:    

[Graphics:Images/Tri-DiagonalMod_gr_46.gif]

[Graphics:Images/Tri-DiagonalMod_gr_47.gif]

[Graphics:Images/Tri-DiagonalMod_gr_48.gif]

  
Above diagonal elements:    

[Graphics:Images/Tri-DiagonalMod_gr_49.gif]

[Graphics:Images/Tri-DiagonalMod_gr_50.gif]

[Graphics:Images/Tri-DiagonalMod_gr_51.gif]

  
Column vector elements:    

[Graphics:Images/Tri-DiagonalMod_gr_52.gif]

[Graphics:Images/Tri-DiagonalMod_gr_53.gif]

[Graphics:Images/Tri-DiagonalMod_gr_54.gif]

   

Computer Programs  Tri-Diagonal Matrices  Tri-Diagonal Matrices  

Mathematica Subroutine (tri-diagonal linear system).

[Graphics:Images/Tri-DiagonalMod_gr_55.gif]

Example 1.  Create a 31 by 31 tridiagonal matrix A where the main diagonal elements are all "2" and all elements of the subdiagonal and superdiagonal elements are "1."  Then solve the linear system  [Graphics:Images/Tri-DiagonalMod_gr_56.gif]  where  [Graphics:Images/Tri-DiagonalMod_gr_57.gif].  Compute the solution using decimal arithmetic and rational arithmetic.  
Solution 1 (a).
Solution 1 (b).

 

Observation.  The 31×31 matrix A in Example 1 has 961 elements, 870 of which are zeros.  This is an example of a "sparse" matrix.   Do those zeros contribute to the solution ?  Since the matrix is tri-diagonal and diagonally dominant, there are other algorithms which can be used to compute the solution.  Our tri-diagonal subroutine will work, and it requires only  12.3%  as much space to save the necessary information to solve the problem.  In larger matrices the savings will be even more.  It is more efficient to use vectors instead of matrices when you have sparse matrices that are tri-diagonal.  

 

Example 2.  Solve the 31 by 31 system  [Graphics:Images/Tri-DiagonalMod_gr_90.gif]  in Example 1 using our TriDiagonal[a,d,c,b] subroutine.  Compute the solution using decimal arithmetic and rational arithmetic.  
Solution 2 (a).
Solution 2 (b).

 

Example 3.  Solve the 31 by 31 system  [Graphics:Images/Tri-DiagonalMod_gr_111.gif]  in Example 1 using Mathematica's built in TridiagonalSolve[a,d,c,b] procedure.    Compute the solution using decimal arithmetic and rational arithmetic.  
Solution 3 (a).
Solution 3 (b).

 

Conclusion.  If the matrix  [Graphics:Images/Tri-DiagonalMod_gr_135.gif] is tri-diagonal this structure should be considered because the stored zeros do not contribute to the accuracy of the solution and just waste space in the computer. Since tri-diagonal systems occur in the solution of boundary value differential equations, practical problems could easily involve tri-diagonal matrices of dimension 1000 x 1000.  This would involve 1,000,000 entries if a square matrix was used but only 2998 entries if the vector form of the tri-diagonal matrix is used.

 

Example 4.  Solve the 31 by 31 system  [Graphics:Images/Tri-DiagonalMod_gr_136.gif]  in Example 1 using the inverse matrix [Graphics:Images/Tri-DiagonalMod_gr_137.gif] and the computation  [Graphics:Images/Tri-DiagonalMod_gr_138.gif].  
Solution 4 (a).
Solution 4 (b).

 

Research Experience for Undergraduates

Tri-Diagonal Matrices  Tri-Diagonal Matrices  Internet hyperlinks to web sites and a bibliography of articles.  

 

Download this Mathematica Notebook Tri-Diagonal Linear Systems

 

Return to Numerical Methods - Numerical Analysis

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

(c) John H. Mathews 2004