Session 04 · Unit 1

Factorization into A = LU


Elimination gets from A to U — this lecture packages the whole process into one equation, A = LU, the most basic factorization of a matrix. The multipliers from elimination drop straight into L with no extra work. Along the way, inverses and transposes of products, the n-cubed-over-three cost of elimination, and the permutation matrices that handle row exchanges.

The inverse of a product

Unfinished business from last time: if AA and BB are both invertible, what is the inverse of ABAB? You multiply the separate inverses — but in reverse order:

The check is just moving parentheses around. In ABB1A1AB \cdot B^{-1}A^{-1}, do the middle multiplication first: BB1=IB B^{-1} = I, then AIA1=AA1=IA I A^{-1} = A A^{-1} = I. On the other side, B1A1ABB^{-1}A^{-1} \cdot AB — this time the inner pair A1AA^{-1}A squeezes down to the identity, and B1BB^{-1}B finishes the job.

Strang apologizes in advance for the example in the book, but it sticks: you take off your shoes, then your socks — so the way to invert that process is socks back on first, then shoes. Inverses come in reverse order.

While we’re at it, one fact about transposes, since the next lecture is full of them. Start from AA1=IAA^{-1} = I and transpose both sides. The identity doesn’t notice being transposed — it’s symmetric. And a product transposes in reverse order, so

(A1)TAT=I(A^{-1})^{\mathsf{T}} A^{\mathsf{T}} = I

That equation answers the question “what is the inverse of ATA^{\mathsf{T}}?” — it’s sitting right there on the left:

From EA = U to A = LU

Now the main event. Elimination takes AA to UU — we know the steps. Today’s lecture is the right way to look at those steps: as a factorization A=LUA = LU. Strang calls this “the most basic factorization of a matrix” — and adds a worry: please don’t think this course is all elimination. It’s just the right algebra to do first. Throughout, assume the nice case: no row exchanges, all pivots fine.

Start with a 2×22 \times 2. Take

A=[2187]A = \begin{bmatrix} 2 & 1 \\ 8 & 7 \end{bmatrix}

The first pivot is 22, so the multiplier is 44 — and the 77 was chosen so the matrix isn’t singular (a 44 in that corner would have killed the second pivot). One elimination step, carried out by the elementary matrix E21E_{21}, produces UU in one shot:

[1041]E21[2187]=[2103]U\underbrace{\begin{bmatrix} 1 & 0 \\ -4 & 1 \end{bmatrix}}_{E_{21}} \begin{bmatrix} 2 & 1 \\ 8 & 7 \end{bmatrix} = \underbrace{\begin{bmatrix} 2 & 1 \\ 0 & 3 \end{bmatrix}}_{U}

But what Strang is shooting for is AA alone on one side and everything else on the other. Multiply through by E211E_{21}^{-1} — and elimination matrices are easy to invert: the inverse of subtracting 44 of row one is adding back 44 of row one, so the sign just flips.

Sometimes it’s nicer to pull the pivots out into their own diagonal matrix DD, leaving ones on both triangular diagonals. Divide row one of UU by 22 and row two by 33:

A=[1041][2003][11201]A = \begin{bmatrix} 1 & 0 \\ 4 & 1 \end{bmatrix} \begin{bmatrix} 2 & 0 \\ 0 & 3 \end{bmatrix} \begin{bmatrix} 1 & \tfrac{1}{2} \\ 0 & 1 \end{bmatrix}

That balanced form is A=LDUA = LDU. MATLAB would produce either one; Strang basically stays with LULU.

Three by three: why L beats E

For a 2×22 \times 2 this was easy — one EE, and the only difference between EE and LL was a minus sign versus a plus sign. With 3×33 \times 3 there’s a more significant difference. Elimination now takes three steps:

E32E31E21A=UE_{32}\, E_{31}\, E_{21}\, A = U

first a zero in the (2,1)(2,1) position, then (3,1)(3,1), then (3,2)(3,2). Moving everything to the right side means inverting the whole bunch — separate inverses, opposite order:

A=E211E311E321U=LUA = E_{21}^{-1} E_{31}^{-1} E_{32}^{-1}\, U = LU

So LL is a product of inverses. But why prefer the inverses? Why is that product nicer than the product of the EE‘s themselves? Strang makes the point with a typical case: suppose E21E_{21} has multiplier 22, suppose E31E_{31} happens to be the identity (a zero was already sitting in the (3,1)(3,1) position), and E32E_{32} has multiplier 55. Multiply the EE‘s in elimination order:

[100010051]E32[100210001]E21=[1002101051]E\underbrace{\begin{bmatrix} 1 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & -5 & 1 \end{bmatrix}}_{E_{32}} \underbrace{\begin{bmatrix} 1 & 0 & 0 \\ -2 & 1 & 0 \\ 0 & 0 & 1 \end{bmatrix}}_{E_{21}} = \underbrace{\begin{bmatrix} 1 & 0 & 0 \\ -2 & 1 & 0 \\ 10 & -5 & 1 \end{bmatrix}}_{E}

Everything above the diagonal stays zero — elimination only subtracts rows from lower rows, nothing moves upward as it did in Gauss–Jordan. But look at that 1010. Where did it come from? “I don’t like that ten,” Strang says — it’s right, but he doesn’t want it there. It appeared because two of row one got removed from row two, and then five of that new row two got removed from row three — so altogether ten of row one got thrown into row three. The multipliers interfere.

Now do it in the reverse direction, inverses in opposite order:

[100210001]E211[100010051]E321=[100210051]L\underbrace{\begin{bmatrix} 1 & 0 & 0 \\ 2 & 1 & 0 \\ 0 & 0 & 1 \end{bmatrix}}_{E_{21}^{-1}} \underbrace{\begin{bmatrix} 1 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 5 & 1 \end{bmatrix}}_{E_{32}^{-1}} = \underbrace{\begin{bmatrix} 1 & 0 & 0 \\ 2 & 1 & 0 \\ 0 & 5 & 1 \end{bmatrix}}_{L}

A happy result: the 22 and the 55 don’t interfere to produce any 1010. In the right order, the multipliers just sit in the matrix LL.

The unattractive matrix is EE, the product of elimination matrices — you can’t see what it is without multiplying. Put the inverses on the other side, in the opposite order, and LL comes out just right. That’s the new insight elimination gains from being done in matrix form: EA=UEA = U, whereas A=LUA = LU.

How expensive is elimination?

Today is a practical day, so a practical question: how many operations does elimination cost on an n×nn \times n matrix? Can we solve a system of order a thousand in a second, a minute, a week? Suppose there are no convenient zeros — count a multiply-and-subtract pair as one operation.

Take n=100n = 100. The first stage of elimination fixes the first row and clears the first column, changing essentially every entry of the matrix — about 1002100^2 operations, since 1002100^2 is the total number of entries and only the insignificant first row is left alone. The second stage works on the remaining 99×9999 \times 99 block: about 99299^2. Then 98298^2, 97297^2, all the way down to 222^2 and 121^2. The big numbers come first; the problem keeps shrinking. So the total is

n2+(n1)2+(n2)2++22+12    13n3n^2 + (n-1)^2 + (n-2)^2 + \cdots + 2^2 + 1^2 \;\approx\; \tfrac{1}{3}n^3

Is it proportional to nn? Certainly not. Is it n!n! — a hundred times longer each time nn grows by one? No (Strang puts in “a bad mark against determinants,” where n!n! really does show up). There are nn terms and the biggest is n2n^2, so the worst it could be is n3n^3 — and the shrinking brings in the factor 13\tfrac{1}{3}. Strang allows exactly one mention of calculus: summing x2x^2 is like integrating it, and 1nx2dx=13n3\int_1^n x^2\,dx = \tfrac{1}{3}n^3. Calculus is like sums, except it’s continuous; algebra is discrete.

That gap is why the factorization matters in practice: pay the 13n3\tfrac{1}{3}n^3 price once to split AA into LL and UU, then process every new right-hand side at the low n2n^2 cost. This is the most fundamental algorithm for a system of equations.

Permutations: allowing row exchanges

Finally, drop the nice-case assumption. When do we need row exchanges? When a zero shows up in the pivot position. The matrices that do the exchanging are permutation matrices — the identity matrix with its rows rearranged.

For 3×33 \times 3 there is a nice little family of them — all six ways to rearrange the rows of II. The identity itself (exchanges nothing), the three single exchanges,

P12=[010100001],P13=[001010100],P23=[100001010]P_{12} = \begin{bmatrix} 0 & 1 & 0 \\ 1 & 0 & 0 \\ 0 & 0 & 1 \end{bmatrix}, \quad P_{13} = \begin{bmatrix} 0 & 0 & 1 \\ 0 & 1 & 0 \\ 1 & 0 & 0 \end{bmatrix}, \quad P_{23} = \begin{bmatrix} 1 & 0 & 0 \\ 0 & 0 & 1 \\ 0 & 1 & 0 \end{bmatrix}

and the two cycles that move every row:

[010001100],[001100010]\begin{bmatrix} 0 & 1 & 0 \\ 0 & 0 & 1 \\ 1 & 0 & 0 \end{bmatrix}, \qquad \begin{bmatrix} 0 & 0 & 1 \\ 1 & 0 & 0 \\ 0 & 1 & 0 \end{bmatrix}

Multiply any two of these together and the answer is on the list — doing some row exchanges and then some more row exchanges is, all together, row exchanges. Invert any one and you’re still inside the family. “Group is the right name for this subject”: the six matrices form a group.

How many 4×44 \times 4 permutation matrices? Twenty-four. The next lecture puts them to work.

Problems

Work these before revealing the solutions — everything you need is in the lecture.

Problem 4.1 Inverses in reverse order

Let

A=[1051],B=[1201]A = \begin{bmatrix} 1 & 0 \\ 5 & 1 \end{bmatrix}, \qquad B = \begin{bmatrix} 1 & 2 \\ 0 & 1 \end{bmatrix}

Write down A1A^{-1} and B1B^{-1} (no computation needed — these are elimination-type matrices). Then compute (AB)1(AB)^{-1} using the reverse-order rule and verify it against ABAB.

Show solution

Flip the signs of the off-diagonal entries: A1=[1051]A^{-1} = \begin{bmatrix} 1 & 0 \\ -5 & 1 \end{bmatrix}, B1=[1201]B^{-1} = \begin{bmatrix} 1 & -2 \\ 0 & 1 \end{bmatrix}.

Reverse order:

(AB)1=B1A1=[1201][1051]=[11251](AB)^{-1} = B^{-1}A^{-1} = \begin{bmatrix} 1 & -2 \\ 0 & 1 \end{bmatrix}\begin{bmatrix} 1 & 0 \\ -5 & 1 \end{bmatrix} = \begin{bmatrix} 11 & -2 \\ -5 & 1 \end{bmatrix}

Verify: AB=[12511]AB = \begin{bmatrix} 1 & 2 \\ 5 & 11 \end{bmatrix}, and

[12511][11251]=[11102+2555510+11]=[1001]\begin{bmatrix} 1 & 2 \\ 5 & 11 \end{bmatrix}\begin{bmatrix} 11 & -2 \\ -5 & 1 \end{bmatrix} = \begin{bmatrix} 11 - 10 & -2 + 2 \\ 55 - 55 & -10 + 11 \end{bmatrix} = \begin{bmatrix} 1 & 0 \\ 0 & 1 \end{bmatrix} \checkmark
Problem 4.2 LU by hand

Factor into A=LUA = LU by elimination:

A=[121381041]A = \begin{bmatrix} 1 & 2 & 1 \\ 3 & 8 & 1 \\ 0 & 4 & 1 \end{bmatrix}

Record the multipliers as you go, and check your factorization by multiplying LULU back together.

Show solution

Multiplier 21=3\ell_{21} = 3: subtract 33 of row one from row two.

[121022041]\begin{bmatrix} 1 & 2 & 1 \\ 0 & 2 & -2 \\ 0 & 4 & 1 \end{bmatrix}

The (3,1)(3,1) entry is already zero, so 31=0\ell_{31} = 0. Multiplier 32=2\ell_{32} = 2: subtract 22 of the new row two from row three.

U=[121022005]U = \begin{bmatrix} 1 & 2 & 1 \\ 0 & 2 & -2 \\ 0 & 0 & 5 \end{bmatrix}

The multipliers go directly into LL:

L=[100310021]L = \begin{bmatrix} 1 & 0 & 0 \\ 3 & 1 & 0 \\ 0 & 2 & 1 \end{bmatrix}

Check row three of LULU: 0(1,2,1)+2(0,2,2)+(0,0,5)=(0,4,1)0 \cdot (1,2,1) + 2 \cdot (0,2,-2) + (0,0,5) = (0,4,1). ✓ Row two: 3(1,2,1)+(0,2,2)=(3,8,1)3(1,2,1) + (0,2,-2) = (3,8,1). ✓

Problem 4.3 Why E is worse than L

Suppose E21E_{21} subtracts 33 times row one from row two, E31=IE_{31} = I, and E32E_{32} subtracts 44 times row two from row three (all 3×33 \times 3). Compute the product E=E32E21E = E_{32}E_{21} and the product L=E211E321L = E_{21}^{-1}E_{32}^{-1}. Which entry of EE is “interference,” and why is it absent from LL?

Show solution
E=[100010041][100310001]=[1003101241]E = \begin{bmatrix} 1 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & -4 & 1 \end{bmatrix} \begin{bmatrix} 1 & 0 & 0 \\ -3 & 1 & 0 \\ 0 & 0 & 1 \end{bmatrix} = \begin{bmatrix} 1 & 0 & 0 \\ -3 & 1 & 0 \\ 12 & -4 & 1 \end{bmatrix}

The 1212 in the (3,1)(3,1) position is the interference: three of row one was removed from row two, then four of that new row two from row three, so twelve of row one got thrown into row three.

In reverse order with plus signs:

L=[100310001][100010041]=[100310041]L = \begin{bmatrix} 1 & 0 & 0 \\ 3 & 1 & 0 \\ 0 & 0 & 1 \end{bmatrix} \begin{bmatrix} 1 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 4 & 1 \end{bmatrix} = \begin{bmatrix} 1 & 0 & 0 \\ 3 & 1 & 0 \\ 0 & 4 & 1 \end{bmatrix}

No 1212: in this order the multipliers 33 and 44 don’t interact — they just sit in their own positions. That is exactly why A=LUA = LU is the preferred form: LL is free.

Problem 4.4 Operation counts

Elimination on a 1000×10001000 \times 1000 matrix takes roughly how many operations? If you then need to solve Ax=bA\mathbf{x} = \mathbf{b} for 5050 different right-hand sides b\mathbf{b}, roughly what does that add? Finally: if nn doubles, by what factor does the cost of elimination on AA grow?

Show solution

Cost on AA: about 13n3=13(1000)33.3×108\tfrac{1}{3}n^3 = \tfrac{1}{3}(1000)^3 \approx 3.3 \times 10^8 operations.

Each right-hand side costs about n2=106n^2 = 10^6 operations, so 5050 of them add about 5×1075 \times 10^7 — still much less than the one-time cost of factoring AA. That’s the payoff of A=LUA = LU: factor once, then every new b\mathbf{b} is cheap.

Doubling nn multiplies 13n3\tfrac{1}{3}n^3 by 23=82^3 = 8: a 2000×20002000 \times 2000 system costs about eight times as much as a 1000×10001000 \times 1000 one.

Problem 4.5 The permutation group

Let

P=[010001100]P = \begin{bmatrix} 0 & 1 & 0 \\ 0 & 0 & 1 \\ 1 & 0 & 0 \end{bmatrix}

(the cycle that moves row two up to row one, row three up to row two, and row one down to row three). Find P1P^{-1}, verify that P1=PTP^{-1} = P^{\mathsf{T}}, and say how many 5×55 \times 5 permutation matrices there are.

Show solution

To undo the cycle, send each row back where it came from: row one back down to row two, row two down to row three, row three up to row one. That is the other cycle:

P1=[001100010]P^{-1} = \begin{bmatrix} 0 & 0 & 1 \\ 1 & 0 & 0 \\ 0 & 1 & 0 \end{bmatrix}

Check: PP1PP^{-1} — row one of PP picks out row two of P1P^{-1}, which is (1,0,0)(1,0,0); row two picks out row three, (0,1,0)(0,1,0); row three picks out row one, (0,0,1)(0,0,1). So PP1=IPP^{-1} = I. ✓

Transposing PP (exchange rows and columns) gives exactly the same matrix as P1P^{-1} above, confirming P1=PTP^{-1} = P^{\mathsf{T}}.

The number of n×nn \times n permutation matrices is the number of ways to rearrange nn rows: n!n!. For n=5n = 5 that is 120120.