Gaussian elimination is the workhorse algorithm of linear algebra. It systematically transforms matrices into echelon forms, enabling us to solve linear systems, compute ranks, and understand the structure of solutions.
Although named after Carl Friedrich Gauss (1777–1855), systematic elimination methods for solving linear equations date back to ancient civilizations. The Nine Chapters on the Mathematical Art, a Chinese text from around 200 BCE, contains methods equivalent to Gaussian elimination for solving systems of linear equations.
Gauss used the method extensively in his work on astronomy and geodesy, particularly in his method of least squares for fitting curves to observational data. His systematic approach and clear exposition led to the method bearing his name.
Wilhelm Jordan (1842–1899), a German geodesist, later developed the refinement that produces reduced row echelon form, which is why RREF is sometimes calledGauss-Jordan elimination.
Today, Gaussian elimination forms the backbone of numerical linear algebra. Modern implementations include pivoting strategies and are optimized for computer architectures, enabling the solution of systems with millions of variables.
Every step in Gaussian elimination consists of one of three elementary row operations. These operations preserve the solution set of a linear system.
The three elementary row operations (EROs) on a matrix are:
If matrix is obtained from matrix by a sequence of elementary row operations, then the systems and (where is obtained by applying the same operations to ) have the same solution set.
Each ERO is reversible:
If satisfies one system, applying the operations shows it satisfies the other, and vice versa by applying the inverse operations.
Apply EROs to eliminate the entry below the pivot:
The first pivot is now 1, and we've eliminated the entry below it.
We often swap rows to get a "nice" pivot (like 1) or to avoid dividing by small numbers (numerical stability). Any non-zero entry in the pivot column will work mathematically, but some choices are better computationally.
An elementary matrix is obtained by applying one ERO to the identity matrix. Left-multiplying by an elementary matrix performs that ERO on any matrix.
For matrices:
Every elementary matrix is invertible, and is also elementary:
If we record all elementary matrices used: (REF), then . This is theLU decomposition, fundamental in numerical computing.
A matrix is in row echelon form (REF) if:
These matrices are in REF (pivots shown in bold):
This matrix is NOT in REF:
INPUT: m × n matrix A
OUTPUT: REF of A
for j = 1 to n:
# Find pivot in column j
Find row i ≥ current row with A[i,j] ≠ 0
if no such row exists:
continue to next column
# Move pivot to current row
Swap current row with row i
# Eliminate entries below pivot
for each row k below current row:
if A[k,j] ≠ 0:
A[k] ← A[k] - (A[k,j]/A[current,j]) × A[current]
Advance to next row
return AReduce to row echelon form:
Step 1: Eliminate below first pivot (column 1):
Step 2: Column 2 has no pivot candidates. Move to column 3:
This is REF. Pivot columns are 1 and 3.
A pivot is the first non-zero entry in a row of an echelon form. The pivot position is the location (row, column) of a pivot. A pivot column is a column containing a pivot position.
The pivots in REF form a "staircase" pattern descending from left to right. Each step down corresponds to moving to the next row, and each step right corresponds to moving to at least the next column.
For the REF:
Pivot positions: (1,1), (2,3), (3,4). Pivot columns: 1, 3, 4.
Non-pivot column: 2. If this were a system, column 2 would give a free variable.
Matrices and are row equivalent if one can be obtained from the other by EROs. Row equivalent matrices have:
A matrix is in reduced row echelon form (RREF) if:
Every matrix has a unique reduced row echelon form.
To obtain RREF from REF, perform back substitution: starting from the rightmost pivot, scale each pivot row to make the pivot 1, then eliminate all entries above it.
Continue from Example 1.3:
This is RREF. Pivots are 1, in columns 1 and 3.
INPUT: m × n matrix A
OUTPUT: RREF of A
# Forward phase (produce REF)
Apply Gaussian Elimination to get REF
# Backward phase (produce RREF)
for each pivot, from bottom to top:
# Scale row to make pivot = 1
Divide pivot row by pivot value
# Eliminate entries above pivot
for each row above the pivot row:
if entry in pivot column ≠ 0:
Subtract appropriate multiple
return AForward elimination requires operations for an matrix. Back substitution adds operations. For RREF, the backward phase also costs .
Reduce completely to RREF:
Forward phase:
Backward phase:
This is the RREF. Pivot columns: 1 and 3. Rank = 2.
For the system , the augmented matrix is , formed by appending as an extra column.
For a linear system with augmented matrix in RREF:
Solve the system:
Form augmented matrix and reduce to RREF:
Pivot columns: 1, 3 (basic variables: , ). Free variable: .
Reading off equations: and .
Solution: , , for any .
In vector form:
Determine if the system has solutions:
The second row reads , which is impossible. No solution exists.
Variables corresponding to pivot columns are basic variables. Variables corresponding to non-pivot columns are free variables.
Free variables can take any value; basic variables are determined by the free variables.
The solution to a system with free variables is typically written inparametric vector form:
where is a particular solution and span the null space.
A homogeneous system is always consistent (has as a solution). It has non-trivial solutions if and only if there are free variables, i.e., if .
Consider the system:
Both equations represent the same line . The solution set is this entire line: .
Three linear equations in 3 variables represent three planes. Possible configurations:
The rank of a matrix , denoted , is the number of pivot positions in any echelon form of .
Equivalently, it equals the number of non-zero rows in the RREF of .
For an matrix and system :
The rank will later be identified with the dimension of the column space (image) of the matrix. The number of free variables equals the dimension of the null space (kernel). The Rank-Nullity Theorem states:
Find the rank of:
Solution: Reduce to REF:
Two non-zero rows, so .
An matrix is invertible if and only if , i.e., the RREF of is the identity matrix.
For an matrix with rank :
These four subspaces are deeply connected. The row space and null space are orthogonal complements in . The column space and left null space are orthogonal complements in .
For which values of does the system have a solution?
Solution: The coefficient matrix has (Row 2 = 3×Row 1).
For consistency, we need as well.
This requires .
So the system has solutions iff for some .
If is with (full row rank), then has a solution for every .
If is with (full column rank), then has at most one solution for any .
INPUT: n × n matrix A
OUTPUT: A⁻¹ (or indication that A is not invertible)
Form augmented matrix [A | I]
Reduce [A | I] to RREF
if left half becomes I:
return right half (this is A⁻¹)
else:
A is not invertibleFind the inverse of:
Form and reduce:
Therefore:
Try to find the inverse of:
Form and reduce:
The left half cannot become (row of zeros). B is not invertible.
Always verify: if you found , check that or. One equality implies the other for square matrices.
Find the inverse of:
Form and reduce to RREF:
Therefore:
For invertible matrices and :
For numerical applications, computing explicitly is often avoided. Instead, systems are solved directly using LU decomposition, which is more numerically stable and efficient.
For theoretical purposes, the inverse can also be computed via the adjugate matrix:
This is useful for proving theorems but inefficient computationally.
Problem: Solve the system:
Solution: Form augmented matrix and reduce:
Back substitution:
Answer:
Problem: Solve:
Solution:
Free variable: . Then , .
Answer: for
Problem: Find all solutions to where:
Solution: Reduce to RREF:
Pivot columns: 1 and 3. Free variable: .
From RREF: and .
So , , .
Null space basis:
Problem: Find a basis for the column space of:
Solution: The RREF is:
Pivot columns are 1 and 3. Take the original columns 1 and 3:
Basis:
Problem: Solve:
Solution:
Row 2 is , which is inconsistent.
No solution exists.
Problem: Find a basis for the row space of:
Solution: Reduce to REF:
The non-zero rows of the REF form a basis for the row space:
Basis: or equivalently
Problem: What can you say about the rank of:
Solution: Note that Row 3 = 2(Row 2) − Row 1.
So the rows are linearly dependent, meaning rank < 3.
By REF, we found 2 non-zero rows, so .
This also means (singular matrix).
Problem: Show that the matrix is full rank:
Solution: Reduce to REF:
3 pivots in a 3×3 matrix means (full rank).
Therefore is invertible.
Problem: Find all solutions to:
Solution: Reduce to RREF:
Pivot columns: 1 and 3. Free variables: , .
From row 2: . From row 1: .
Solution:
Problem: Are the vectors , , linearly independent?
Solution: Form matrix with vectors as columns and find rank:
Rank = 2 < 3, so the vectors are linearly dependent.
From RREF: .
When solving , every row operation on must also be applied to the column. Forgetting this gives wrong solutions.
The column space basis comes from the original matrix's pivot columns, not the RREF's columns (which are just standard basis vectors).
Multiplying a row by zero is NOT a valid ERO—it's not reversible and destroys information. The scalar must be non-zero.
REF only requires zeros below pivots. RREF additionally requires pivots = 1 and zeros both above AND below each pivot.
A row of zeros [0 0 ... 0 | 0] is fine—it just means a dependent equation. Only [0 0 ... 0 | c] with indicates no solution.
Double-check each row operation carefully. A single arithmetic error propagates through all subsequent steps. Consider verifying by substituting solutions back into original equations.
In back-substitution, work from bottom to top. Solve for the last basic variable first, then substitute upward. Working in the wrong order leads to errors.
Swap rows, scale by non-zero constant, add multiple of one row to another. These preserve solution sets and are all reversible.
REF: zeros below pivots, staircase pattern. RREF: also pivots = 1 and zeros above pivots. RREF is unique; REF is not.
Number of pivots = rank = dimension of column space = number of basic variables. Free variables = n − rank = dimension of null space.
No solution: inconsistent row [0...0|c]. Unique: all columns are pivot columns. Infinitely many: consistent with free variables.
Reduce [A|I] to RREF. If left half becomes I, right half is A⁻¹. If left half has zero row, A is not invertible.
From RREF: for each free variable, set it to 1 (others to 0) and solve for basic variables. These vectors form a null space basis.
The pivot columns of the ORIGINAL matrix (not RREF) form a basis for the column space. RREF identifies which columns to take.
Gaussian elimination is used everywhere: solving circuits, balancing chemical equations, computer graphics, machine learning, and cryptography.
| To Find... | Method |
|---|---|
| Solution to Ax = b | Reduce [A|b] to RREF, read off solution |
| Rank of A | Count pivots in REF/RREF |
| Null space basis | RREF of A, solve for free variables |
| Column space basis | Pivot columns of original A |
| Row space basis | Non-zero rows of REF |
| Inverse of A | Reduce [A|I] to RREF |
In REF, pivots are 'leading entries' with zeros below them, and each pivot is to the right of pivots above. RREF additionally requires: (1) all pivots are 1, and (2) each pivot is the only non-zero entry in its column.
It determines matrix rank, finds bases for column/null spaces, computes determinants (via REF), tests linear independence, and underlies the LU decomposition used in numerical computing.
Yes! Every matrix has a unique RREF. Different sequences of row operations may be used, but the final RREF is always the same. REF is not unique—different choices of pivots give different REFs.
A system Ax = b is consistent iff b is in the column space of A, which happens iff the augmented matrix [A|b] and A have the same rank. Equivalently, no row in the RREF of [A|b] has the form [0 0 ... 0 | c] with c ≠ 0.
For an n×n matrix, Gaussian elimination requires O(n³) arithmetic operations. This makes it efficient for moderate-sized systems but expensive for very large matrices, where iterative methods may be preferred.
Partial pivoting means selecting the largest (in absolute value) entry in the current column as the pivot. This improves numerical stability by reducing rounding errors. Without pivoting, small pivots can lead to catastrophic error amplification in floating-point arithmetic.
Yes! Gaussian elimination works over any field (ℚ, ℝ, ℂ, finite fields, etc.). The algorithm only uses field operations: addition, subtraction, multiplication, and division by non-zero elements.
LU decomposition records the steps of Gaussian elimination. The matrix L contains the multipliers used during elimination, while U is the resulting row echelon form. We have A = LU, which allows efficient solving of multiple systems with the same coefficient matrix.
From the RREF: (1) identify free variables (non-pivot columns), (2) set each free variable to 1 (others to 0) one at a time, (3) solve for basic variables. Each such vector is a basis element of the null space.
REF allows any non-zero pivot values and doesn't require elimination above pivots. Different row operation sequences can yield different REFs. RREF's strict requirements (pivots = 1, only entry in column) force a unique result.