Lay Chapter 2,

LU Decomposition

LU Factorization with 2x2 Elementary Matrices

Use premultiplication by elementary matrices to produce the LU factorization.

In[1]:=

Out[3]//MatrixForm=

In[4]:=

Out[6]//MatrixForm=

In[7]:=

Check.

In[8]:=

Out[8]=

LU Factorization with 3x3 Elementary Matrices

Use elementary matrices to produce the LU factorization.

In[9]:=

Out[11]//MatrixForm=

In[12]:=

Out[13]//MatrixForm=

In[14]:=

Out[15]//MatrixForm=

In[16]:=

Check.

In[18]:=

Out[18]=

Solving Ax=b with LU Factorization

Construct the matrices L and U.

In[19]:=

Out[21]//MatrixForm=

In[23]:=

Out[25]//MatrixForm=

In[26]:=

Out[28]//MatrixForm=

In[29]:=

Check.

In[30]:=

Out[30]=

Solve A.x==b by LU Factorization

In[31]:=

In[32]:=

Out[33]=

In[34]:=

Out[35]=

In[36]:=

Out[36]=

Solve A.x==b by row reduction.

In[37]:=

In[38]:=

Out[40]//MatrixForm=

In[41]:=

Out[42]//MatrixForm=

In[43]:=

Out[43]=

In[44]:=

Out[44]=

makeMatrix

Let's write a procedure which creates matrices.

In[45]:=

Generate a few matrices.

New matrices will be generated each time these cells are evaluated.

In[46]:=

Out[48]//MatrixForm=

In[49]:=

Out[50]//MatrixForm=

In[51]:=

Out[52]//MatrixForm=

Solving a 3x3 System of Equations with the LU Decomposition

We wish to solve the linear system represented by the following augmented matrix.

In[53]:=

Out[55]//MatrixForm=

Here is an efficient way to do that -- using the LU decomposition of a square matrix m.

First, extract the relevant components, the matrix m and the vector b.

In[56]:=

In[57]:=

Out[58]//MatrixForm=

In[59]:=

Out[60]//MatrixForm=

Now use the LU decomposition of the square matrix m to solve the original system.

In[61]:=

Out[62]=

In[63]:=

Out[64]//MatrixForm=

Check.

In[65]:=

Out[65]=

Mathematica's LUDecomposition

LUDecomposition returns a triple containing a matrix, a vector, and a condition number.

The matrix returned by LUDecomposition contains both L and U in it.

The nonzero entries of U are on and above its diagonal, and

the entries below its diagonal are the corresponding entries of L.

The procedures Upper and Lower, which are defined below, have been modified from those given in the Mathematica Help Browser.

In[66]:=

Out[70]=

The vector returned by LUDecomposition indicates the permutation of the rows of m that will bring it into conformity with L.U.

In[71]:=

Out[73]//MatrixForm=

Created by Mathematica (February 10, 2005) |