LU Decomposition and Efficient Solving
LU decomposition factors a matrix as , where is a permutation matrix (from row swaps), is unit lower triangular (the elimination multipliers on and below the diagonal), and is upper triangular (the echelon form).
Why is this useful? To solve : compute (apply row permutations, ), then solve by forward substitution (), then solve by back substitution (). Total: per right-hand side after one-time factorization.
This pays off when solving for many different : factorize once (), then solve each system in . MATLAB's uses LU under the hood.
Formal View
Interactive Visualization
LU Decomposition Animator
Why This Matters
LU decomposition is the backbone of practical linear system solving in science and engineering.
- MATLAB's backslash operator, NumPy's `linalg.solve`, and LAPACK all use LU decomposition
- Finite element analysis solves the same stiffness matrix for many load vectors
- Real-time simulation in games uses pre-factored LU to solve physics constraints efficiently
Quiz
If , solving requires:
LU decomposition is most efficient when the same matrix is used to solve systems with many different right-hand sides.
Common Mistakes
- Computing explicitly to solve — LU decomposition is far more efficient and numerically stable.
- Forgetting the permutation matrix — it records the row swaps needed for numerical stability.
- Applying LU to singular matrices — LU decomposition requires invertibility for the square case.