Gaussian elimination is the fundamental algorithm for solving Ax=b without ever computing A−1. It works by applying systematic row operations to transform A into a triangular form. Once in triangular form, the system is easy to solve by simple substitution — each equation contains one fewer unknown than the one below it, so we can unwind the solution one variable at a time.
Triangular Matrices
Two special matrix shapes make substitution trivial.
A lower triangular matrixL has zeros everywhere above the main diagonal:
L=l11l21⋮ln10l22⋮ln2……⋱…00⋮lnn
An upper triangular matrixU has zeros everywhere below the main diagonal:
U=u110⋮0u12u22⋮0……⋱…u1nu2n⋮unn
Forward Substitution
When the system Lx=b is lower triangular, we can solve it top-down: find x1 from the first equation, substitute into the second to find x2, and so on. This is called forward substitution.
Because we solve from x1 down to xn, this is called a top-down approach.
Operation Count
For the j-th variable, we always need 1 division, (j−1) multiplications, and (j−1) subtractions. The total number of arithmetic operations across all n variables is:
Total operations=∑j=1n[1+2(j−1)]
=∑j=1n(2j−1)
=2∑j=1nj−∑j=1n1
=2⋅2n(n+1)−n
=n(n+1)−n
=n2
Forward substitution on a lower triangular n×n system costs exactly n2 arithmetic operations.
Applying Gaussian Elimination
To solve a general Ax=b, we first transform A into upper triangular form using row operations. The key operation is: for each column k, eliminate all entries below the diagonal by subtracting a scaled multiple of row k from every row below it.
Starting from a general 4×4 matrix, the column-by-column elimination looks like this:
Each arrow represents one round of row operations that zeroes out one column below the diagonal. After n−1 rounds the matrix is in upper triangular form and the system can be solved by back substitution (the top-down logic in reverse: solve xn first, then substitute upward).
The diagonal element used to eliminate entries below it in each round is called the pivot. A non-zero pivot is required for each step to proceed.
The general formula for the multiplier used to eliminate entry aik in column k is:
mik=akkaik
And the row operation applied to row i is:
Ri←Ri−mikRk
Worked Example: Augmented Matrix
Problem: Solve the following system using Gaussian elimination.
x1+2x2+x3=0
x1−2x2+2x3=4
2x1+12x2−2x3=4
Step 1 — Set up the augmented matrix
Write A and b side by side, separated by a vertical bar:
1122−21212−2044
Step 2 — First round of elimination (clear column 1 below the pivot)
The pivot is a11=1. Compute multipliers m21=a11a21=11=1 and m31=a11a31=12=2.
Apply R2←R2−m21R1 and R3←R3−m31R1:
1002−4811−4044
Step 3 — Second round of elimination (clear column 2 below the pivot)
The new pivot is a22=−4. Compute multiplier m32=a22a32=−48=−2.
Apply R3←R3−m32R2:
1002−4011−20412
The matrix is now upper triangular. The corresponding system is: