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.
Multiplying by P reorders the rows. When no row swaps are needed, we can take P=I and write A=LU.
The factor L is always square. The new creature is U: instead of necessarily being square, it always has the same shape as A, n×d.
(n×d)=(n×n)(n×d).
The role of U 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: U is the result of using row operations to create echelon form, while L records the multiples used in those operations and P records the row swaps.
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 p is a nonzero pivot. Each ∗ can be any number, including zero. The orange staircase separates these entries from the required zeros.
import plotly.graph_objects as go
from IPython.display import Image, display
pivot_columns = [1, 3, 4, 6]
fig = go.Figure()
for row in range(1, 6):
pivot = pivot_columns[row - 1] if row <= 4 else 8
for col in range(1, 8):
value = "0" if col < pivot else ("p" if col == pivot else "∗")
color = "#3d81f6" if col == pivot else "#222222"
fig.add_annotation(x=col, y=row, text=value, showarrow=False,
font=dict(size=27, color=color))
# Follow the boundary below each pivot row, then step down before the next pivot.
fig.add_trace(go.Scatter(
x=[0.5, 0.5, 2.5, 2.5, 3.5, 3.5, 5.5, 5.5, 7.5],
y=[0.5, 1.5, 1.5, 2.5, 2.5, 3.5, 3.5, 4.5, 4.5],
mode="lines", line=dict(color="orange", width=3), hoverinfo="skip"))
for x, inner in [(0.15, 0.35), (7.85, 7.65)]:
fig.add_trace(go.Scatter(x=[inner, x, x, inner], y=[0.5, 0.5, 5.5, 5.5],
mode="lines", line=dict(color="#222222", width=2),
hoverinfo="skip"))
fig.add_annotation(x=8.1, y=5, text="Zero rows<br>come last", xanchor="left",
showarrow=False, font=dict(size=20))
fig.add_annotation(x=4, y=6.1, text="Pivots move strictly to the right as we move down.",
showarrow=False, font=dict(size=20))
fig.update_layout(width=860, height=430, margin=dict(l=25, r=20, t=20, b=15),
showlegend=False, paper_bgcolor="white", plot_bgcolor="white",
font=dict(family="Palatino", color="black"),
xaxis=dict(range=[-0.1, 10.4], visible=False, fixedrange=True),
yaxis=dict(range=[6.6, 0], visible=False, fixedrange=True))
png = fig.to_image(format="png", scale=2)
display(Image(data=png, width=860, alt="An echelon matrix with pivots in columns 1, 3, 4, and 6, an orange staircase below the pivots, and a final zero row."))
For example, each of these matrices is in row echelon form:
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,
⎣⎡100200−123⎦⎤
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.
Suppose we have a (P)LU factorization of A, in other words
PA=LU.
Remember, the reason we’d want such a factorization is to efficiently solve for x in Ax=b. With this factorization, multiplying both sides of Ax=b by P gives
PAx=Pb.
Then, using PA=LU gives us
LUx=Pb.
We solve for x in two stages:
First solve Ly=Pb for y.
Then solve Ux=y for x.
The first system always has a unique solution: L is lower triangular with diagonal entries 1. Forward substitution determines every entry of y.
The second system may have no solution, one solution, or infinitely many solutions. The echelon form of U tells us which possibility occurs.
In the two-stage process outlined above, the act of solving Ly=Pb for y is not new in this section, because L 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 in Ux=y, because U 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 in Ux=y.
The zero row causes no contradiction, so we can omit the equation 0=0. The pivots are in columns 1 and 3. Keep the corresponding variables, x1 and x3, on the left and move x2 to the right:
x1−x3=3−2x2,2x3=4.
In matrix form, this is
upper triangular[10−12][x1x3]=[3−2x24].
The coefficient matrix is upper triangular with nonzero diagonal entries. For every choice of x2, this system has a unique solution for x1 and x3. This is why we can choose x2 freely: it is a free variable. The variables x1 and x3 are pivot variables.
Let x2=t, where t∈R. Back substitution gives x3=2, and then
x1+2t−2=3⟹x1=5−2t.
Thus the entire solution set is
x=⎣⎡502⎦⎤+t⎣⎡−210⎦⎤,t∈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∈R corresponds to a solution.
Notice that if the right-hand side in the system were instead ⎣⎡341⎦⎤, i.e.
⎣⎡100200−120⎦⎤⎣⎡x1x2x3⎦⎤=⎣⎡341⎦⎤,
the last equation would be 0=1, and there would be no solution.
The coefficient matrix is upper triangular with nonzero diagonal entries. Thus, for every choice of x2 and x4, there is a unique solution for x1 and x3. We can choose x2 and x4 independently, so they are free variables. Let
Every pair (s,t) gives a solution, and every solution corresponds to a value of s and t. The solution set is an affine plane in R4. We will formally discuss the concept of lines and planes in spaces higher than R3 in Chapter 5.
After solving Ly=Pb, we can read the number of free variables from the pivots of U.
For a fixed permutation matrix P for which PA=LU, the echelon factor U is unique. If U has r nonzero rows (equivalently, r pivots), then the first r columns of L are also unique. Finally, the number r does not depend on the choice of P, L, or U.
Rank is a very important invariant of a matrix: it is a property of A itself, independent of the factors used to compute it. For now, we define it as the number of pivots in U. 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 x0 as one specific, or particular, solution to Ax=b, and think of v1,v2,…,vd−r as being the direction vectors that describe ways we can create other solutions from the one particular solution. These vectors satisfy
Av1=Av2=⋯=Avd−r=0.
Think about why this must be true! Hint: What happens if you multiply both sides of x=x0+t1v1+⋯+td−rvd−r by A on the left?
Find ℓ32 using the actual pivot. Entry (3,2) gives
(−1)(2)+ℓ32(0)=−2.
This is true for every ℓ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 U has its pivot in the last column, echelon form requires the third row of U to be zero, so u33=0. Then, matching entry (3,3) gives
These are exactly the columns of A. Notice that entry (3,3) of L did not factor into any of these calculations. We set it to 1 because of the convention that L has ones on its diagonal, but changing that bottom-right 1 to 342, for example, would not change the fact that A=LU.
Since U has two pivots and three columns, A is not invertible: for some possible outputs b of Ax, the equation Ax=b has infinitely many solutions.
To illustrate how we might solve, suppose we need to find x in Ax=b, where b=⎣⎡3109⎦⎤. First solve Ly=b:
⎣⎡12−1013001⎦⎤⎣⎡y1y2y3⎦⎤=⎣⎡3109⎦⎤.
Written out, this gives
y1=3,2y1+y2=10,−y1+3y2+y3=9.
This gives y=⎣⎡340⎦⎤. The system Ux=y is Example 2, so
x=⎣⎡502⎦⎤+t⎣⎡−210⎦⎤,t∈R.
If the last entry of b changes from 9 to 10, then y3=1 and the system is inconsistent, since b=⎣⎡31010⎦⎤ is not a possible output of Ax. When a square matrix A is not invertible, Ax=b either has no solution or infinitely many solutions.
Let’s compute a (P)LU factorization of A and use it to solve Ax=b. First, keep the original row order and seek a lower triangular L with ones on its diagonal and an echelon U such that A=LU. Write
The first row of U is the first row of A, and matching the first column gives −2ℓ21=1, so ℓ21=−21. Matching the remaining entries in the second row gives
Now we want to solve for x in Ax=[−23]. The first stage involves solving for y in Ly=b:
[1−2101][y1y2]=[−23].
Written out, this gives
y1=−2,−21y1+y2=3,soy=[−22].
The pivot columns of U are 1 and 3. Set x2=s and x4=t. Back substitution gives
21x3+t=2⟹x3=4−2t,
−2x1−4s+3(4−2t)=−2⟹x1=7−2s−3t.
Thus
x=⎣⎡7040⎦⎤+s⎣⎡−2100⎦⎤+t⎣⎡−30−21⎦⎤,s,t∈R.
Now, let’s redo the calculation after swapping the rows. Why? This is not strictly necessary, because we were able to find A=LU with the necessary conditions. But here it turns out that swapping the two rows of A will give us a factorization that doesn’t involve fractions. Let’s see. With
There are four unknowns but only two pivots, leaving two free variables.
Both P=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.
A rectangular system—particularly one involving a tall coefficient matrix, with more rows than columns—can have a unique solution. Consider
A=⎣⎡123134⎦⎤.
Let’s compute a (P)LU factorization of A, then use it to solve Ax=b for b=⎣⎡3811⎦⎤. First, seek a lower triangular L with ones on its diagonal and an echelon U such that A=LU. Here L is 3×3 and U is 3×2. Write
Solve the system. Now we want to solve for x in Ax=b, where b=⎣⎡3811⎦⎤. First solve for y in Ly=b:
⎣⎡123011001⎦⎤⎣⎡y1y2y3⎦⎤=⎣⎡3811⎦⎤.
Written out, this gives
y1=3,2y1+y2=8,3y1+y2+y3=11,
so y=⎣⎡320⎦⎤. Next, solve Ux=y:
⎣⎡100110⎦⎤[x1x2]=⎣⎡320⎦⎤.
The equations are
x1+x2=3,x2=2,0=0.
There are no free variables. The unique solution is x=[12].
If the last entry of b were 12 instead, forward substitution would give y3=1. The final equation would then be 0=1, so there would be no solution. This is because ⎣⎡3811⎦⎤ is a possible output of Ax, but ⎣⎡3812⎦⎤ is not.
Step 1: find the first row and first column. Since the first row of the product equals the first row of U, that row is [24−22]. Matching the first column gives
The first row of U stays the same. Matching the first column in this new order gives ℓ21=−1 and ℓ31=2: the two entries we had already found exchange places. We now find the remaining entries for this reordered matrix.
These are exactly the columns of PA. There are two pivots, so the rank is 2. When solving a consistent system with this matrix, x2 and x4 are free variables.
If PA=LU, multiplying both sides on the left by P−1 gives
A=P−1LU.
The inverse of a permutation matrix is also a permutation matrix: it undoes the row reordering. Setting P′=P−1, we can therefore state the theorem another way: every matrix A can be written as
A=P′LU,
where P′ is a permutation matrix, L is lower triangular with ones on the diagonal, and U is in row echelon form. Some references use this convention and call it the PLU factorization, or PLU decomposition, of A.