Uniqueness of the Reduced Echelon Form
Two people row-reducing the same matrix may choose different pivots, swap different rows and get different echelon forms along the way. Yet if both go all the way to the reduced row echelon form, they always end with exactly the same matrix. This lesson explains why, and why that matters.
Echelon forms are not unique
Here are two different row echelon forms of the same matrix:
Both are valid echelon forms, with different numbers. Their RREF, however, is the same: .
The theorem
Theorem. Every matrix is row equivalent to exactly one matrix in reduced row echelon form.
Existence is the Gauss-Jordan algorithm: it always terminates with an RREF. The interesting part is uniqueness.
Why it is unique (proof sketch)
The idea: an RREF is completely determined by which linear relations hold among the columns, and row operations never change those relations.
Step 1. Row operations preserve column relations. A relation says exactly that is a solution of the homogeneous system . Row operations do not change the solutions of a system (Elementary Operations). So if and are row equivalent, they have exactly the same column relations.
Step 2. The relations determine the pivot columns. In an RREF, column is a pivot column exactly when it is not a combination of the columns to its left (a pivot column has a 1 in a row where all earlier columns are 0). That property is a statement about column relations, so by Step 1 it is the same for any two RREFs and of . They have the same pivot columns.
Step 3. The relations determine the other entries. The pivot columns of an RREF are the standard columns in order. A non-pivot column is a combination of the pivot columns to its left, and its entries are precisely the coefficients of that combination:
The same relation holds in , with the same pivot columns , so has the same entries in column . Hence . ∎
Consequences
| Consequence | Why it matters |
|---|---|
| The pivot positions of are well defined | any echelon form, not only the RREF, has its pivots in the same columns |
| The number of pivots, the rank of , is well defined | it does not depend on how you reduced |
| The number of free variables is well defined | the dimension of the solution set is a property of the system |
| a mechanical test for row equivalence |
Seeing it in code
Apply a long random sequence of row operations to a matrix: the RREF never changes.
import random
from sympy import Matrix
A = Matrix([[1, 2, -1, 3], [2, 4, 0, 2], [-1, -2, 3, -7]])
print("RREF of A:", A.rref()[0].tolist())
random.seed(4)
B = A.copy()
for step in range(30):
i, j = random.sample(range(3), 2)
op = random.choice(["swap", "scale", "add"])
if op == "swap":
B = B.elementary_row_op("n<->m", row1=i, row2=j)
elif op == "scale":
B = B.elementary_row_op("n->kn", row=i, k=random.choice([-3, -2, 2, 5]))
else:
B = B.elementary_row_op("n->n+km", row=i, k=random.randint(-4, 4), row2=j)
print("scrambled B:", B.tolist())
print("RREF of B:", B.rref()[0].tolist())
print("same RREF:", A.rref()[0] == B.rref()[0])RREF of A: [[1, 2, 0, 1], [0, 0, 1, -2], [0, 0, 0, 0]]
scrambled B: [[3050, 6100, -4962, 12974], [-1040, -2080, 1680, -4400], [2098, 4196, -3378, 8854]]
RREF of B: [[1, 2, 0, 1], [0, 0, 1, -2], [0, 0, 0, 0]]
same RREF: True
Because the RREF is unique, it works as a canonical form: a standard representative that you can compare with ==.
from sympy import Matrix
def row_equivalent(A, B):
return Matrix(A).rref()[0] == Matrix(B).rref()[0]
print(row_equivalent([[1, 2], [3, 4]], [[0, 1], [5, 0]]))
print(row_equivalent([[1, 2], [2, 4]], [[1, 2], [0, 1]]))
print(row_equivalent([[1, 1, 2], [0, 1, 1]], [[2, 3, 5], [1, 0, 1]]))True
False
True
The first pair are both invertible matrices (). In the second pair, has rank 1 and the other has rank 2.
In software
Canonical forms are a core programming idea: normalizing before comparing. Unicode normalization (NFC), sorted keys in JSON before hashing, canonical SMILES strings for molecules and the RREF of a matrix all answer "are these two things the same?" by reducing both to a unique standard form. In coding theory, the RREF of a generator matrix is the standard form of a linear code (error-correcting codes).
Exercises
Exercise 1: Two echelon forms
Give two different row echelon forms of , and its RREF.
Answer
For example and ; RREF .
Solution
Exercise 2: Row equivalent?
Are and row equivalent?
Answer
Yes. The first matrix reduces to , which is the second matrix.
Solution
Exercise 3: Rank from any echelon form
A matrix has the echelon form . What is its rank, and which columns are pivot columns?
Answer
Rank 3; pivot columns 1, 3 and 4.
Solution
Pivots: 3 (column 1), 5 (column 3), 2 (column 4). By the uniqueness theorem any other echelon form has its pivots in the same columns.
Exercise 4: Column relation (code)
For from the lesson, the RREF's column 4 is . Use that to write column 4 of as a combination of its pivot columns, and check it in code.
Answer
.
Solution
The pivot columns are 1 and 3, and the RREF entries of column 4 are the coefficients (Step 3 of the proof).
from sympy import Matrix
A = Matrix([[1, 2, -1, 3], [2, 4, 0, 2], [-1, -2, 3, -7]])
print(list(1 * A[:, 0] - 2 * A[:, 2]), list(A[:, 3]))[3, 2, -7] [3, 2, -7]
Test yourself
Which of these is unique for a given matrix?
- Its row echelon form
- Its reduced row echelon form
- The sequence of row operations used
- The choice of pivots
Why is the rank of a matrix well defined?
- Because the RREF is unique, so the number of pivots does not depend on the steps
- Because every matrix is square
- Because determinants are unique
- It is not well defined
What do row operations preserve that makes the uniqueness proof work?
- The entries of the first row
- The determinant
- The number of zero entries
- The linear relations among the columns