3.6  LU and PLU Factorizations

Gaussian elimination solves one system Ax=b. In practice the matrix often stays fixed while the right-hand side changes: the same network under different loads, the same model fed different data. The row operations depend only on A, so repeating them for every b wastes almost all of the work. This section stores the elimination as a factorization A=LU, a lower triangular matrix that remembers the operations times an upper triangular matrix that is their result. We prove when it exists and when it is unique, and we repair its failures with row swaps.

Throughout, F is a field and all matrices are square, in Mn(F).

3.6.1. Triangular systems are cheap

Some systems need no elimination at all. Take U=(21−103100−2),Ux=(−1−1−4). The last equation mentions only x3: −2x3=−4, so x3=2. The second mentions x2 and the known x3: 3x2+2=−1, so x2=−1. The first then gives 2x1−1−2=−1, so x1=1. This is back substitution: in an upper triangular system with non-zero diagonal entries, each equation introduces exactly one new unknown, read from the bottom up. A lower triangular system is solved the same way from the top down, by forward substitution.

Now suppose a matrix A factors as A=LU with L lower triangular and U upper triangular. Then Ax=b reads L(Ux)=b. Naming the inner vector y=Ux splits the problem in two: first solve Ly=b for y,then solve Ux=y for x. Both are triangular, so both are cheap. The expensive part, finding L and U, is done once for all right-hand sides.

An LU factorization is Gaussian elimination written down once, so that it never has to be done again.

3.6.2. LU factorizations

Definition 3.6.1 (LU factorization)

A matrix L∈Mn(F) is unit lower triangular if it is lower triangular and every diagonal entry equals 1. Let A∈Mn(F). An LU factorization of A is a pair (L,U) of matrices in Mn(F) such that A=LU,L is unit lower triangular,U is upper triangular.

In words: L has 1’s on the diagonal and zeros above it, and the entries below the diagonal are unrestricted. U has zeros strictly below the diagonal, and its diagonal entries are unrestricted; some of them may be 0. The definition says an factorization: whether there is only one is a theorem, and it needs a hypothesis.

Example (An LU factorization from elimination)

Let A=(21−145−1−282)∈M3(Q). Reduce A to upper triangular form using only operations “subtract a multiple of a higher row from a lower row”, and record each multiplier. Compare the result with the matrix U of the previous subsection.

Solution. The first pivot is 2. To clear column 1 below it we subtract ℓ21=4/2=2 times row 1 from row 2, and ℓ31=−2/2=−1 times row 1 from row 3: (21−145−1−282)→R3→R3−(−1)R1R2→R2−2R1(21−1031091). The second pivot is 3. We subtract ℓ32=9/3=3 times row 2 from row 3: (21−1031091)→R3→R3−3R2(21−103100−2)=U. Put the multipliers below the diagonal of a unit lower triangular matrix, each in the position of the entry it cleared: L=(100ℓ2110ℓ31ℓ321)=(100210−131). Multiplying out, row by row, LU=(21−12⋅22⋅1+32⋅(−1)+1−2−1+91+3−2)=(21−145−1−282)=A. So (L,U) is an LU factorization of A, and U is exactly the triangular matrix of the back substitution above.

The example suggests the general statement: elimination produces U, and the multipliers, with their signs as subtracted, fill in L. We prove this below. First, the smallest cases.

  • Upper triangular A. A=I⋅A, and I is unit lower triangular. So every upper triangular matrix, including 0 and I, has the LU factorization (I,A).
  • 1×1. Every (a)∈M1(F) is upper triangular, so (a)=(1)(a). Nothing can go wrong here, and that is exactly why the 2×2 failure below is instructive.

Non-example by minimal change. The matrix (1110) has the LU factorization (1110)=(1011)(110−1). Change the top-left entry from 1 to 0, and everything collapses.

Example (An invertible matrix with no LU factorization)

Show that A=(0110)∈M2(F) has no LU factorization, over any field F, although A is invertible.

Solution. A is invertible, since AA=I2. Suppose, for a contradiction, that A=LU with L=(10ℓ1),U=(uv0w). Then LU=(uvℓuℓv+w). Comparing (1,1)-entries with A gives u=0. Comparing (2,1)-entries gives ℓu=1. But ℓu=ℓ⋅0=0 by Theorem 0.7.1, and 0≠1 in a field. This contradiction shows that no LU factorization exists.

What failed is visible: the (1,1)-entry of any product LU is u11 alone, so a zero there forces the whole first column of LU to vanish. In elimination terms, the first pivot is 0 while the entry below it is not, and the only cure is to swap rows, which “subtract a multiple of a higher row from a lower row” cannot do. We return to this with permutation matrices.

Why “unit”. Without the 1’s on the diagonal of L, uniqueness would fail even for invertible matrices. If A=LU and D is any invertible diagonal matrix, then also A=(LD)(D−1U), where LD is still lower triangular and D−1U still upper triangular. When L is invertible and D≠I, this is a different pair, and over any field with more than two elements such a D exists. For instance (2)=(1)(2)=(2)(1)=(4)(1/2) over Q. Fixing the diagonal of L removes this freedom and matches what elimination does: it never rescales a row.

Warning. Invertible does not mean “has an LU factorization”. The matrix of Example (An invertible matrix with no LU factorization) is invertible and has none. Conversely, a singular matrix can have one: 0=I⋅0. Existence of an LU factorization is a property of the order of the rows, not of invertibility.

3.6.3. Unit lower triangular matrices

Elimination builds L out of elementary matrices, and the uniqueness proof below divides one factorization by another. Both need the same facts: products and inverses of unit lower triangular matrices stay unit lower triangular. We also need to know exactly when a triangular matrix is invertible.

The key observation is a statement about where the non-zero entries of a product can sit.

Lemma 3.6.1 (Unit lower triangular matrices are closed)

Let L,L′∈Mn(F) be unit lower triangular. Then:

  • (a) LL′ is unit lower triangular;
  • (b) L is invertible, and L−1 is unit lower triangular.

Idea. Write L=I+N, where N has non-zero entries only strictly below the diagonal. Multiplying two such matrices pushes the non-zero entries further below the diagonal, so Nn=0. Then the geometric series 1/(1+t)=1−t+t2−⋯ stops after n terms and gives the inverse exactly.

Proof. Say that X∈Mn(F) is p-low if xij=0 whenever i<j+p. So 0-low means lower triangular, and 1-low means zero on and above the diagonal.

Claim. If X is p-low and Y is q-low, then XY is (p+q)-low. A matrix that is n-low is the zero matrix.

Proof. By Definition 0.9.9, (XY)ij=∑l=1nxilylj. A term can be non-zero only if i≥l+p and l≥j+q, which together give i≥j+p+q. So if i<j+p+q, every term is 0 and (XY)ij=0. For the second statement, every pair of indices satisfies i≤n<1+n≤j+n, so every entry of an n-low matrix is 0.

Write L=I+N and L′=I+N′. Since L and L′ are unit lower triangular, N and N′ are 1-low.

For (a), LL′=I+N+N′+NN′ by Theorem 0.9.4. Here N+N′ is 1-low, since a sum of entries that are both 0 is 0, and NN′ is 2-low, hence 1-low, by the Claim. So LL′−I is 1-low, which says that LL′ is unit lower triangular.

For (b), let K=I−N+N2−⋯+(−1)n−1Nn−1. Multiplying out, the sum telescopes: (I+N)K=I+(−1)n−1Nn=I, where Nn=0 because Nn is n-low by the Claim applied n−1 times. The same computation gives K(I+N)=I, since N commutes with its own powers. Hence L is invertible with L−1=K. Finally K−I=∑p=1n−1(−1)pNp is a sum of 1-low matrices, by the Claim, so K is unit lower triangular. This proves the lemma.

Transposing everything, the same statements hold for unit upper triangular matrices (upper triangular with 1’s on the diagonal).

The next lemma decides invertibility of a triangular matrix from its diagonal, without any computation beyond back substitution.

Lemma 3.6.2 (Invertibility of a triangular matrix)

An upper triangular matrix U∈Mn(F) is invertible if and only if every diagonal entry u11,…,unn is non-zero.

Proof. (⇐) Suppose every ukk≠0, and let Ux=0. We show xk=0 for k=n,n−1,…,1 in turn. Suppose xk+1=⋯=xn=0 (nothing is assumed when k=n). Row k of Ux=0 reads ukkxk+∑j>kukjxj=0, because ukj=0 for j<k. The sum vanishes, so ukkxk=0, and xk=0 since ukk≠0. Hence x=0 is the only solution of Ux=0, and U is invertible by Theorem 3.4.4.

(⇒) We prove the contrapositive. Suppose ukk=0 for some k. For each j≤k, the entries of column j in rows i≥k are zero: if i>j this is upper triangularity, and the only remaining case i=j=k is ukk=0. So the first k columns of U lie in W=span(e1,…,ek−1). The list (e1,…,ek−1) is independent and spans W, so dim⁡W=k−1 (for k=1, W={0} has dimension 0). By Theorem 1.6.3 (a), these k columns are linearly dependent, so the columns of U are dependent, and U is not invertible by Theorem 3.4.4. This proves the lemma.

3.6.4. Elimination without row swaps

To prove that elimination always produces an LU factorization, we first need to say exactly which elimination we mean. It is Gaussian elimination restricted to one kind of operation: subtracting a multiple of a row from a row below it.

Algorithm. Elimination without row swaps. Input: A∈Mn(F). Put A(0)=A. For k=1,2,…,n−1, write A(k−1)=(aij) and do the following.

  • If akk≠0, set ℓik=aik/akk for i=k+1,…,n.
  • If akk=0 and aik=0 for every i>k, set ℓik=0 for i=k+1,…,n.
  • If akk=0 but aik≠0 for some i>k, stop: a row swap is needed.

If we did not stop, obtain A(k) from A(k−1) by replacing row i with (row i) −ℓik⋅ (row k), for each i=k+1,…,n.

If the loop finishes without stopping, we say elimination without row swaps succeeds on A. The numbers ℓik (i>k) are its multipliers, and U=A(n−1) is its result.

In both non-stopping cases the new (i,k)-entry is aik−ℓikakk=0: in the first case by the choice of ℓik, in the second because both terms are already 0. The multipliers are well defined: row k is not changed during step k, so it does not matter in which order the rows i>k are updated.

The proof will write each step as a matrix. By Definition 3.4.1, the elementary matrix of the operation Ri→Ri+cRk (i≠k) is I+cEik, where Eik is the matrix unit with 1 in entry (i,k). We will write the matrix unit as a product of a column and a row, Eik=eiek⊤, which holds because eiek⊤ has (p,q)-entry (ei)p(ek)q, equal to 1 if p=i and q=k, and 0 otherwise. We will use one more rule constantly: for a vector v∈Fn, the 1×1 matrix ek⊤v is the k-th entry vk, which we treat as a scalar. In particular ek⊤ej=0 for j≠k.

For 1≤k≤n and a vector v∈Fn whose first k entries are zero, put Gk(v)=I+vek⊤. Its only non-identity entries are vi in position (i,k), for i>k: it is the identity with the column vector v written into column k below the diagonal. So Gk(v) is unit lower triangular.

Lemma 3.6.3 (Multiplier matrices)

Let 1≤k≤n, and let v,v1,…,vm∈Fn be vectors such that the first k entries of v are zero and, for each j, the first j entries of vj are zero (m≤n). Then:

  • (a) Gk(v) is the product, in any order, of the elementary matrices I+viEik for i=k+1,…,n;
  • (b) Gk(v)Gk(−v)=Gk(−v)Gk(v)=I;
  • (c) G1(v1)G2(v2)⋯Gm(vm)=I+v1e1⊤+v2e2⊤+⋯+vmem⊤.

Proof. For (a), let i,j>k. By Theorem 0.9.4, (I+aeiek⊤)(I+bejek⊤)=I+aeiek⊤+bejek⊤+abei(ek⊤ej)ek⊤, and the last term is zero because ek⊤ej=0 for j≠k. Repeating this, one factor at a time, the product of the I+viEik=I+vieiek⊤ in any order is I+∑i>kvieiek⊤=I+vek⊤, since v=∑i>kviei.

For (b), (I+vek⊤)(I−vek⊤)=I−v(ek⊤v)ek⊤=I, because ek⊤v=vk=0. Swapping the signs gives the other order.

For (c), we use induction on m; the case m=1 is the definition. Suppose the formula holds for m−1. Then (I+∑j<mvjej⊤)(I+vmem⊤)=I+∑j<mvjej⊤+vmem⊤+∑j<mvj(ej⊤vm)em⊤. For j<m, ej⊤vm is entry j of vm, which is zero because the first m entries of vm are zero. So the last sum vanishes, and the formula holds for m. This proves the lemma.

Part (c) is the heart of the matter: when the factors come in the order G1,G2,…, they do not interfere, and each vector vj lands untouched in column j.

Theorem 3.6.4 (LU from elimination)

Let A∈Mn(F), and suppose elimination without row swaps succeeds on A, with multipliers ℓik and result U. Let L be the unit lower triangular matrix whose (i,k)-entry is ℓik for every i>k. Then U is upper triangular and A=LU. In particular A has an LU factorization.

Idea. Each step of elimination is left multiplication by a product of elementary matrices, which collapses to one matrix Gk(−ℓk). So U=Gn−1(−ℓn−1)⋯G1(−ℓ1)A. To get A back, undo the steps in reverse order. Their inverses Gk(ℓk) then appear in the order G1,G2,…, which is exactly the order in which, by Lemma 3.6.3 (c), the multipliers drop into place.

Proof. Let A(0),…,A(n−1)=U be the matrices produced by the algorithm. For each k, let ℓk=∑i>kℓikei∈Fn, a vector whose first k entries are zero.

Step 1: U is upper triangular. We show by induction on k that in A(k) every entry below the diagonal in columns 1,…,k is zero. For k=0 there is nothing to prove. Suppose it holds for A(k−1). Step k changes only rows i>k, replacing row i by row i minus a multiple of row k. In columns j<k, the entry of row k lies below the diagonal (k>j), so it is 0 by the induction hypothesis, and the entries of row i in these columns stay 0. In column k, the new entries below the diagonal are 0, as noted after the algorithm. This completes the induction, and for k=n−1 it says that U is upper triangular.

Step 2: each step is a matrix. Step k performs the operations “add −ℓik times row k to row i” for i=k+1,…,n. By Theorem 3.4.1, applying them one after another multiplies A(k−1) on the left by the corresponding elementary matrices I−ℓikEik. By Lemma 3.6.3 (a), their product is Gk(−ℓk). Hence A(k)=Gk(−ℓk)A(k−1), and therefore U=Gn−1(−ℓn−1)⋯G2(−ℓ2)G1(−ℓ1)A.

Step 3: undo the steps. Multiply both sides on the left by Gn−1(ℓn−1), then by Gn−2(ℓn−2), and so on down to G1(ℓ1). By Lemma 3.6.3 (b), each one cancels the factor next to it, and we get G1(ℓ1)G2(ℓ2)⋯Gn−1(ℓn−1)U=A. By Lemma 3.6.3 (c), the product on the left of U is I+∑k=1n−1ℓkek⊤. Its (i,k)-entry for i>k is ℓik; its diagonal entries are 1; its entries above the diagonal are 0. That is, it is L. Hence A=LU with L unit lower triangular and U upper triangular, as claimed.

So the multipliers are not something to be remembered separately: they are the lower triangular factor. When a computer performs elimination it stores each ℓik in the slot (i,k) that it has just cleared, and at the end the one array holds L below the diagonal and U on and above it.

Warning. The matrix that performs elimination, L−1, is not L with its multipliers negated. In Example (An LU factorization from elimination) the operations multiply A on the left by G2(−ℓ2)G1(−ℓ1)=(1000100−31)(100−210101)=(100−2107−31), and the entry 7=1+(−3)(−2) mixes two multipliers. This matrix is L−1, by Step 3 of the proof. It is L, whose factors come in the order G1,G2, that has the multipliers cleanly in place.

Quick check. Find the LU factorization of A=(2465) over Q by elimination, and check it by multiplying.

Solution. The pivot is 2 and the multiplier is ℓ21=6/2=3. Subtracting 3 times row 1 from row 2 gives U=(2405−12)=(240−7), and L=(1031). Check: LU=(24612−7)=A.

3.6.5. Solving with an LU factorization

Once A=LU is known, each system Ax=b costs two substitutions.

Example (Two right-hand sides, one factorization)

Let A=(21−145−1−282) with the factorization A=LU of Example (An LU factorization from elimination). Solve Ax=b for b=(−1−3−6)andb′=(37−2).

Solution. First right-hand side. Forward substitution in Ly=b: y1=−1,2y1+y2=−3⇒y2=−1,−y1+3y2+y3=−6⇒y3=−6−1+3=−4. Back substitution in Ux=y: −2x3=−4⇒x3=2,3x2+x3=−1⇒x2=−1,2x1+x2−x3=−1⇒x1=1. So x=(1,−1,2). Check: Ax=(2−1−2,4−5−2,−2−8+4)=(−1,−3,−6)=b.

Second right-hand side. Ly=b′: y1=3, y2=7−2⋅3=1, y3=−2+y1−3y2=−2+3−3=−2. Then Ux=y: −2x3=−2, so x3=1; 3x2+1=1, so x2=0; 2x1+0−1=3, so x1=2. So x′=(2,0,1), and indeed Ax′=(4+0−1,8+0−1,−4+0+2)=(3,7,−2).

Since the diagonal of U is 2,3,−2, all non-zero, U is invertible by Lemma 3.6.2, L is invertible by Lemma 3.6.1, and so A=LU is invertible. Each solution found is therefore the only one.

How much is saved? Count the arithmetic operations (+,−,×,÷) for an n×n matrix. At step k of elimination there are n−k rows below the pivot. Each needs one division for its multiplier, then n−k multiplications and n−k subtractions in the columns to the right of column k. With j=n−k, the total is ∑j=1n−1j(2j+1)=n(n−1)(4n+1)6≈23n3. Forward substitution with a unit lower triangular L uses n(n−1) operations, and back substitution n2, so a pair of triangular solves costs 2n2−n. For n=1000 that is about 6.7×108 operations for the factorization, done once, against about 2×106 for each new right-hand side.

3.6.6. Uniqueness

The factorization of Example (An LU factorization from elimination) came from one particular procedure. Could another procedure give a different pair (L,U)? For invertible matrices, no.

Theorem 3.6.5 (Uniqueness of the LU factorization)

Let A∈Mn(F) be invertible. If A=L1U1 and A=L2U2 are LU factorizations, then L1=L2 and U1=U2.

Idea. Take the difference in multiplicative form: from L1U1=L2U2 we get (L2−1L1)U1=U2. The matrix M=L2−1L1 is unit lower triangular, and multiplying U1 by it must leave an upper triangular matrix. Clearing below the diagonal column by column, the non-zero pivots of U1 force M to have nothing below its diagonal. Invertibility of A is what provides those non-zero pivots.

Proof. By Lemma 3.6.1 (b), L1 and L2 are invertible. Hence U1=L1−1A is a product of invertible matrices, so it is invertible by Theorem 0.9.7, and by Lemma 3.6.2 its diagonal entries u11,…,unn are all non-zero.

Let M=L2−1L1. By Lemma 3.6.1, M=(mij) is unit lower triangular. Multiplying L1U1=L2U2 on the left by L2−1 gives MU1=U2, so MU1 is upper triangular. We show mij=0 for all i>j, by induction on the column j.

Fix j, and suppose mik=0 whenever k<j and i>k. Let i>j. Since MU1 is upper triangular and i>j, 0=(MU1)ij=∑k=1nmikukj=∑k≤jmikukj=mijujj, where the third equality uses ukj=0 for k>j, and the last uses mik=0 for k<j (here i>j>k). Since ujj≠0, we get mij=0. This completes the induction, so M is lower triangular with 1’s on the diagonal and nothing below it: M=I.

Hence L2−1L1=I, and multiplying by L2 gives L1=L2. Then U1=L1−1A=L2−1A=U2. This proves the theorem.

Two consequences are worth saying. The LU factorization of an invertible matrix does not depend on how it was found, so it is legitimate to speak of the factors L and U. And if elimination without row swaps succeeds on an invertible A, then every pivot is non-zero: row k is not changed after step k, so the pivot of step k is ukk, which is non-zero by the first paragraph of the proof. So the second case of the algorithm (a zero pivot over a zero column) never occurs.

Remark. The hypothesis “invertible” cannot be dropped. For every c∈F, (0001)=(10c1)(0001), since the first column of the right factor is zero. Taking c=0 and c=1 gives two different LU factorizations. The proof breaks exactly at “ujj≠0”, here for j=1.

3.6.7. Row swaps and the PLU factorization

Example (An invertible matrix with no LU factorization) showed that some matrices, even invertible ones, have no LU factorization, because elimination meets a zero pivot with a non-zero entry below it. The cure in Gaussian elimination is to swap rows. We now show that the swaps can all be collected in front, as a single matrix that rearranges the rows of A before elimination starts. After that rearrangement, no swaps are needed.

Matrices that rearrange rows were named in Definition 3.4.2: Pσ has j-th column eσ(j), a product of permutation matrices is one, Pσ−1=Pσ⊤, and a transposition gives the row-swap elementary matrix (Lemma 3.4.7). One more fact about them is needed here and nowhere else, because it is about the Gauss transforms of this section: a swap that leaves the first k coordinates alone can be pushed through Gk.

Lemma 3.6.6 (Pushing a Swap Past a Gauss Transform)

Let 1≤k<r<s≤n, let τ=(r s), and let v∈Fn have its first k entries zero. Then Pτv has its first k entries zero, and PτGk(v)Pτ=Gk(Pτv).

Proof. Write P=Pτ. Its effect on a vector is to exchange entries r and s, which are both beyond position k, so Pv still has its first k entries zero. Since k≠r,s, we have Pek=eτ(k)=ek. By Lemma 3.4.7 (b) and (c), P⊤=P−1=P, so ek⊤P=ek⊤P⊤=(Pek)⊤=ek⊤ by Theorem 0.9.5. Therefore P(I+vek⊤)P=P2+(Pv)(ek⊤P)=I+(Pv)ek⊤=Gk(Pv), using P2=I from Lemma 3.4.7 (c). This proves the lemma.

Definition 3.6.2 (PLU factorization)

Let A∈Mn(F). A PLU factorization of A is a triple (P,L,U) of matrices in Mn(F) such that PA=LU,P is a permutation matrix,L is unit lower triangular,U is upper triangular.

In words: after rearranging the rows of A by P, the matrix has an LU factorization. By Lemma 3.4.7 (b) this can also be written A=P⊤LU, which is why some books write the factorization as A=PLU with their P our P⊤. For example, A=(0110) has the PLU factorization (A,I,I), since AA=I=I⋅I. An LU factorization is the special case P=I.

To produce P, run elimination and allow a swap whenever a zero pivot has a non-zero entry below it.

Algorithm. Elimination with row swaps. Input: A∈Mn(F). Put A(0)=A. For k=1,2,…,n−1, with A(k−1)=(aij):

  • If aik=0 for every i≥k, set Pk=I and all ℓik=0, and let A(k)=A(k−1).
  • Otherwise choose some rk≥k with arkk≠0. Let Pk be the matrix swapping rows k and rk (so Pk=I if rk=k), and let B=PkA(k−1). Set ℓik=bik/bkk for i>k, and obtain A(k) from B by replacing row i with (row i) −ℓik⋅ (row k) for each i>k.

This version never stops. Here is the result it delivers.

Theorem 3.6.7 (Existence of a PLU factorization)

Every A∈Mn(F) has a PLU factorization.

Idea. Step roadmap. ① As before, each step is a matrix: A(k)=Gk(−ℓk)PkA(k−1), and the final matrix U is upper triangular. ② The swaps are tangled with the multiplier matrices. A swap of two rows below row k can be pushed to the right past Gk at the price of swapping the entries of the multiplier vector: this is Lemma 3.4.7 (d). ③ Once all swaps sit next to A, the rest is the LU proof word for word. In practice, ② says: when you swap two rows, also swap the multipliers already stored in those rows.

Proof. Run elimination with row swaps on A, producing A(0),…,A(n−1)=U, swap matrices P1,…,Pn−1 and multipliers ℓik. Let ℓk=∑i>kℓikei, whose first k entries are zero.

Step 1. Exactly as in Step 1 of the proof of Theorem 3.6.4, every entry of A(k) below the diagonal in columns 1,…,k is zero. The only new point is the swap in step k: it exchanges rows k and rk≥k, whose entries in columns j<k are below the diagonal and hence zero, so the swap does not disturb these columns. After the swap the pivot bkk is non-zero, and the new entries below it are bik−ℓikbkk=0. Hence U is upper triangular. By Lemma 3.4.7 (c), Theorem 3.4.1 and Lemma 3.6.3 (a), as in Step 2 of that proof, A(k)=Gk(−ℓk)PkA(k−1)(k=1,…,n−1). This also holds in the first case of the algorithm, where Pk=I and Gk(0)=I.

Step 2. For 1≤k≤m≤n−1 put ℓk(m)=PmPm−1⋯Pk+1ℓk, with ℓm(m)=ℓm. We claim that the first k entries of ℓk(m) are zero and that Gm(−ℓm)Pm⋯G1(−ℓ1)P1=Gm(−ℓm(m))⋯G1(−ℓ1(m))Pm⋯P1. For m=1 both sides are G1(−ℓ1)P1. Suppose the claim holds for m, and multiply it on the left by Gm+1(−ℓm+1)Pm+1. The matrix Pm+1 is I or swaps rows m+1 and rm+1>m+1, both beyond every k≤m. So by Lemma 3.4.7 (c) and Lemma 3.6.6, for each k≤m and each vector v with its first k entries zero, Pm+1Gk(v)=Pm+1Gk(v)Pm+1Pm+1=Gk(Pm+1v)Pm+1, and Pm+1v again has its first k entries zero. Applying this for k=m,m−1,…,1 moves Pm+1 to the right past every factor Gk, replacing ℓk(m) by Pm+1ℓk(m)=ℓk(m+1) (note Pm+1(−v)=−Pm+1v). This is the claim for m+1.

Step 3. By Step 1, U=Gn−1(−ℓn−1)Pn−1⋯G1(−ℓ1)P1A. Write ℓk′=ℓk(n−1) and P=Pn−1⋯P1. By Step 2, U=Gn−1(−ℓn−1′)⋯G1(−ℓ1′)PA. P is a permutation matrix by Lemma 3.4.7 (a) and (c). Multiplying on the left by Gn−1(ℓn−1′), then Gn−2(ℓn−2′), and so on, and using Lemma 3.6.3 (b) and (c) as in Step 3 of the proof of Theorem 3.6.4, PA=LU,L=I+∑k=1n−1ℓk′ek⊤, where L is unit lower triangular because the first k entries of each ℓk′ are zero. So (P,L,U) is a PLU factorization of A. This proves the theorem.

Example (A swap in the middle)

Find a PLU factorization of A=(121243372)∈M3(Q).

Solution. Step 1. The pivot 1 is non-zero, so no swap. The multipliers are ℓ21=2 and ℓ31=3: A→R3→R3−3R1R2→R2−2R1(12100101−1),ℓ1=(023). Step 2. The pivot position (2,2) holds 0, but the entry below it is 1. Elimination without row swaps would stop here. We swap rows 2 and 3, so P2=P23: →R2↔R3(12101−1001)=U. The entry below the new pivot is already 0, so ℓ32=0, and U is upper triangular.

By Step 2 of the proof, the stored multipliers of step 1 are swapped too: ℓ1′=P2ℓ1=(0,3,2). Hence P=(100001010),L=(100310201). Check: PA is A with rows 2 and 3 swapped, and LU=(12136+13−1242+1)=(121372243)=PA. Notice where the multipliers ended up: 3 in row 2 and 2 in row 3, traveling with the rows they belong to. To solve Ax=b, multiply by P and solve LUx=Pb by two substitutions; since P is invertible, this changes no solutions. For b=(2,3,8), Pb=(2,8,3). Forward substitution in Ly=Pb gives y1=2, y2=8−3⋅2=2, y3=3−2⋅2=−1. Back substitution in Ux=y gives x3=−1, x2=2+x3=1, x1=2−2x2−x3=1. Check: A(1,1,−1)=(1+2−1,2+4−3,3+7−2)=(2,3,8).

Remark. Over R, computers do not choose just any non-zero pivot. They choose the entry of largest absolute value in the column, which is called partial pivoting. The reason is rounding. For A=(ε111) with ε=10−20, elimination without swaps gives the multiplier 1020 and u22=1−1020, which in standard double-precision arithmetic is stored as −1020. Multiplying back, the computed LU has (2,2)-entry 1020−1020=0 instead of 1. Swapping the rows first gives the harmless multiplier ε. Chapter 24 makes this precise.

3.6.8. Symmetric matrices: the LDLᵀ factorization

When A is symmetric, the two factors of A=LU are secretly related: up to a diagonal matrix, U is the transpose of L. In Example (An LU factorization from elimination) the factors look unrelated, but that matrix is not symmetric. Try a symmetric one: (13−237−8−2−85)→R3→R3+2R1R2→R2−3R1(13−20−2−20−21)→R3→R3−R2(13−20−2−2003)=U, with multipliers ℓ21=3, ℓ31=−2, ℓ32=1. Divide each row of U by its diagonal entry: the rows become (1,3,−2), (0,1,1), (0,0,1). These are the columns of L=(100310−211), read as rows. So U=DL⊤ with D=diag(1,−2,3), and A=LDL⊤.

Theorem 3.6.8 (LDLᵀ factorization)

Let A∈Mn(F) be symmetric and invertible, and suppose A=LU is an LU factorization. Then the diagonal entries u11,…,unn of U are non-zero, and with D=diag(u11,…,unn), U=DL⊤andA=LDL⊤.

Idea. Pull the diagonal out of U, writing U=DV with V unit upper triangular, so A=LDV. Transposing, A=A⊤=V⊤(DL⊤), which is a second LU factorization of the same invertible matrix. Uniqueness forces the two to agree, so L=V⊤.

Proof. As in the proof of Theorem 3.6.5, U=L−1A is invertible, so its diagonal entries are non-zero by Lemma 3.6.2. Hence D is invertible, with D−1=diag(u11−1,…,unn−1). Let V=D−1U. Row i of V is uii−1 times row i of U, so V is upper triangular with vii=uii−1uii=1, and A=LDV.

Since A is symmetric and D⊤=D, Theorem 0.9.5 gives A=A⊤=(LDV)⊤=V⊤DL⊤=V⊤(DL⊤). Here V⊤ is unit lower triangular, because V is unit upper triangular. And DL⊤ is upper triangular: its (i,j)-entry is uiiℓji, and ℓji=0 when j<i, since L is lower triangular. So (V⊤,DL⊤) is an LU factorization of the invertible matrix A. By Theorem 3.6.5, V⊤=L and DL⊤=U. Therefore A=LU=LDL⊤, as claimed.

The factorization stores about half as much: L and the diagonal D determine everything. Over R, when every entry of D is positive, one can split D=D1/2D1/2 and write A=(LD1/2)(LD1/2)⊤; this is the Cholesky factorization, which Chapter 13 connects with positive definite matrices.

Remark. Symmetry alone does not give an LU factorization: (0110) is symmetric and invertible, and has none by Example (An invertible matrix with no LU factorization). The theorem assumes the factorization exists and then improves it.

3.6.9. Exercises

A. Check your understanding

Exercise (A1)
  • (a) Define an LU factorization of a matrix A∈Mn(F), and a PLU factorization.
  • (b) True or false: every invertible matrix has an LU factorization. Justify your answer.
  • (c) Suppose A=LU. In which order are the two triangular systems solved to find a solution of Ax=b, and what is each one?
  • (d) True or false: the product of two unit lower triangular n×n matrices is unit lower triangular. Justify your answer.
  • (e) True or false: the zero matrix in M2(F) has more than one LU factorization. Justify your answer.
  • (f) What is the inverse of a permutation matrix P?

Solution.

  • (a) See Definition 3.6.1: A=LU with L unit lower triangular and U upper triangular. See Definition 3.6.2: PA=LU with P a permutation matrix, L unit lower triangular and U upper triangular.
  • (b) False. (0110) is invertible but has no LU factorization, by Example (An invertible matrix with no LU factorization).
  • (c) First Ly=b, by forward substitution; then Ux=y, by back substitution. Then Ax=L(Ux)=Ly=b.
  • (d) True, by Lemma 3.6.1 (a).
  • (e) True. For every c∈F, (10c1)0=0, so ((10c1),0) is an LU factorization; c=0 and c=1 give two different ones. This does not contradict Theorem 3.6.5, because 0 is not invertible.
  • (f) P−1=P⊤, by Lemma 3.4.7 (b).

B. Practice

Exercise (B1: An LU factorization)

Find the LU factorization of A=(120−3−7426−3)∈M3(Q) by elimination without row swaps. Hence show that A is invertible.

Solution. Step 1. The pivot is 1, with multipliers ℓ21=−3 and ℓ31=2: A→R3→R3−2R1R2→R2−(−3)R1(1200−1402−3). Step 2. The pivot is −1, with multiplier ℓ32=2/(−1)=−2: →R3→R3−(−2)R2(1200−14005)=U. By Theorem 3.6.4, L=(100−3102−21),A=LU. Check: LU=(120−3−6−1424+2−8+5)=A.

The diagonal entries 1,−1,5 of U are non-zero, so U is invertible by Lemma 3.6.2, and L is invertible by Lemma 3.6.1. Hence A=LU is invertible by Theorem 0.9.7.

Exercise (B2: Two systems, one factorization)

With A=LU as in Exercise (B1: An LU factorization), solve Ax=b for b=(3,−6,5) and for b=(0,1,−2), using only forward and back substitution.

Solution. For b=(3,−6,5). Ly=b: y1=3; −3y1+y2=−6, so y2=3; 2y1−2y2+y3=5, so y3=5−6+6=5. Then Ux=y: 5x3=5, so x3=1; −x2+4x3=3, so x2=1; x1+2x2=3, so x1=1. Hence x=(1,1,1). Check: Ax=(1+2,−3−7+4,2+6−3)=(3,−6,5).

For b=(0,1,−2). Ly=b: y1=0; y2=1+3y1=1; y3=−2−2y1+2y2=0. Then Ux=y: 5x3=0, so x3=0; −x2+0=1, so x2=−1; x1+2(−1)=0, so x1=2. Hence x=(2,−1,0). Check: Ax=(2−2,−6+7,4−6)=(0,1,−2).

Since A is invertible (Exercise (B1: An LU factorization)), each solution is the only one, by Theorem 0.9.7.

Exercise (B3: A PLU factorization)

Let A=(012111231)∈M3(Q).

  • (a) Explain why A has no LU factorization.
  • (b) Find a PLU factorization of A.
  • (c) Hence solve Ax=(0,2,7).

Solution.

  • (a) If A=LU, then the (1,1)-entry gives u11=a11=0, and the (2,1)-entry gives a21=ℓ21u11=0. But a21=1≠0, a contradiction, exactly as in Example (An invertible matrix with no LU factorization).
  • (b) The first pivot position holds 0 and the entry below is 1, so swap rows 1 and 2, P1=P12: A→R1↔R2(111012231)→R3→R3−2R1R2→R2−0R1(11101201−1)→R3→R3−1R2(11101200−3)=U. The multipliers are ℓ21=0, ℓ31=2, ℓ32=1, and no swap happens after step 1, so they need no rearranging. Hence P=(010100001),L=(100010211). Check: PA=(111012231), and LU=(11101222+12+2−3)=PA.
  • (c) Ax=b holds if and only if PAx=Pb, since P is invertible (Lemma 3.4.7 (b)). Swapping the first two entries of b=(0,2,7), we solve LUx=Pb=(2,0,7). Ly=(2,0,7): y1=2, y2=0, y3=7−2⋅2−0=3. Ux=y: −3x3=3, so x3=−1; x2+2x3=0, so x2=2; x1+x2+x3=2, so x1=1. Hence x=(1,2,−1). Check: Ax=(0+2−2,1+2−1,2+6−1)=(0,2,7).

C. Going deeper

Exercise (C1: Leading principal submatrices)

For A∈Mn(F) and 1≤k≤n, the leading principal submatrix Ak∈Mk(F) is the top-left k×k corner of A, with entries aij for i,j≤k.

  • (a) Let L be lower triangular and U upper triangular in Mn(F). Show that (LU)k=LkUk for every k.
  • (b) Deduce that if A has an LU factorization A=LU with U invertible, then every leading principal submatrix A1,…,An is invertible.
  • (c) Prove the converse: if A1,…,An are all invertible, then A has an LU factorization with U invertible.

Hint for (c): induction on n. Write A with An−1 in its top-left corner, a column b, a row c⊤ and a corner entry d, and look for L and U of the same shape.

Solution.

  • (a) Let i,j≤k. By Definition 0.9.9, (LU)ij=∑l=1nℓilulj. If l>k, then l>i, so ℓil=0 because L is lower triangular. Hence (LU)ij=∑l=1kℓilulj=(LkUk)ij, as claimed.

  • (b) Suppose A=LU with U invertible. By (a), Ak=LkUk. The matrix Lk is unit lower triangular, so it is invertible by Lemma 3.6.1. By Lemma 3.6.2, u11,…,unn are non-zero; Uk is upper triangular with diagonal u11,…,ukk, so Uk is invertible by the same lemma. Hence Ak is invertible by Theorem 0.9.7.

  • (c) We prove by induction on n that every A∈Mn(F) whose leading principal submatrices are all invertible has an LU factorization with U invertible. For n=1, A=(a11) with a11≠0, and A=(1)(a11) works.

    Let n≥2 and suppose the statement holds for n−1. Write A=(An−1bc⊤d),b,c∈Fn−1, d∈F. The leading principal submatrices of An−1 are A1,…,An−1, all invertible, so by the induction hypothesis An−1=L′U′ with L′ unit lower triangular and U′ upper triangular and invertible. Put y=L′−1b, x⊤=c⊤U′−1 and z=d−x⊤y, and let L=(L′0x⊤1),U=(U′y0⊤z). Then L is unit lower triangular and U is upper triangular. Computing LU entry by entry, splitting each sum ∑l=1n into l≤n−1 and l=n: the top-left block is L′U′+00⊤=An−1; the top-right column is L′y+0z=b; the bottom-left row is x⊤U′+1⋅0⊤=c⊤; the corner is x⊤y+z=d. Hence A=LU.

    Finally A=An is invertible by hypothesis, and L is invertible by Lemma 3.6.1, so U=L−1A is invertible by Theorem 0.9.7. This completes the induction.

In the language of elimination: z is the n-th pivot, and (c) shows that invertible leading corners are exactly what keeps every pivot non-zero.

Exercise (C2: An LDLᵀ factorization)

Let A=(4−48−45−118−1127)∈M3(R).

  • (a) Find the LU factorization of A, show that A is invertible, and write A=LDL⊤.
  • (b) Deduce that x⊤Ax>0 for every non-zero x∈R3.

Solution.

  • (a) Step 1: pivot 4, multipliers ℓ21=−1, ℓ31=2. Row 2 becomes (−4,5,−11)+(4,−4,8)=(0,1,−3), row 3 becomes (8,−11,27)−2(4,−4,8)=(0,−3,11). Step 2: pivot 1, multiplier ℓ32=−3; row 3 becomes (0,−3,11)+3(0,1,−3)=(0,0,2). Hence L=(100−1102−31),U=(4−4801−3002), and A=LU by Theorem 3.6.4. The diagonal 4,1,2 of U is non-zero, so U is invertible (Lemma 3.6.2), L is invertible (Lemma 3.6.1), and A=LU is invertible. A is symmetric, so by Theorem 3.6.8, with D=diag(4,1,2), A=LDL⊤,DL⊤=(400010002)(1−1201−3001)=(4−4801−3002)=U, which confirms the theorem directly.
  • (b) Let x≠0 and put y=L⊤x. By Lemma 3.6.1, L is invertible, so L⊤ is invertible by Theorem 0.9.7 (4), so y≠0 (otherwise x=(L⊤)−1y=0). By Theorem 0.9.5, y⊤=x⊤L, so x⊤Ax=x⊤LDL⊤x=y⊤Dy=4y12+y22+2y32, reading the 1×1 matrix as a real number. Each term is ≥0, and at least one yi≠0, which makes its term strictly positive. Hence x⊤Ax>0.
Exercise (C3: Counting matrices without an LU factorization)
  • (a) Let A=(abcd)∈M2(F). Prove that A has an LU factorization if and only if a≠0 or c=0.
  • (b) Let q be a prime. How many matrices in M2(Fq) have no LU factorization? List them for q=2.

Solution.

  • (a) (⇒) Suppose A=LU with L=(10ℓ1) and U=(uv0w). As in Example (An invertible matrix with no LU factorization), LU=(uvℓuℓv+w), so a=u and c=ℓu=ℓa. If a=0, then c=0. Hence a≠0 or c=0.

    (⇐) If a≠0, elimination without row swaps succeeds with multiplier ℓ=c/a, and indeed (10c/a1)(ab0d−cb/a)=(abccb/a+d−cb/a)=A. If c=0, then A is upper triangular and A=IA.

  • (b) By (a), A has no LU factorization exactly when a=0 and c≠0. There are q−1 choices of c, and q choices each of b and d, so there are (q−1)q2 such matrices. For q=2 this gives 4 of the 16 matrices: a=0, c=1, and b,d∈{0,1}, that is, (0010),(0011),(0110),(0111).

Found a typo or a mistake? Report it, or read this page’s source

The text of this book is licensed under CC BY-NC-SA 4.0.