Artificial Intelligence 🤖
Matrices
LU decomposition

LU decomposition

In this section we focus again on solving linear systems given by Ax=bA \boldsymbol{x}=\boldsymbol{b}. However now we discuss a method that allows us to solve the matrix equation above with different vectors b\boldsymbol{b} without repeating the whole process for each case. The LUL U decomposition records the steps of Gaussian elimination by decomposing AA into a lower and an upper triangular matrix. Suppose that we can write AA as

A=LUA=L U

for some lower triangular matrix LL and some upper triangular matrix UU. Then the matrix equation above becomes,

LUx=bL U \boldsymbol{x}=\boldsymbol{b}

we let z=Ux\boldsymbol{z}=U \boldsymbol{x} which, when substituted in Eq. (10.70), yields,

Lz=b.L \boldsymbol{z}=\boldsymbol{b} .

Thus, in order to solve Eq. (10.70), we solve (10.71) for z\boldsymbol{z} and then use z=Ux\boldsymbol{z}=U \boldsymbol{x} to solve for x\boldsymbol{x}. We illustrate the ideas with an example. Consider the matrix,

A=(1231351512)A=\left(\begin{array}{ccc} 1 & 2 & 3 \\ 1 & 3 & 5 \\ 1 & 5 & 12 \end{array}\right)

We want to write it in the following form

A=(000)(000),A=\left(\begin{array}{lll} \star & 0 & 0 \\ \star & \star & 0 \\ \star & \star & \star \end{array}\right)\left(\begin{array}{lll} \star & \star & \star \\ 0 & \star & \star \\ 0 & 0 & \star \end{array}\right),

where the stars indicate possibly nonzero entries. The stars represent 12 unknowns in LL and UU but we only have 9 equations for the entries in matrix AA. To make progress, we choose the diagonal entries of the lower triangular matrix to be all unity,

L=(100101)L=\left(\begin{array}{ccc} 1 & 0 & 0 \\ \star & 1 & 0 \\ \star & \star & 1 \end{array}\right)

It follows that the first row of UU must be the first row of AA giving,

U=(123000)U=\left(\begin{array}{lll} 1 & 2 & 3 \\ 0 & \star & \star \\ 0 & 0 & \star \end{array}\right)

Between LL and UU, we now have 6 unknowns which can be solved for by solving 6 equations. Alternatively, we can reduce the coefficient matrix AA to upper triangular form, keeping track of row operations used. The latter is done through the use of elementary matrices (see Subsec. 10.3.1).

Starting with the coefficient matrix AA given in Eq. (10.72), we perform (R2R1)(R2)\left(R_{2}-R_{1}\right) \rightarrow\left(R_{2}\right) which is represented by the elementary matrix,

E1=(100110001)E_{1}=\left(\begin{array}{ccc} 1 & 0 & 0 \\ -1 & 1 & 0 \\ 0 & 0 & 1 \end{array}\right)

Recall that to perform this row operation on AA, we need to pre-multiply AA by the elementary matrix E1E_{1} yielding,

E1A=(1230121512)E_{1} A=\left(\begin{array}{ccc} 1 & 2 & 3 \\ 0 & 1 & 2 \\ 1 & 5 & 12 \end{array}\right)

Next, we continue with (R3R1)(R3)\left(R_{3}-R_{1}\right) \rightarrow\left(R_{3}\right) represented by the elementary matrix

E2=(100010101)E_{2}=\left(\begin{array}{ccc} 1 & 0 & 0 \\ 0 & 1 & 0 \\ -1 & 0 & 1 \end{array}\right)

and pre-multiplying E1AE_{1} A by E2E_{2} gives,

E2E1A=(123012039).E_{2} E_{1} A=\left(\begin{array}{lll} 1 & 2 & 3 \\ 0 & 1 & 2 \\ 0 & 3 & 9 \end{array}\right) .

Finally, we undertake (R33R2)(R3)\left(R_{3}-3 R_{2}\right) \rightarrow\left(R_{3}\right) represented by the elementary matrix

E3=(100010031)E_{3}=\left(\begin{array}{ccc} 1 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & -3 & 1 \end{array}\right)

and E3E2E1AE_{3} E_{2} E_{1} A gives,

E3E2E1A=(123012003)=UE_{3} E_{2} E_{1} A=\left(\begin{array}{lll} 1 & 2 & 3 \\ 0 & 1 & 2 \\ 0 & 0 & 3 \end{array}\right)=U

So far we have

E3E2E1A=UE_{3} E_{2} E_{1} A=U

where the elementary matrices are given by Eqs. (10.76), (10.78), and (10.80). From Eq. (10.82), we have,

A=E11E21E31LUA=\underbrace{E_{1}^{-1} E_{2}^{-1} E_{3}^{-1}}_{L} U

It follows that by taking the inverses of the elementary matrices in reverse order, we obtain LL,

L=(100110001)(100010101)(100010031)=(100110131)L=\left(\begin{array}{lll} 1 & 0 & 0 \\ 1 & 1 & 0 \\ 0 & 0 & 1 \end{array}\right)\left(\begin{array}{lll} 1 & 0 & 0 \\ 0 & 1 & 0 \\ 1 & 0 & 1 \end{array}\right)\left(\begin{array}{lll} 1 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 3 & 1 \end{array}\right)=\left(\begin{array}{lll} 1 & 0 & 0 \\ 1 & 1 & 0 \\ 1 & 3 & 1 \end{array}\right)

The LUL U decomposition is therefore,

A=(100110131)(123012003)A=\left(\begin{array}{lll} 1 & 0 & 0 \\ 1 & 1 & 0 \\ 1 & 3 & 1 \end{array}\right)\left(\begin{array}{lll} 1 & 2 & 3 \\ 0 & 1 & 2 \\ 0 & 0 & 3 \end{array}\right)

Suppose we wish to calculate the solution of Ax=bA \boldsymbol{x}=\boldsymbol{b} for b=(2,4,5)\boldsymbol{b}=(2,4,5)^{\top}. We first solve the lower triangular system Lz=bL \boldsymbol{z}=\boldsymbol{b},

(100110131)(z1z2z3)=(245)\left(\begin{array}{lll} 1 & 0 & 0 \\ 1 & 1 & 0 \\ 1 & 3 & 1 \end{array}\right)\left(\begin{array}{l} z_{1} \\ z_{2} \\ z_{3} \end{array}\right)=\left(\begin{array}{l} 2 \\ 4 \\ 5 \end{array}\right)

This gives z1=2,z2=4z1=2z_{1}=2, z_{2}=4-z_{1}=2, and z3=5z13z2=3z_{3}=5-z_{1}-3 z_{2}=-3. We then solve for Ux=zU \boldsymbol{x}=\boldsymbol{z},

(123012003)(xyz)=(223)\left(\begin{array}{lll} 1 & 2 & 3 \\ 0 & 1 & 2 \\ 0 & 0 & 3 \end{array}\right)\left(\begin{array}{l} x \\ y \\ z \end{array}\right)=\left(\begin{array}{c} 2 \\ 2 \\ -3 \end{array}\right)

This gives x=3,y=4x=-3, y=4, and z=1z=-1.

Exercises

  1. Use LU factorisation for the system Ax=bA \boldsymbol{x}=\boldsymbol{b} where A=(221412432)A=\left(\begin{array}{ccc}2 & -2 & -1 \\ 4 & 1 & -2 \\ 4 & 3 & -2\end{array}\right) and the following values of b\boldsymbol{b} : (a) b=(5,0,4)\boldsymbol{b}^{\top}=(-5,0,4); (b) b=(1,1,9)\boldsymbol{b}^{\top}=(-1,-1,-9); (c) b=(1,8,12)\boldsymbol{b}^{\boldsymbol{\top}}=(-1,8,12).
  2. Use LU factorisation for the system Ax=bA \boldsymbol{x}=\boldsymbol{b} where A=(111232513)A=\left(\begin{array}{ccc}1 & 1 & 1 \\ 2 & 3 & -2 \\ 5 & -1 & -3\end{array}\right) and the following values of b\boldsymbol{b} : (a) b=(4,1,1)\boldsymbol{b}^{\top}=(4,1,1) (b) b=(3,3,5)\boldsymbol{b}^{\boldsymbol{\top}}=(3,-3,5) (c) b=(1,1,9)\boldsymbol{b}^{\top}=(-1,1,9)