Why factor a matrix at all?
Solving A*x = b once is easy. But in practice you often solve it again and again with the same A and a new b each time — many right-hand sides, one matrix. Redoing elimination from scratch every time wastes work. A factorization does the hard part once and stores the result as a product of simpler matrices.
Simpler matrices — triangular or orthogonal ones — are easy to solve with. So the whole game of this rung is: turn a hard matrix into a product of easy ones.
LU: elimination, remembered
Gaussian elimination turns A into an upper-triangular matrix U by subtracting rows. LU decomposition simply remembers the multipliers you used in a lower-triangular matrix L. The result is A = L*U: U is what elimination produces, and L records how you got there.
A = L*U
Solve A*x = b -> L*y = b (forward)
U*x = y (backward)QR: Gram-Schmidt, packaged
QR decomposition writes A = Q*R, where Q has orthonormal columns and R is upper-triangular. This is exactly Gram-Schmidt on the columns of A, with R bookkeeping the lengths and overlaps. Because Q's columns are orthonormal, multiplying by Q does not stretch or distort — that is what makes QR numerically stable.
- Take the columns of A one at a time.
- Subtract off their projections onto the directions already chosen.
- Normalize what remains to length 1 — these become the columns of Q.
- Collect the lengths and overlaps into the upper-triangular R.