Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

4.5: (P)LU factorization for all matrices

So far, we’ve focused on finding (P)LU factorizations of square matrices. But this (P)LU approach extends to every matrix, regardless of its shape or whether the system has a unique solution.


A factorization for every matrix

Multiplying by PP reorders the rows. When no row swaps are needed, we can take P=IP=I and write A=LUA=LU.

The factor LL is always square. The new creature is UU: instead of necessarily being square, it always has the same shape as AA, n×dn\times d.

(n×d)=(n×n)(n×d).(n\times d)=(n\times n)(n\times d).

The role of UU is to give us a system that we can solve from the bottom up. For a general matrix, the useful pattern is a staircase: the first nonzero entries move to the right as we move down the rows, and any zero rows come last. This is row echelon form. It allows us to use the same approach for square and non-square matrices.

As before, we will find the factors by multiplying and matching entries. Chapter 4.6 gives an optional interpretation: UU is the result of using row operations to create echelon form, while LL records the multiples used in those operations and PP records the row swaps.


Row echelon form

The pivot positions form a staircase. Everything to the left of a row’s pivot is zero, and everything below a pivot is zero. A step can skip columns; it need not follow the main diagonal.

In the picture below, each blue pp is a nonzero pivot. Each ∗* can be any number, including zero. The orange staircase separates these entries from the required zeros.

<IPython.core.display.Image object>

For example, each of these matrices is in row echelon form:

[2◯1−304◯2000],[1◯2−1002◯000],[1◯2−11001◯2].\begin{bmatrix}\textcolor{#3d81f6}{\text{\textcircled{2}}}&1&-3\\0&\textcolor{#3d81f6}{\text{\textcircled{4}}}&2\\0&0&0\end{bmatrix},\qquad \begin{bmatrix}\textcolor{#3d81f6}{\text{\textcircled{1}}}&2&-1\\0&0&\textcolor{#3d81f6}{\text{\textcircled{2}}}\\0&0&0\end{bmatrix},\qquad \begin{bmatrix}\textcolor{#3d81f6}{\text{\textcircled{1}}}&2&-1&1\\0&0&\textcolor{#3d81f6}{\text{\textcircled{1}}}&2\end{bmatrix}.

The first has pivots in columns 1 and 2. The other two have pivots in columns 1 and 3: column 2 is skipped. In particular, a pivot need not lie on the main diagonal.

By contrast,

[12−1002003]\begin{bmatrix}1&2&-1\\0&0&2\\0&0&3\end{bmatrix}

is upper triangular but is not in row echelon form: the last two rows begin in the same column. For general linear systems, echelon form gives more useful information than triangular shape alone.

Recognizing row echelon form


Solving systems using (P)LU

Suppose we have a (P)LU factorization of AA, in other words

PA=LU.PA=LU.

Remember, the reason we’d want such a factorization is to efficiently solve for x⃗\vec x in Ax⃗=b⃗.A\vec x=\vec b. With this factorization, multiplying both sides of Ax⃗=b⃗A\vec x=\vec b by PP gives

PAx⃗=Pb⃗.PA\vec x=P\vec b.

Then, using PA=LUPA=LU gives us

LUx⃗=Pb⃗.\boxed{LU\vec x=P\vec b.}

We solve for x⃗\vec x in two stages:

  1. First solve Ly⃗=Pb⃗L\vec y=P\vec b for y⃗\vec y.

  2. Then solve Ux⃗=y⃗U\vec x=\vec y for x⃗\vec x.

The first system always has a unique solution: LL is lower triangular with diagonal entries 1. Forward substitution determines every entry of y⃗\vec y.

The second system may have no solution, one solution, or infinitely many solutions. The echelon form of UU tells us which possibility occurs.


Examples

In the two-stage process outlined above, the act of solving Ly⃗=Pb⃗L\vec y=P\vec b for y⃗\vec y is not new in this section, because LL is still a square lower triangular matrix: we’ve studied this in depth earlier in the chapter. What is new is then solving for x⃗\vec x in Ux⃗=y⃗U\vec x=\vec y, because UU can now be rectangular and is in row echelon form, rather than necessarily being square and upper triangular. So, let’s start by looking at some examples of how to solve for x⃗\vec x in Ux⃗=y⃗U\vec x=\vec y.

Example 1: No solution

Consider

[2−13002000][x1x2x3]=[564].\begin{bmatrix}2&-1&3\\0&0&2\\0&0&0\end{bmatrix} \begin{bmatrix}x_1\\x_2\\x_3\end{bmatrix} =\begin{bmatrix}5\\6\\4\end{bmatrix}.

Written out, these equations are

2x1−x2+3x3=5,2x3=6,0=4.2x_1-x_2+3x_3=5,\qquad 2x_3=6,\qquad 0=4.

The last equation is impossible, so the solution set is empty. There is no need to solve the preceding equations.

Example 2: Solution set is a line

Now consider

[12−1002000][x1x2x3]=[340].\begin{bmatrix}1&2&-1\\0&0&2\\0&0&0\end{bmatrix} \begin{bmatrix}x_1\\x_2\\x_3\end{bmatrix} =\begin{bmatrix}3\\4\\0\end{bmatrix}.

The equations are

x1+2x2−x3=3,2x3=4,0=0.x_1+2x_2-x_3=3,\qquad 2x_3=4,\qquad 0=0.

The zero row causes no contradiction, so we can omit the equation 0=00=0. The pivots are in columns 1 and 3. Keep the corresponding variables, x1x_1 and x3x_3, on the left and move x2x_2 to the right:

x1−x3=3−2x2,2x3=4.x_1-x_3=3-2x_2,\qquad 2x_3=4.

In matrix form, this is

[1−102]⏟upper triangular[x1x3]=[3−2x24].\underbrace{\begin{bmatrix}1&-1\\0&2\end{bmatrix}}_{\text{upper triangular}} \begin{bmatrix}x_1\\x_3\end{bmatrix} =\begin{bmatrix}3-2x_2\\4\end{bmatrix}.

The coefficient matrix is upper triangular with nonzero diagonal entries. For every choice of x2x_2, this system has a unique solution for x1x_1 and x3x_3. This is why we can choose x2x_2 freely: it is a free variable. The variables x1x_1 and x3x_3 are pivot variables.

Let x2=tx_2=t, where t∈Rt\in\mathbb R. Back substitution gives x3=2x_3=2, and then

x1+2t−2=3⟹x1=5−2t.x_1+2t-2=3\quad\Longrightarrow\quad x_1=5-2t.

Thus the entire solution set is

x⃗=[502]+t[−210],t∈R.\boxed{\vec x=\begin{bmatrix}5\\0\\2\end{bmatrix} +t\begin{bmatrix}-2\\1\\0\end{bmatrix},\qquad t\in\mathbb R.}

The solution set in this case is an affine line. Here, we’ve described the solution in vector-parametric form. Each value of t∈Rt\in\mathbb R corresponds to a solution.

Notice that if the right-hand side in the system were instead [341]\begin{bmatrix}3\\4\\1\end{bmatrix}, i.e.

[12−1002000][x1x2x3]=[341],\begin{bmatrix}1&2&-1\\0&0&2\\0&0&0\end{bmatrix} \begin{bmatrix}x_1\\x_2\\x_3\end{bmatrix} =\begin{bmatrix}3\\4\\1\end{bmatrix},

the last equation would be 0=10=1, and there would be no solution.

Example 3: Two free variables

Consider the system

[12−110012][x1x2x3x4]=[34],\begin{bmatrix}1&2&-1&1\\0&0&1&2\end{bmatrix} \begin{bmatrix}x_1\\x_2\\x_3\\x_4\end{bmatrix} =\begin{bmatrix}3\\4\end{bmatrix},

involving the 2×42\times4 matrix UU in echelon form. There are no zero rows, so no consistency conditions arise. Writing out the equations gives

x1+2x2−x3+x4=3,x3+2x4=4.x_1+2x_2-x_3+x_4=3,\qquad x_3+2x_4=4.

The pivot columns are 1 and 3. Keep x1x_1 and x3x_3 on the left and move x2x_2 and x4x_4 to the right:

x1−x3=3−2x2−x4,x3=4−2x4.x_1-x_3=3-2x_2-x_4,\qquad x_3=4-2x_4.

In matrix form, this is

[1−101]⏟upper triangular[x1x3]=[3−2x2−x44−2x4].\underbrace{\begin{bmatrix}1&-1\\0&1\end{bmatrix}}_{\text{upper triangular}} \begin{bmatrix}x_1\\x_3\end{bmatrix} =\begin{bmatrix}3-2x_2-x_4\\4-2x_4\end{bmatrix}.

The coefficient matrix is upper triangular with nonzero diagonal entries. Thus, for every choice of x2x_2 and x4x_4, there is a unique solution for x1x_1 and x3x_3. We can choose x2x_2 and x4x_4 independently, so they are free variables. Let

x2=s,x4=t.x_2=s,\qquad x_4=t.

The second equation gives

x3+2t=4⟹x3=4−2t.x_3+2t=4\quad\Longrightarrow\quad x_3=4-2t.

Substitute into the first equation:

x1+2s−(4−2t)+t=3⟹x1=7−2s−3t.x_1+2s-(4-2t)+t=3 \quad\Longrightarrow\quad x_1=7-2s-3t.

Therefore

x⃗=[7040]+s[−2100]+t[−30−21],s,t∈R.\boxed{ \vec x=\begin{bmatrix}7\\0\\4\\0\end{bmatrix} +s\begin{bmatrix}-2\\1\\0\\0\end{bmatrix} +t\begin{bmatrix}-3\\0\\-2\\1\end{bmatrix},\qquad s,t\in\mathbb R. }

Every pair (s,t)(s,t) gives a solution, and every solution corresponds to a value of ss and tt. The solution set is an affine plane in R4\mathbb R^4. We will formally discuss the concept of lines and planes in spaces higher than R3\mathbb R^3 in Chapter 5.


The full solution set

Counting pivots and free variables

After solving Ly⃗=Pb⃗L\vec y=P\vec b, we can read the number of free variables from the pivots of UU.

For a fixed permutation matrix PP for which PA=LUPA=LU, the echelon factor UU is unique. If UU has rr nonzero rows (equivalently, rr pivots), then the first rr columns of LL are also unique. Finally, the number rr does not depend on the choice of PP, LL, or UU.

Rank is a very important invariant of a matrix: it is a property of AA itself, independent of the factors used to compute it. For now, we define it as the number of pivots in UU. Later, we will see equivalent, more conceptual ways to think about rank.

If there are no zero rows, the consistency condition imposes no restrictions. If there are no pivots, every variable is free whenever the system is consistent.

Above, think of x⃗0\vec x_0 as one specific, or particular, solution to Ax⃗=b⃗A\vec x=\vec b, and think of v⃗1,v⃗2,…,v⃗d−r\vec v_1,\vec v_2,\ldots,\vec v_{d-r} as being the direction vectors that describe ways we can create other solutions from the one particular solution. These vectors satisfy

Av⃗1=Av⃗2=⋯=Av⃗d−r=0⃗.A\vec v_1=A\vec v_2=\cdots=A\vec v_{d-r}=\vec 0.

Think about why this must be true! Hint: What happens if you multiply both sides of x⃗=x⃗0+t1v⃗1+⋯+td−rv⃗d−r\vec x=\vec x_0+t_1\vec v_1+\cdots+t_{d-r}\vec v_{d-r} by AA on the left?


Additional examples

With this more abstract theory in mind, let’s look at several more examples.

Example 4: Finding factors when a pivot skips a column

Let

A=[12−1240−1−27].A=\begin{bmatrix}1&2&-1\\2&4&0\\-1&-2&7\end{bmatrix}.

Let’s compute a (P)LU factorization of AA. Let’s start by finding a lower triangular LL with ones on its diagonal and an echelon UU such that A=LUA=LU. Write

[12−1240−1−27]=[100ℓ2110ℓ31ℓ321][u11u12u130u22u2300u33].\begin{bmatrix}1&2&-1\\2&4&0\\-1&-2&7\end{bmatrix}=\begin{bmatrix}1&0&0\\\ell_{21}&1&0\\\ell_{31}&\ell_{32}&1\end{bmatrix}\begin{bmatrix}u_{11}&u_{12}&u_{13}\\0&u_{22}&u_{23}\\0&0&u_{33}\end{bmatrix}.

Multiplying the factors gives

LU=[u11u12u13ℓ21u11ℓ21u12+u22ℓ21u13+u23ℓ31u11ℓ31u12+ℓ32u22ℓ31u13+ℓ32u23+u33].LU=\begin{bmatrix}u_{11}&u_{12}&u_{13}\\\ell_{21}u_{11}&\ell_{21}u_{12}+u_{22}&\ell_{21}u_{13}+u_{23}\\\ell_{31}u_{11}&\ell_{31}u_{12}+\ell_{32}u_{22}&\ell_{31}u_{13}+\ell_{32}u_{23}+u_{33}\end{bmatrix}.

We match these entries with those of AA.

First row of UU and first column of LL. The first row of UU is [12−1]\begin{bmatrix}1&2&-1\end{bmatrix}. Matching the first column gives ℓ21=2\ell_{21}=2 and ℓ31=−1\ell_{31}=-1.

A=[12−1240−1−27]=[100210−1ℓ321]⏟L[12−10u22u2300u33]⏟U.A=\begin{bmatrix}1&2&-1\\2&4&0\\-1&-2&7\end{bmatrix}=\underbrace{\begin{bmatrix}1&0&0\\\textcolor{orange}{2}&1&0\\\textcolor{orange}{-1}&\ell_{32}&1\end{bmatrix}}_L\underbrace{\begin{bmatrix}\textcolor{orange}{1}&\textcolor{orange}{2}&\textcolor{orange}{-1}\\0&u_{22}&u_{23}\\0&0&u_{33}\end{bmatrix}}_U.

Second row of UU. Matching entries (2,2)(2,2) and (2,3)(2,3) gives

2(2)+u22=4,2(−1)+u23=0,2(2)+u_{22}=4,\qquad 2(-1)+u_{23}=0,

so u22=0u_{22}=0 and u23=2u_{23}=2. The second row of UU is [002]\begin{bmatrix}0&0&2\end{bmatrix}.

A=[12−1240−1−27]=[100210−1ℓ321]⏟L[12−100200u33]⏟U.A=\begin{bmatrix}1&2&-1\\2&4&0\\-1&-2&7\end{bmatrix}=\underbrace{\begin{bmatrix}1&0&0\\2&1&0\\-1&\ell_{32}&1\end{bmatrix}}_L\underbrace{\begin{bmatrix}1&2&-1\\0&\textcolor{orange}{0}&\textcolor{orange}{2}\\0&0&u_{33}\end{bmatrix}}_U.

Find ℓ32\ell_{32} using the actual pivot. Entry (3,2)(3,2) gives

(−1)(2)+ℓ32(0)=−2.(-1)(2)+\ell_{32}(0)=-2.

This is true for every ℓ32\ell_{32}, so it supplies no information. The pivot in row 2 lies in column 3, so use that column instead.

Since the second row of UU has its pivot in the last column, echelon form requires the third row of UU to be zero, so u33=0u_{33}=0. Then, matching entry (3,3)(3,3) gives

(−1)(−1)+2ℓ32+1(0)=7⟹ℓ32=3.(-1)(-1)+2\ell_{32}+1(0)=7\quad\Longrightarrow\quad\ell_{32}=3.

Then we have found

A=[12−1240−1−27]=[100210−131]⏟L[12−1002000]⏟U.A=\begin{bmatrix}1&2&-1\\2&4&0\\-1&-2&7\end{bmatrix}=\underbrace{\begin{bmatrix}1&0&0\\2&1&0\\-1&\textcolor{orange}{3}&1\end{bmatrix}}_L\underbrace{\begin{bmatrix}1&2&-1\\0&0&2\\0&0&\textcolor{orange}{0}\end{bmatrix}}_U.

To verify, we can multiply LL and UU column by column:

  • The first column of LULU is

    L[100]=[12−1].L\begin{bmatrix}1\\0\\0\end{bmatrix}=\begin{bmatrix}1\\2\\-1\end{bmatrix}.
  • The second column of LULU is

    L[200]=2[12−1]=[24−2].L\begin{bmatrix}2\\0\\0\end{bmatrix}=2\begin{bmatrix}1\\2\\-1\end{bmatrix}=\begin{bmatrix}2\\4\\-2\end{bmatrix}.
  • The third column of LULU is

    L[−120]=−1[12−1]+2[013]=[−107].L\begin{bmatrix}-1\\2\\0\end{bmatrix}=-1\begin{bmatrix}1\\2\\-1\end{bmatrix}+2\begin{bmatrix}0\\1\\3\end{bmatrix}=\begin{bmatrix}-1\\0\\7\end{bmatrix}.

These are exactly the columns of AA. Notice that entry (3,3)(3,3) of LL did not factor into any of these calculations. We set it to 1 because of the convention that LL has ones on its diagonal, but changing that bottom-right 1 to 342, for example, would not change the fact that A=LUA=LU.

Since UU has two pivots and three columns, AA is not invertible: for some possible outputs b⃗\vec b of Ax⃗A\vec x, the equation Ax⃗=b⃗A\vec x=\vec b has infinitely many solutions.

To illustrate how we might solve, suppose we need to find x⃗\vec x in Ax⃗=b⃗A\vec x=\vec b, where b⃗=[3109].\vec b=\begin{bmatrix}3\\10\\9\end{bmatrix}. First solve Ly⃗=b⃗L\vec y=\vec b:

[100210−131][y1y2y3]=[3109].\begin{bmatrix}1&0&0\\2&1&0\\-1&3&1\end{bmatrix}\begin{bmatrix}y_1\\y_2\\y_3\end{bmatrix}=\begin{bmatrix}3\\10\\9\end{bmatrix}.

Written out, this gives

y1=3,2y1+y2=10,−y1+3y2+y3=9.y_1=3,\qquad2y_1+y_2=10,\qquad-y_1+3y_2+y_3=9.

This gives y⃗=[340]\vec y=\begin{bmatrix}3\\4\\0\end{bmatrix}. The system Ux⃗=y⃗U\vec x=\vec y is Example 2, so

x⃗=[502]+t[−210],t∈R.\vec x=\begin{bmatrix}5\\0\\2\end{bmatrix}+t\begin{bmatrix}-2\\1\\0\end{bmatrix},\qquad t\in\mathbb R.

If the last entry of b⃗\vec b changes from 9 to 10, then y3=1y_3=1 and the system is inconsistent, since b⃗=[31010]\vec b=\begin{bmatrix}3\\10\\10\end{bmatrix} is not a possible output of Ax⃗A\vec x. When a square matrix AA is not invertible, Ax⃗=b⃗A\vec x=\vec b either has no solution or infinitely many solutions.

Example 5: More unknowns than equations

Consider

A=[−2−43012−11],b⃗=[−23].A=\begin{bmatrix}-2&-4&3&0\\1&2&-1&1\end{bmatrix},\qquad \vec b=\begin{bmatrix}-2\\3\end{bmatrix}.

Let’s compute a (P)LU factorization of AA and use it to solve Ax⃗=b⃗A\vec x=\vec b. First, keep the original row order and seek a lower triangular LL with ones on its diagonal and an echelon UU such that A=LUA=LU. Write

[−2−43012−11]=[10ℓ211][u11u12u13u140u22u23u24].\begin{bmatrix}-2&-4&3&0\\1&2&-1&1\end{bmatrix}=\begin{bmatrix}1&0\\\ell_{21}&1\end{bmatrix}\begin{bmatrix}u_{11}&u_{12}&u_{13}&u_{14}\\0&u_{22}&u_{23}&u_{24}\end{bmatrix}.

Multiplying the factors gives

LU=[u11u12u13u14ℓ21u11ℓ21u12+u22ℓ21u13+u23ℓ21u14+u24].LU=\begin{bmatrix}u_{11}&u_{12}&u_{13}&u_{14}\\\ell_{21}u_{11}&\ell_{21}u_{12}+u_{22}&\ell_{21}u_{13}+u_{23}&\ell_{21}u_{14}+u_{24}\end{bmatrix}.

We match these entries with those of AA.

The first row of UU is the first row of AA, and matching the first column gives −2ℓ21=1-2\ell_{21}=1, so ℓ21=−12\ell_{21}=-\frac12. Matching the remaining entries in the second row gives

(−12)(−4)+u22=2⟹u22=0,(−12)(3)+u23=−1⟹u23=12,(−12)(0)+u24=1⟹u24=1.\begin{aligned} \left(-\frac12\right)(-4)+u_{22}&=2&&\Longrightarrow\quad u_{22}=0,\\ \left(-\frac12\right)(3)+u_{23}&=-1&&\Longrightarrow\quad u_{23}=\frac12,\\ \left(-\frac12\right)(0)+u_{24}&=1&&\Longrightarrow\quad u_{24}=1. \end{aligned}

Hence

A=[10−121][−2−43000121].A=\begin{bmatrix}1&0\\-\frac12&1\end{bmatrix} \begin{bmatrix}-2&-4&3&0\\0&0&\frac12&1\end{bmatrix}.

Now we want to solve for x⃗\vec x in Ax⃗=[−23]A\vec x=\begin{bmatrix}-2\\3\end{bmatrix}. The first stage involves solving for y⃗\vec y in Ly⃗=b⃗L\vec y=\vec b:

[10−121][y1y2]=[−23].\begin{bmatrix}1&0\\-\frac12&1\end{bmatrix}\begin{bmatrix}y_1\\y_2\end{bmatrix}=\begin{bmatrix}-2\\3\end{bmatrix}.

Written out, this gives

y1=−2,−12y1+y2=3,soy⃗=[−22].y_1=-2,\qquad -\frac12y_1+y_2=3, \qquad\text{so}\qquad\vec y=\begin{bmatrix}-2\\2\end{bmatrix}.

The pivot columns of UU are 1 and 3. Set x2=sx_2=s and x4=tx_4=t. Back substitution gives

12x3+t=2⟹x3=4−2t,\frac12x_3+t=2\quad\Longrightarrow\quad x_3=4-2t,
−2x1−4s+3(4−2t)=−2⟹x1=7−2s−3t.-2x_1-4s+3(4-2t)=-2\quad\Longrightarrow\quad x_1=7-2s-3t.

Thus

x⃗=[7040]+s[−2100]+t[−30−21],s,t∈R.\vec x=\begin{bmatrix}7\\0\\4\\0\end{bmatrix} +s\begin{bmatrix}-2\\1\\0\\0\end{bmatrix} +t\begin{bmatrix}-3\\0\\-2\\1\end{bmatrix},\qquad s,t\in\mathbb R.

Now, let’s redo the calculation after swapping the rows. Why? This is not strictly necessary, because we were able to find A=LUA=LU with the necessary conditions. But here it turns out that swapping the two rows of AA will give us a factorization that doesn’t involve fractions. Let’s see. With

P=[0110],PA=[12−11−2−430],Pb⃗=[3−2],P=\begin{bmatrix}0&1\\1&0\end{bmatrix},\qquad PA=\begin{bmatrix}1&2&-1&1\\-2&-4&3&0\end{bmatrix},\qquad P\vec b=\begin{bmatrix}3\\-2\end{bmatrix},

seek factors of the form

L=[10ℓ1],U=[u11u12u13u140u22u23u24].L=\begin{bmatrix}1&0\\\ell&1\end{bmatrix},\qquad U=\begin{bmatrix}u_{11}&u_{12}&u_{13}&u_{14}\\0&u_{22}&u_{23}&u_{24}\end{bmatrix}.

Multiplying gives

LU=[u11u12u13u14ℓu11ℓu12+u22ℓu13+u23ℓu14+u24]=[12−11−2−430]=PA.LU=\begin{bmatrix} u_{11}&u_{12}&u_{13}&u_{14}\\ \ell u_{11}&\ell u_{12}+u_{22}&\ell u_{13}+u_{23}&\ell u_{14}+u_{24} \end{bmatrix} =\begin{bmatrix}1&2&-1&1\\-2&-4&3&0\end{bmatrix}=PA.
PA=[12−11−2−430]=[10ℓ1]⏟L[u11u12u13u140u22u23u24]⏟U.PA=\begin{bmatrix}1&2&-1&1\\-2&-4&3&0\end{bmatrix}=\underbrace{\begin{bmatrix}1&0\\\ell&1\end{bmatrix}}_L\underbrace{\begin{bmatrix}u_{11}&u_{12}&u_{13}&u_{14}\\0&u_{22}&u_{23}&u_{24}\end{bmatrix}}_U.

Match the first row and column. The first row of UU is [12−11]\begin{bmatrix}1&2&-1&1\end{bmatrix}, and matching the first column gives ℓ=−2\ell=-2.

PA=[12−11−2−430]=[10−21]⏟L[12−110u22u23u24]⏟U.PA=\begin{bmatrix}1&2&-1&1\\-2&-4&3&0\end{bmatrix}=\underbrace{\begin{bmatrix}1&0\\\textcolor{orange}{-2}&1\end{bmatrix}}_L\underbrace{\begin{bmatrix}\textcolor{orange}{1}&\textcolor{orange}{2}&\textcolor{orange}{-1}&\textcolor{orange}{1}\\0&u_{22}&u_{23}&u_{24}\end{bmatrix}}_U.

Match the remaining entries. The second row of the product gives

(−2)(2)+u22=−4⟹u22=0,(−2)(−1)+u23=3⟹u23=1,(−2)(1)+u24=0⟹u24=2.\begin{aligned} (-2)(2)+u_{22}&=-4&&\Longrightarrow\quad u_{22}=0,\\ (-2)(-1)+u_{23}&=3&&\Longrightarrow\quad u_{23}=1,\\ (-2)(1)+u_{24}&=0&&\Longrightarrow\quad u_{24}=2. \end{aligned}

Thus

PA=[12−11−2−430]=[10−21]⏟L[12−110012]⏟U.PA=\begin{bmatrix}1&2&-1&1\\-2&-4&3&0\end{bmatrix}=\underbrace{\begin{bmatrix}1&0\\-2&1\end{bmatrix}}_L\underbrace{\begin{bmatrix}1&2&-1&1\\0&\textcolor{orange}{0}&\textcolor{orange}{1}&\textcolor{orange}{2}\end{bmatrix}}_U.

The shapes are (2×4)=(2×2)(2×4)(2\times4)=(2\times2)(2\times4). The second row of UU has its pivot in column 3; column 2 is skipped.

We again want to solve Ax⃗=b⃗A\vec x=\vec b with b⃗=[−23]\vec b=\begin{bmatrix}-2\\3\end{bmatrix}. This time, the first stage is Ly⃗=Pb⃗L\vec y=P\vec b:

[10−21][y1y2]=[3−2].\begin{bmatrix}1&0\\-2&1\end{bmatrix}\begin{bmatrix}y_1\\y_2\end{bmatrix}=\begin{bmatrix}3\\-2\end{bmatrix}.

Written out, this gives

y1=3,−2y1+y2=−2,soy⃗=[34].y_1=3,\qquad -2y_1+y_2=-2, \qquad\text{so}\qquad\vec y=\begin{bmatrix}3\\4\end{bmatrix}.

The system Ux⃗=y⃗U\vec x=\vec y is the one from Example 3. It gives the same solution set as the calculation without a row interchange:

x⃗=[7040]+s[−2100]+t[−30−21],s,t∈R.\vec x=\begin{bmatrix}7\\0\\4\\0\end{bmatrix} +s\begin{bmatrix}-2\\1\\0\\0\end{bmatrix} +t\begin{bmatrix}-3\\0\\-2\\1\end{bmatrix},\qquad s,t\in\mathbb R.

Here every row of UU has a pivot, so every right-hand side is consistent.

PA=[12−11−2−430]=[10−21]⏟L[12−110012]⏟U.PA=\begin{bmatrix}1&2&-1&1\\-2&-4&3&0\end{bmatrix}=\underbrace{\begin{bmatrix}1&0\\-2&1\end{bmatrix}}_L\underbrace{\begin{bmatrix}1&2&-1&1\\0&0&1&2\end{bmatrix}}_U.

There are four unknowns but only two pivots, leaving two free variables.

Both P=IP=I and the row-interchange matrix above give valid factorizations. The factors differ, but both echelon factors have two pivots, so both tell us that rank⁡(A)=2\operatorname{rank}(A)=2.

Example 6: More equations than unknowns

A rectangular system—particularly one involving a tall coefficient matrix, with more rows than columns—can have a unique solution. Consider

A=[112334].A=\begin{bmatrix}1&1\\2&3\\3&4\end{bmatrix}.

Let’s compute a (P)LU factorization of AA, then use it to solve Ax⃗=b⃗A\vec x=\vec b for b⃗=[3811]\vec b=\begin{bmatrix}3\\8\\11\end{bmatrix}. First, seek a lower triangular LL with ones on its diagonal and an echelon UU such that A=LUA=LU. Here LL is 3×33\times3 and UU is 3×23\times2. Write

[112334]=[100ℓ2110ℓ31ℓ321][u11u120u2200].\begin{bmatrix}1&1\\2&3\\3&4\end{bmatrix}=\begin{bmatrix}1&0&0\\\ell_{21}&1&0\\\ell_{31}&\ell_{32}&1\end{bmatrix}\begin{bmatrix}u_{11}&u_{12}\\0&u_{22}\\0&0\end{bmatrix}.

Multiplying the factors gives

LU=[u11u12ℓ21u11ℓ21u12+u22ℓ31u11ℓ31u12+ℓ32u22].LU=\begin{bmatrix}u_{11}&u_{12}\\\ell_{21}u_{11}&\ell_{21}u_{12}+u_{22}\\\ell_{31}u_{11}&\ell_{31}u_{12}+\ell_{32}u_{22}\end{bmatrix}.

We match these entries with those of AA.

First row of UU and first column of LL. Matching the first row gives u11=u12=1u_{11}=u_{12}=1. Matching entries (2,1)(2,1) and (3,1)(3,1) then gives

ℓ21(1)=2,ℓ31(1)=3,\ell_{21}(1)=2,\qquad\ell_{31}(1)=3,

so ℓ21=2\ell_{21}=2 and ℓ31=3\ell_{31}=3.

A=[112334]=[1002103ℓ321]⏟L[110u2200]⏟U.A=\begin{bmatrix}1&1\\2&3\\3&4\end{bmatrix}=\underbrace{\begin{bmatrix}1&0&0\\\textcolor{orange}{2}&1&0\\\textcolor{orange}{3}&\ell_{32}&1\end{bmatrix}}_L\underbrace{\begin{bmatrix}\textcolor{orange}{1}&\textcolor{orange}{1}\\0&u_{22}\\0&0\end{bmatrix}}_U.

Second row of UU. Matching entry (2,2)(2,2) gives

2(1)+u22=3⟹u22=1.2(1)+u_{22}=3\quad\Longrightarrow\quad u_{22}=1.
A=[112334]=[1002103ℓ321]⏟L[110100]⏟U.A=\begin{bmatrix}1&1\\2&3\\3&4\end{bmatrix}=\underbrace{\begin{bmatrix}1&0&0\\2&1&0\\3&\ell_{32}&1\end{bmatrix}}_L\underbrace{\begin{bmatrix}1&1\\0&\textcolor{orange}{1}\\0&0\end{bmatrix}}_U.

Finish the second column of LL. Matching entry (3,2)(3,2) gives

3(1)+ℓ32(1)+1(0)=4⟹ℓ32=1.3(1)+\ell_{32}(1)+1(0)=4\quad\Longrightarrow\quad\ell_{32}=1.

We have found

A=[112334]=[100210311]⏟L[110100]⏟U.A=\begin{bmatrix}1&1\\2&3\\3&4\end{bmatrix}=\underbrace{\begin{bmatrix}1&0&0\\2&1&0\\3&\textcolor{orange}{1}&1\end{bmatrix}}_L\underbrace{\begin{bmatrix}1&1\\0&1\\0&0\end{bmatrix}}_U.

Solve the system. Now we want to solve for x⃗\vec x in Ax⃗=b⃗A\vec x=\vec b, where b⃗=[3811]\vec b=\begin{bmatrix}3\\8\\11\end{bmatrix}. First solve for y⃗\vec y in Ly⃗=b⃗L\vec y=\vec b:

[100210311][y1y2y3]=[3811].\begin{bmatrix}1&0&0\\2&1&0\\3&1&1\end{bmatrix}\begin{bmatrix}y_1\\y_2\\y_3\end{bmatrix}=\begin{bmatrix}3\\8\\11\end{bmatrix}.

Written out, this gives

y1=3,2y1+y2=8,3y1+y2+y3=11,y_1=3,\qquad 2y_1+y_2=8,\qquad 3y_1+y_2+y_3=11,

so y⃗=[320]\vec y=\begin{bmatrix}3\\2\\0\end{bmatrix}. Next, solve Ux⃗=y⃗U\vec x=\vec y:

[110100][x1x2]=[320].\begin{bmatrix}1&1\\0&1\\0&0\end{bmatrix}\begin{bmatrix}x_1\\x_2\end{bmatrix}=\begin{bmatrix}3\\2\\0\end{bmatrix}.

The equations are

x1+x2=3,x2=2,0=0.x_1+x_2=3,\qquad x_2=2,\qquad 0=0.

There are no free variables. The unique solution is x⃗=[12]\displaystyle\vec x=\begin{bmatrix}1\\2\end{bmatrix}.

If the last entry of b⃗\vec b were 12 instead, forward substitution would give y3=1y_3=1. The final equation would then be 0=10=1, so there would be no solution. This is because [3811]\begin{bmatrix}3\\8\\11\end{bmatrix} is a possible output of Ax⃗A\vec x, but [3812]\begin{bmatrix}3\\8\\12\end{bmatrix} is not.

Example 7: A final example

Let

A=[24−2248−44−2−454].A=\begin{bmatrix} 2&4&-2&2\\ 4&8&-4&4\\ -2&-4&5&4 \end{bmatrix}.

Let’s compute a (P)LU factorization of AA. First, try finding a lower triangular LL with ones on its diagonal and an echelon UU such that A=LUA=LU. Write

[24−2248−44−2−454]=[100ℓ2110ℓ31ℓ321][u11u12u13u140u22u23u2400u33u34].\begin{bmatrix}2&4&-2&2\\4&8&-4&4\\-2&-4&5&4\end{bmatrix}=\begin{bmatrix}1&0&0\\\ell_{21}&1&0\\\ell_{31}&\ell_{32}&1\end{bmatrix}\begin{bmatrix}u_{11}&u_{12}&u_{13}&u_{14}\\0&u_{22}&u_{23}&u_{24}\\0&0&u_{33}&u_{34}\end{bmatrix}.

Multiplying the factors gives

LU=[u11u12u13u14ℓ21u11ℓ21u12+u22ℓ21u13+u23ℓ21u14+u24ℓ31u11ℓ31u12+ℓ32u22ℓ31u13+ℓ32u23+u33ℓ31u14+ℓ32u24+u34].LU=\begin{bmatrix}u_{11}&u_{12}&u_{13}&u_{14}\\\ell_{21}u_{11}&\ell_{21}u_{12}+u_{22}&\ell_{21}u_{13}+u_{23}&\ell_{21}u_{14}+u_{24}\\\ell_{31}u_{11}&\ell_{31}u_{12}+\ell_{32}u_{22}&\ell_{31}u_{13}+\ell_{32}u_{23}+u_{33}&\ell_{31}u_{14}+\ell_{32}u_{24}+u_{34}\end{bmatrix}.

We match these entries with those of AA.

Step 1: find the first row and first column. Since the first row of the product equals the first row of UU, that row is [24−22]\begin{bmatrix}2&4&-2&2\end{bmatrix}. Matching the first column gives

2ℓ21=4,2ℓ31=−2,soℓ21=2,ℓ31=−1.2\ell_{21}=4,\qquad 2\ell_{31}=-2, \qquad\text{so}\qquad \ell_{21}=2,\quad\ell_{31}=-1.
A=[24−2248−44−2−454]=[100210−1ℓ321]⏟L[24−220u22u23u2400u33u34]⏟U.A=\begin{bmatrix}2&4&-2&2\\4&8&-4&4\\-2&-4&5&4\end{bmatrix}=\underbrace{\begin{bmatrix}1&0&0\\\textcolor{orange}{2}&1&0\\\textcolor{orange}{-1}&\ell_{32}&1\end{bmatrix}}_L\underbrace{\begin{bmatrix}\textcolor{orange}{2}&\textcolor{orange}{4}&\textcolor{orange}{-2}&\textcolor{orange}{2}\\0&u_{22}&u_{23}&u_{24}\\0&0&u_{33}&u_{34}\end{bmatrix}}_U.

Step 2: try to find the second row. Matching entries (2,2)(2,2), (2,3)(2,3), and (2,4)(2,4) gives

2(4)+u22=8⟹u22=0,2(−2)+u23=−4⟹u23=0,2(2)+u24=4⟹u24=0.\begin{aligned} 2(4)+u_{22}&=8&&\Longrightarrow\quad u_{22}=0,\\ 2(-2)+u_{23}&=-4&&\Longrightarrow\quad u_{23}=0,\\ 2(2)+u_{24}&=4&&\Longrightarrow\quad u_{24}=0. \end{aligned}

Thus the second row of UU must be zero.

The attempted factorization now has the form

A=[24−2248−44−2−454]=[100210−1ℓ321]⏟L[24−22000000u33u34]⏟U.A=\begin{bmatrix}2&4&-2&2\\4&8&-4&4\\-2&-4&5&4\end{bmatrix}=\underbrace{\begin{bmatrix}1&0&0\\2&1&0\\-1&\ell_{32}&1\end{bmatrix}}_L\underbrace{\begin{bmatrix}2&4&-2&2\\0&\textcolor{orange}{0}&\textcolor{orange}{0}&\textcolor{orange}{0}\\0&0&u_{33}&u_{34}\end{bmatrix}}_U.

Can we finish in this row order? If UU is in echelon form, its third row must then also be zero. But matching entry (3,3)(3,3) would require

(−1)(−2)+ℓ32(0)+1(0)=5,(-1)(-2)+\ell_{32}(0)+1(0)=5,

which says 2=52=5. No choice of ℓ32\ell_{32} can make this true. We need to change the row order.

Step 3: swap the second and third rows. Let

P=[100001010],PA=[24−22−2−45448−44].P=\begin{bmatrix}1&0&0\\0&0&1\\0&1&0\end{bmatrix}, \qquad PA=\begin{bmatrix}2&4&-2&2\\-2&-4&5&4\\4&8&-4&4\end{bmatrix}.

The first row of UU stays the same. Matching the first column in this new order gives ℓ21=−1\ell_{21}=-1 and ℓ31=2\ell_{31}=2: the two entries we had already found exchange places. We now find the remaining entries for this reordered matrix.

PA=[24−22−2−45448−44]=[100−1102ℓ321]⏟L[24−220u22u23u2400u33u34]⏟U.PA=\begin{bmatrix}2&4&-2&2\\-2&-4&5&4\\4&8&-4&4\end{bmatrix}=\underbrace{\begin{bmatrix}1&0&0\\\textcolor{orange}{-1}&1&0\\\textcolor{orange}{2}&\ell_{32}&1\end{bmatrix}}_L\underbrace{\begin{bmatrix}2&4&-2&2\\0&u_{22}&u_{23}&u_{24}\\0&0&u_{33}&u_{34}\end{bmatrix}}_U.

Step 4: find the new second row of UU. Matching entries (2,1)(2,1), (2,2)(2,2), (2,3)(2,3), and (2,4)(2,4) of LULU with those of PAPA gives

−2+u21=−2⟹u21=0,−4+u22=−4⟹u22=0,2+u23=5⟹u23=3,−2+u24=4⟹u24=6.\begin{aligned} -2+u_{21}&=-2 &&\Longrightarrow\quad u_{21}=0,\\ -4+u_{22}&=-4 &&\Longrightarrow\quad u_{22}=0,\\ 2+u_{23}&=5 &&\Longrightarrow\quad u_{23}=3,\\ -2+u_{24}&=4 &&\Longrightarrow\quad u_{24}=6. \end{aligned}

The second row of UU is [0036]\begin{bmatrix}0&0&3&6\end{bmatrix}. Its pivot is in column 3; column 2 is skipped.

PA=[24−22−2−45448−44]=[100−1102ℓ321]⏟L[24−22003600u33u34]⏟U.PA=\begin{bmatrix}2&4&-2&2\\-2&-4&5&4\\4&8&-4&4\end{bmatrix}=\underbrace{\begin{bmatrix}1&0&0\\-1&1&0\\2&\ell_{32}&1\end{bmatrix}}_L\underbrace{\begin{bmatrix}2&4&-2&2\\\textcolor{orange}{0}&\textcolor{orange}{0}&\textcolor{orange}{3}&\textcolor{orange}{6}\\0&0&u_{33}&u_{34}\end{bmatrix}}_U.

Step 5: use the pivot to find ℓ32\ell_{32}. At this point the factors have the form

L=[100−1102ℓ321],U=[24−220036000u34].L=\begin{bmatrix}1&0&0\\-1&1&0\\2&\ell_{32}&1\end{bmatrix}, \qquad U=\begin{bmatrix}2&4&-2&2\\0&0&3&6\\0&0&0&u_{34}\end{bmatrix}.

Why are the first three entries of the last row of UU zero? Its pivot, if it has one, must lie to the right of the second row’s pivot.

Matching entry (3,2)(3,2) gives

2(4)+ℓ32(0)=8.2(4)+\ell_{32}(0)=8.

This is already true and tells us nothing about ℓ32\ell_{32}. Instead, use column 3, where the second row has its pivot:

2(−2)+3ℓ32=−4⟹ℓ32=0.2(-2)+3\ell_{32}=-4 \quad\Longrightarrow\quad \ell_{32}=0.
PA=[24−22−2−45448−44]=[100−110201]⏟L[24−220036000u34]⏟U.PA=\begin{bmatrix}2&4&-2&2\\-2&-4&5&4\\4&8&-4&4\end{bmatrix}=\underbrace{\begin{bmatrix}1&0&0\\-1&1&0\\2&\textcolor{orange}{0}&1\end{bmatrix}}_L\underbrace{\begin{bmatrix}2&4&-2&2\\0&0&3&6\\0&0&\textcolor{orange}{0}&u_{34}\end{bmatrix}}_U.

Step 6: finish the last row and check. Matching entry (3,4)(3,4) gives

2(2)+0(6)+u34=4⟹u34=0.2(2)+0(6)+u_{34}=4 \quad\Longrightarrow\quad u_{34}=0.

Therefore

PA=[24−22−2−45448−44]=[100−110201]⏟L[24−2200360000]⏟U.PA=\begin{bmatrix}2&4&-2&2\\-2&-4&5&4\\4&8&-4&4\end{bmatrix}=\underbrace{\begin{bmatrix}1&0&0\\-1&1&0\\2&0&1\end{bmatrix}}_L\underbrace{\begin{bmatrix}2&4&-2&2\\0&0&3&6\\0&0&0&\textcolor{orange}{0}\end{bmatrix}}_U.

To check, multiply LL by each column of UU:

L[200]=[2−24],L[400]=[4−48],L[−230]=[−25−4],L[260]=[244].\begin{aligned} L\begin{bmatrix}2\\0\\0\end{bmatrix}&=\begin{bmatrix}2\\-2\\4\end{bmatrix},& L\begin{bmatrix}4\\0\\0\end{bmatrix}&=\begin{bmatrix}4\\-4\\8\end{bmatrix},\\ L\begin{bmatrix}-2\\3\\0\end{bmatrix}&=\begin{bmatrix}-2\\5\\-4\end{bmatrix},& L\begin{bmatrix}2\\6\\0\end{bmatrix}&=\begin{bmatrix}2\\4\\4\end{bmatrix}. \end{aligned}

These are exactly the columns of PAPA. There are two pivots, so the rank is 2. When solving a consistent system with this matrix, x2x_2 and x4x_4 are free variables.

Reading an echelon system

To recap, the echelon form tells us how to read the solution set.


Another convention for PLU factorization

If PA=LUPA=LU, multiplying both sides on the left by P−1P^{-1} gives

A=P−1LU.A=P^{-1}LU.

The inverse of a permutation matrix is also a permutation matrix: it undoes the row reordering. Setting P′=P−1P'=P^{-1}, we can therefore state the theorem another way: every matrix AA can be written as

A=P′LU,A=P'LU,

where P′P' is a permutation matrix, LL is lower triangular with ones on the diagonal, and UU is in row echelon form. Some references use this convention and call it the PLU factorization, or PLU decomposition, of AA.