消元的每一步都是一个初等矩阵;把它们的逆按相反顺序乘回去,就得到 A = LU。L 里直接保存乘数,U 保存主元与消元结果。
A = LU: Writing Elimination as a Factorization
Each elimination step is an elementary matrix. Multiplying their inverses in reverse order gives A = LU: L stores the multipliers directly, U stores the pivots and the result.
两者只差低阶项。所以消元是 O(n3),而处理一个右端向量只要 O(n2)——这正是「多个右端共享同一个 A 时先做一次 LU」更划算的原因。
5. 为什么排列矩阵的逆等于它的转置?
参考答案:排列矩阵 P 是把单位矩阵的行重新排列得到的,所以它的每一列恰好是某个标准基向量 eσ(i)。两个不同的列是互相垂直的单位向量,自身点积为 1。因此
PTP=I,
即 PT 是 P 的逆。直观上:P 把行按某个置换搬动,PT 把它搬回去;搬过去再搬回来就是原样,所以转置恰好完成了逆的操作。
与前后课的关系
LU 把消元从一个过程变成了一个对象。下一讲转向转置、排列与向量空间 Rn,为四个基本子空间做准备。
Two small formulas first
The inverse of a product reverses the order
If A and B are invertible, then
(AB)−1=B−1A−1.
Check:
(AB)(B−1A−1)=A(BB−1)A−1=AIA−1=I.
The order must reverse, like shoes and socks: shoes come off first, so socks go on first when undoing the process.
Transpose and inverse commute
Start from A−1A=I and transpose both sides:
(A−1A)T=IT=I.
Since (A−1A)T=AT(A−1)T,
AT(A−1)T=I,
so
(AT)−1=(A−1)T.
For a single matrix, transposing and inverting can be done in either order.
Timeline
Time
Topic
0:12
Lecture four: A=LU
2:04
The inverse of a product and of a transpose
2:58
Products that give the identity
4:23
The inverse formula
5:47
(AT)−1=(A−1)T
9:53
The elimination matrix E
10:49
How L relates to E
12:01
Why the letter L
14:57
A=LU when no rows are exchanged
16:08
Inverting the factors in reverse order
17:23
The 2×2 case
23:11
The 3×3 case: multipliers do not interfere
25:56
Moving the inverses to the other side
29:24
Counting the operations
31:56
The cost of elimination
36:31
The upper bound n3
39:23
The cost of handling b
41:41
Row exchanges: PA=LU
47:16
How many n×n permutation matrices
The core: A=LU
Assume no row exchanges are needed and no pivot is zero. Each elimination step is an elementary matrix Eij, and at the end
E32E31E21A=U.
Call the product E, so EA=U. To isolate A, multiply on the left by E−1:
A=E−1U.
The inverse of a product reverses the order:
E−1=(E32E31E21)−1=E21−1E31−1E32−1.
That product is L:
A=LU.
U is upper triangular; L is lower triangular with ones on the diagonal.
A 2×2 example
A=[2817].
The first pivot is 2, and eliminating the 8 below it needs multiplier 8/2=4:
E21=[1−401],U=[2013].
Check E21A=U: the second row is −4 times row one plus row two, [8,7]−4[2,1]=[0,3].
L is E21−1: change −4 to +4.
L=[1401],A=[1401][2013]=[2817].
Pulling out the pivots: LDU
Factor the diagonal out of U:
U=[2003][101/21]=DU′.
Then A=LDU′: unit triangular matrices on both sides and a diagonal matrix in the middle. MATLAB may return either form; the course mostly uses LU.
The 3×3 case: why L holds the multipliers directly
For three dimensions the elimination sequence is
E32E31E21A=U,
so
A=E21−1E31−1E32−1U=LU.
The real question is why L is nicer than E. Take a typical case:
E21=1−20010001,E31=I,E32=10001−5001.
First compute E=E32E21:
E=1−21001−5001.
A 10 appears in position (3,1). Where from? Subtracting twice row one from row two, then five times the new row two from row three, throws 5×2=10 copies of row one into row three.
Nothing is wrong, but E is hard to read: the multipliers 2 and 5 are entangled.
The multipliers 2 and 5 sit exactly where they belong, and position (3,1) is 0.
One-sentence summary: With no row exchanges, L is a ledger of multipliers — whatever multiplier elimination used goes straight into the corresponding slot of L.
This is why LU is the right record of elimination: once it is done, all the information in A lives in L and U, and the original matrix can be discarded.
Operation count: why n3/3
How expensive is elimination? For an n×n matrix, the first step updates about n2 entries. The second works on the remaining (n−1)×(n−1) block, about (n−1)2 operations. Continuing:
n2+(n−1)2+⋯+22+12.
There are n terms, the largest is n2, so the crude bound is n3. More precisely,
k=1∑nk2=6n(n+1)(2n+1)≈3n3.
The integral makes the constant visible:
∫0nx2dx=3n3.
So elimination is O(n3). The right-hand side b is a single column, so handling it costs O(n2).
That yields a practical rule: when many right-hand sides share the same A, factor once into LU, then run forward and back substitution at O(n2) per right-hand side. It is far cheaper than re-eliminating each time.
When rows must be exchanged: permutations
If a zero appears in a pivot position, rows must be swapped. A permutation matrixP does the swapping; it is the identity with its rows rearranged.
There are 3!=6 permutation matrices of size 3, and 4!=24 of size 4. They form a group:
the product of two permutations is another permutation;
every permutation is invertible, and its inverse is also a permutation;
in fact, P−1=PT. Swapping two rows twice restores the original, so many P are their own inverse; in general the inverse equals the transpose.
With row exchanges, the factorization becomes
PA=LU.
The permutation records the row order first, and L and U keep the same structure.
Takeaways
(AB)−1=B−1A−1: the order reverses.
(AT)−1=(A−1)T.
Without row exchanges, E32E31E21A=U, hence A=E21−1E31−1E32−1U=LU.
L has ones on the diagonal and the multipliers off it; U has the pivots on its diagonal.
A=LDU′ separates the pivots from the unit triangular factors.
Elimination costs about n3/3; each right-hand side costs about n2.
With row exchanges, PA=LU. There are n! permutation matrices, and P−1=PT.
Check your understanding
1. Verify (AB)−1=B−1A−1 and explain why the order cannot be preserved.
Reference answer: Multiply directly:
(AB)(B−1A−1)=A(BB−1)A−1=AIA−1=I,
so B−1A−1 really is the inverse of AB. The order cannot be kept, because
(AB)(A−1B−1)=A(BA−1)B−1,
and BA−1 is generally not A−1B unless the two matrices commute; then the product is not I. The picture is getting dressed: socks first, then shoes, so undressing must remove the shoes first and the socks second — reversed order.
2. For A=[2817], write E21, U, and L, and verify A=LU.
Reference answer: The first pivot is 2; clearing the 8 uses multiplier 8/2=4, so
E21=[1−401],U=[2013].
Check E21A=U: row two becomes [8,7]−4[2,1]=[0,3]. Then L=E21−1 changes −4 to +4:
L=[1401].
Indeed
LU=[1401][2013]=[2817]=A.
3. In the 3×3 example, why is the (3,1) entry of E equal to 10, while the same entry of L is 0?
Reference answer: Here E=E32E21. After E21, row two is the original row two minus twice row one; then E32 subtracts five times that new row two from row three. So row three loses 5×2=10 times row one in total, and the (3,1) entry becomes −5⋅(−2)=10: the two multipliers have been multiplied together and mixed. In L=E21−1E32−1 the operations are undone in reverse order — first restore five times row two, then twice row one — so the multipliers 2 and 5 sit in their own positions and (3,1) is untouched at 0. That is why L reads as a ledger of multipliers.
4. Explain the n3/3 count both with the sum of squares and with an integral.
Reference answer: The first elimination step updates roughly n2 entries; the next works on the remaining (n−1)×(n−1) block, about (n−1)2 operations, and so on, giving
k=1∑nk2=6n(n+1)(2n+1)=3n3+O(n2)≈3n3.
As an integral, the sum is a Riemann sum for x2 on [0,n]:
∫0nx2dx=3n3,
differing only in lower-order terms. Hence elimination costs O(n3), while each right-hand side costs O(n2) — which is why one LU factorization pays off when many right-hand sides share A.
5. Why is the inverse of a permutation matrix equal to its transpose?
Reference answer: A permutation matrix is the identity with its rows rearranged, so each column is a standard basis vector eσ(i). Distinct columns are orthogonal unit vectors, and each has squared length 1. Therefore
PTP=I,
so PT is the inverse of P. In words: P moves rows by a permutation, and PT moves them back; doing both is the identity.
How it connects
LU turns elimination from a process into an object. The next lecture turns to transposes, permutations, and the vector space Rn, preparing the ground for the four fundamental subspaces.