Matrix Rank, Nullity and the Rank-Nullity Theorem
The rank of a matrix is the number of pivots in its echelon form, equal to the dimension of its column space and of its row space; the nullity is the dimension of its null space, and the rank–nullity theorem states that for an m × n matrix A, rank A + nullity A = n. In brief: the matrix [[1, 2, 3], [4, 5, 6], [7, 8, 9]] has rank 2, because its third row is twice the second minus the first, and so its null space has dimension 3 − 2 = 1, spanned by (1, −2, 1).
Rank measures how many independent directions a matrix or a linear map really has. This guide defines rank in several equivalent ways, computes it by row reduction and by minors, states the rank–nullity theorem with a proof sketch, and lists the main inequalities, with worked examples and a table.
What is the rank of a matrix?
The following numbers are equal for every matrix A, and their common value is the rank, rank A:
- the number of pivots in a row echelon form of A;
- the maximal number of linearly independent columns (the dimension of the column space);
- the maximal number of linearly independent rows (the dimension of the row space);
- the order of the largest square submatrix with a nonzero determinant.
Consequently rank A = rank AT and rank A ≤ min(m, n). A matrix with rank equal to min(m, n) has full rank. The nullity is dim Null(A), the number of free variables when solving Ax = 0.
How do you compute the rank?
Row reduce and count the nonzero rows of the echelon form. Row operations do not change the rank.
Example 1: a singular 3 × 3 matrix
A = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]. R2 − 4R1 = (0, −3, −6), R3 − 7R1 = (0, −6, −12), R3 − 2R2 = (0, 0, 0). Two nonzero rows, so the rank is 2 and det A = 0. The nullity is 3 − 2 = 1: from x2 + 2x3 = 0 and x1 + 2x2 + 3x3 = 0, we get the null vector (1, −2, 1). Check: 1 − 4 + 3 = 0, 4 − 10 + 6 = 0, 7 − 16 + 9 = 0 ✓.
Example 2: a rectangular matrix
[[1, 2, 3], [4, 5, 6]] has the minor 1 · 5 − 2 · 4 = −3 ≠ 0, so the rank is 2 (full rank). The nullity is 3 − 2 = 1.
Example 3: rank by minors
[[1, 2, 3], [2, 4, 6]] has all 2 × 2 minors equal to 0 (for instance 1 · 4 − 2 · 2 = 0), but a nonzero entry, so the rank is 1.
What is the rank–nullity theorem?
For an m × n matrix A (equivalently, a linear map from an n-dimensional space), rank A + nullity A = n: the number of columns splits into the pivot columns (rank) and the free columns (nullity). A proof sketch: take a basis of the null space and extend it to a basis of the whole domain. The images of the added basis vectors are linearly independent and span the column space, so their count is the rank.
Example 4: applying the theorem
A 5 × 8 matrix has rank at most 5, so the nullity is at least 3: the homogeneous system of 5 equations in 8 unknowns always has a solution space of dimension at least 3. The 3 × 4 matrix of the article on fundamental subspaces has n = 4 and rank 2, so its null space has dimension 2.
Example 5: dimension of a solution space
The system x + y + z + w = 0, x − y + z − w = 0 has the coefficient rank 2 and 4 unknowns, so the solutions form a 2-dimensional subspace of ℝ4, spanned for instance by (−1, 0, 1, 0) and (0, −1, 0, 1).
What inequalities does rank satisfy?
- rank(A + B) ≤ rank A + rank B.
- rank(AB) ≤ min(rank A, rank B).
- Sylvester’s inequality: rank A + rank B − n ≤ rank(AB) for an m × n matrix A and an n × p matrix B.
- Multiplying by an invertible matrix on either side does not change the rank.
- rank(ATA) = rank A for real matrices.
Example 6: the product can drop the rank
A = [[1, 0], [0, 0]] and B = [[0, 0], [0, 1]] both have rank 1, but AB = O has rank 0. Sylvester’s bound: 1 + 1 − 2 = 0 ≤ 0 ✓.
Example 7: rank of a sum
I and −I have rank 2 each, but I + (−I) = O has rank 0 ≤ 4. And the identity and a rank-1 matrix [[1, 1], [1, 1]] have the sum [[2, 1], [1, 2]] of rank 2 ≤ 2 + 1.
How does rank depend on a parameter?
The rank changes only at special values of the parameter, which are found by setting the relevant minors to zero.
Example 8: a parametric matrix
M(k) = [[1, 1, 1], [1, k, 1], [1, 1, k]]. det M(k) = 1(k2 − 1) − 1(k − 1) + 1(1 − k) = (k − 1)2. So for k ≠ 1 the rank is 3. For k = 1, all rows equal (1, 1, 1), and the rank is 1. (For this matrix, the rank never equals 2.)
Example 9: the rank of a system’s matrices
The consistency of Ax = b is decided by comparing rank A and rank [A | b].
Table of examples
| Matrix | Size | Rank | Nullity | Comment |
|---|---|---|---|---|
| [[1, 2, 3], [4, 5, 6], [7, 8, 9]] | 3 × 3 | 2 | 1 | singular |
| [[1, 2, 3], [4, 5, 6]] | 2 × 3 | 2 | 1 | full row rank |
| [[1, 2, 3], [2, 4, 6]] | 2 × 3 | 1 | 2 | proportional rows |
| I3 | 3 × 3 | 3 | 0 | invertible |
| zero matrix | 2 × 4 | 0 | 4 | only the rank 0 matrix |
| M(k), k ≠ 1 | 3 × 3 | 3 | 0 | Example 8 |
Where does the concept come from?
The idea of the rank of a matrix was developed in the second half of the nineteenth century: Sylvester used the notion of the order of the largest nonvanishing minor, and Georg Frobenius gave the systematic treatment of rank in 1879 in the study of linear forms. The rank–nullity theorem is part of the modern abstract theory of linear maps.
Which mistakes are common?
Counting zero rows of the original matrix
The rank is read from an echelon form, not from the original matrix. A matrix with no zero rows can still have a low rank (Example 1).
Confusing rank with the number of nonzero entries
The rank depends on independence, not on the number of entries. The matrix of ones [[1, 1], [1, 1]] has rank 1.
Forgetting n in the rank–nullity theorem
The sum is the number of columns n, not the number of rows m.
Assuming rank(AB) = rank A · rank B
The rank of a product is at most the smaller of the two ranks, and can be smaller still (Example 6).