Mathematica 9 is now available
 Documentation /  Mathematica Teacher's Edition /  Teacher Tools /  Standard Packages /  LinearAlgebra /

LinearAlgebra`Tridiagonal`

There are many numerical techniques for working with matrices of specific forms. Often these routines are far more efficient than the general case. Frequently, the best way to get an efficient general routine is to reduce the problem systematically to a special case that can be solved efficiently.
In addition, special forms of matrices often come up naturally in solving certain classes of problems. One very useful special type of matrix is the tridiagonal. In these matrices all elements are zero except for elements on the main, super-, and subdiagonal. More precisely, if . Tridiagonal matrices occur in a wide variety of applications, such as the construction of certain splines and the solution of boundary value problems.

Solving matrix equations with tridiagonal matrices.

This loads the package.

In[1]:= <<LinearAlgebra`Tridiagonal`

This defines the list that will give the nonzero diagonals of a matrix.

In[2]:= {a, b, c} =
{{7, 1, 11}, {4, 8, 2, 12}, {5, 9, 3}}

Out[2]=

Here is the matrix m constructed from the list.

In[3]:= m = Table[Switch[
j-i, -1, a[[j]], 0, b[[j]], 1,
c[[j-1]], _, 0], {i, 4}, {j, 4}]

Out[3]=

This displays the matrix using MatrixForm.

In[4]:= MatrixForm[%]

Out[4]//MatrixForm=

This gives the vector x that solves the equation m.x == {2, 3, 4, 5}.

In[5]:= TridiagonalSolve[a, b, c, {2, 3, 4, 5}]

Out[5]=

TridiagonalSolve uses Gaussian elimination and back substitution. No pivoting is done. If a pivot happens to be zero, this introduces an Infinity. If the matrix is diagonally dominate, which is the case in certain applications, no pivoting is necessary.

You can solve equations containing real and complex numbers as well as symbolic quantities.

In[6]:= TridiagonalSolve[
{2.2, 5.2},
{4.3, 3.22, 2.1},
{8.1 + I, 3.4},
{1, 2.3 I , 3}]

Out[6]=



Any questions about topics on this page? Click here to get an individual response.Buy NowMore Information
THIS IS DOCUMENTATION FOR AN OBSOLETE PRODUCT.