Gaussian Elimination
The general method for solving square systems of linear equations.
Solving Triangular Systems
Before tackling general systems, we first look at systems that are already in a "nice" form: Triangular Matrices.
Lower Triangular ($L$)
All non-zero elements are on or below the diagonal.
Method: Forward Substitution
Upper Triangular ($U$)
All non-zero elements are on or above the diagonal.
Method: Backward Substitution
Algorithm: Backward Substitution
Gaussian Elimination
Our goal is to transform an arbitrary square system $Ax=b$ into an equivalent upper triangular system $Ux=c$, which we can then solve easily.
Hand Calculation Example
Original System
$2x_1 + 4x_2 = 6$
Elimination ($R_2 \leftarrow R_2 - 2R_1$)
$0 - 2x_2 = -4$
Solve $x_2 = 2$, then substitute back to get $x_1 = -1$.
The "Cartoon" View
Visualizing how zeros propagate through the matrix.
[ x x x ]
[ x x x ]
[ 0 x x ]
[ 0 x x ]
[ 0 x x ]
[ 0 0 x ]
The Algorithm & Cost
Forward Elimination Code
Computational Cost
Total Cost: $\mathcal{O}(n^3)$
Doubling $n$ increases cost by factor of 8.
Elementary Elimination Matrices
We can represent the row operations as matrix multiplications. To eliminate entries below the $k$-th diagonal, we use matrix $M_k$.
Where $m_i = a_i / a_k$ are the multipliers.
The Inverse: $L_k$
The inverse of an elimination matrix is incredibly simple. Just flip the sign of the multipliers!
LU Factorization
We transform $A$ to upper triangular $U$ by applying a sequence of matrices: \[ (M_{n-1} \dots M_2 M_1) A = U \]
Inverting the $M$'s moves them to the other side: \[ A = (M_1^{-1} M_2^{-1} \dots M_{n-1}^{-1}) U \]
The product of the inverses is a lower triangular matrix $L$. Thus:
This factors matrix $A$ into a Lower triangular matrix $L$ and an Upper triangular matrix $U$.
Why "Naive"?
The algorithm described is called "Naive" because it assumes we can always divide by the pivot $A(k,k)$.
Zero Pivot
[ 4 5 6 ]
[ 7 8 9 ]
Division by zero error immediately!
Small Pivot
[ 4 5 6 ]
[ 7 8 9 ]
Leads to massive roundoff error (Loss of Significance).
š§ Final Challenge +20 XP
What is the structure of the matrix $M_k$ used to eliminate elements in the $k$-th column?