Rank of a Matrix
The rank of a matrix A is the dimension of its column space, which equals the number of pivot columns in an echelon form of A. The rank-nullity theorem says that for an m × n matrix, rank A + dim Nul A = n: the pivot columns and the free-variable columns together make up all n columns.
Before this lesson: Basis and Dimension, Null Space and Column Space and Gaussian Elimination
What rank means
A matrix can have many columns but only a few truly different directions among them. The rank counts those directions. It is the dimension of Col A, the space of all outputs Ax, so it tells you how much of ℝᵐ the matrix can actually reach.
Row reduction sorts the n columns into two kinds. A pivot column adds a new direction to the column space. A non-pivot column matches a free variable, and each free variable adds one dimension to the null space. Every column is one kind or the other, which is why rank and nullity always add up to n.
Rank, nullity and the rank-nullity theorem
For an m × n matrix A:
- The rank of A is rank A = dim Col A, the number of pivot columns.
- The nullity of A is dim Nul A, the number of free variables.
- The row space Row A is the span of the rows of A. It has the same dimension as Col A, so rank A = dim Row A, and rank Aᵀ = rank A.
Rank-nullity theorem:
\operatorname{rank} A + \dim \operatorname{Nul} A = nTwo limits follow. The rank is at most the number of rows and at most the number of columns, so rank A ≤ min(m, n). And Ax = b can be solved for every b in ℝᵐ exactly when rank A = m.
For a square n × n matrix, the invertible matrix theorem adds more: A is invertible exactly when rank A = n, which is the same as nullity 0.
How to find the rank of a matrix
- Row reduce A to an echelon form. Reduced form is not required.
- Count the pivots. That count is rank A.
- Subtract from the number of columns to get the nullity: dim Nul A = n − rank A.
- For bases: the nonzero rows of the echelon form are a basis for Row A, the pivot columns of the original A are a basis for Col A, and the parametric vector form of the solution of Ax = 0 gives a basis for Nul A.
Row operations never change the row space, so echelon rows are safe for Row A. They do change the column space, so Col A must use the original columns.
Rank of a matrix examples
Example 1: Rank and nullity
Find the rank and nullity of A = \begin{bmatrix} 1 & 2 & -1 & 3 \\ 2 & 4 & 1 & 0 \\ 3 & 6 & 0 & 3 \end{bmatrix}.
\begin{bmatrix} 1 & 2 & -1 & 3 \\ 2 & 4 & 1 & 0 \\ 3 & 6 & 0 & 3 \end{bmatrix}Start with A.
\sim \begin{bmatrix} 1 & 2 & -1 & 3 \\ 0 & 0 & 3 & -6 \\ 3 & 6 & 0 & 3 \end{bmatrix}R₂ − 2R₁ → R₂.
\sim \begin{bmatrix} 1 & 2 & -1 & 3 \\ 0 & 0 & 3 & -6 \\ 0 & 0 & 3 & -6 \end{bmatrix}R₃ − 3R₁ → R₃.
\sim \begin{bmatrix} 1 & 2 & -1 & 3 \\ 0 & 0 & 3 & -6 \\ 0 & 0 & 0 & 0 \end{bmatrix}R₃ − R₂ → R₃. Echelon form with pivots in columns 1 and 3.
\operatorname{rank} A = 2Count the pivots.
\dim \operatorname{Nul} A = 4 - 2 = 2Rank-nullity: subtract from n = 4 columns.
Answer: rank A = 2 and the nullity is 2. Check: columns 2 and 4 hold the free variables x₂ and x₄, which is 2 free variables.
Example 2: Bases for all three spaces
For the same A, find a basis for Row A, Col A and Nul A.
(1, 2, -1, 3),\quad (0, 0, 3, -6)
Row A: take the nonzero rows of the echelon form from Example 1.
\begin{bmatrix} 1 \\ 2 \\ 3 \end{bmatrix},\quad \begin{bmatrix} -1 \\ 1 \\ 0 \end{bmatrix}Col A: take columns 1 and 3 of the original A.
\begin{bmatrix} 1 & 2 & -1 & 3 \\ 0 & 0 & 1 & -2 \\ 0 & 0 & 0 & 0 \end{bmatrix}For Nul A, continue to reduced form: ⅓R₂ → R₂.
\begin{bmatrix} 1 & 2 & 0 & 1 \\ 0 & 0 & 1 & -2 \\ 0 & 0 & 0 & 0 \end{bmatrix}R₁ + R₂ → R₁ (see reduced row echelon form).
x_1 = -2x_2 - x_4,\quad x_3 = 2x_4
Solve rows 1 and 2; x₂ and x₄ are free.
x = x_2\begin{bmatrix} -2 \\ 1 \\ 0 \\ 0 \end{bmatrix} + x_4\begin{bmatrix} -1 \\ 0 \\ 2 \\ 1 \end{bmatrix}Write the solution in parametric vector form.
Answer: Row A has basis {(1, 2, −1, 3), (0, 0, 3, −6)}; Col A has basis {(1, 2, 3), (−1, 1, 0)}; Nul A has basis {(−2, 1, 0, 0), (−1, 0, 2, 1)}. Row A and Col A both have dimension 2 = rank A, and 2 + 2 = 4 columns.
Example 3: Using the theorem without row reducing
A is a 7 × 10 matrix, and its null space has dimension 4. Find rank A. Can Ax = b be solved for every b in ℝ⁷? Can it have exactly one solution?
\operatorname{rank} A + 4 = 10Rank-nullity with n = 10 columns.
\operatorname{rank} A = 10 - 4 = 6Subtract 4 from both sides.
6 \lt 7
Compare the rank with the number of rows, m = 7.
Col A is a 6-dimensional subspace of ℝ⁷, so it is not all of ℝ⁷.
Answer: rank A = 6. Some b in ℝ⁷ make Ax = b inconsistent. When a solution exists, the 4 free variables make infinitely many, so Ax = b never has exactly one solution.
Example 4: A rank that depends on a parameter
For which values of k does A = \begin{bmatrix} 1 & 2 & 1 \\ 2 & 5 & k \\ 1 & 3 & 2 \end{bmatrix} have rank 3, and what is the rank otherwise?
\sim \begin{bmatrix} 1 & 2 & 1 \\ 0 & 1 & k - 2 \\ 1 & 3 & 2 \end{bmatrix}R₂ − 2R₁ → R₂.
\sim \begin{bmatrix} 1 & 2 & 1 \\ 0 & 1 & k - 2 \\ 0 & 1 & 1 \end{bmatrix}R₃ − R₁ → R₃.
\sim \begin{bmatrix} 1 & 2 & 1 \\ 0 & 1 & k - 2 \\ 0 & 0 & 1 - (k - 2) \end{bmatrix}R₃ − R₂ → R₃.
1 - (k - 2) = 3 - k
Simplify the last entry.
3 - k = 0 \Rightarrow k = 3
The third pivot disappears only when this entry is 0.
Answer: rank A = 3 for every k ≠ 3. When k = 3, the last row is all zeros and rank A = 2 (nullity 1). As a check, det A = 3 − k, which is 0 exactly when k = 3 (see determinant of a matrix).
Example 5: A rank-1 sales table
A chain records sales (in units) for three stores over four months. Rows are stores and columns are months: S = \begin{bmatrix} 20 & 30 & 40 & 10 \\ 40 & 60 & 80 & 20 \\ 10 & 15 & 20 & 5 \end{bmatrix}. Find rank S and explain what it says about the data.
\sim \begin{bmatrix} 20 & 30 & 40 & 10 \\ 0 & 0 & 0 & 0 \\ 10 & 15 & 20 & 5 \end{bmatrix}R₂ − 2R₁ → R₂.
\sim \begin{bmatrix} 20 & 30 & 40 & 10 \\ 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 \end{bmatrix}R₃ − ½R₁ → R₃.
\operatorname{rank} S = 1One pivot.
\begin{bmatrix} 10 \\ 20 \\ 5 \end{bmatrix}\begin{bmatrix} 2 & 3 & 4 & 1 \end{bmatrix} = \begin{bmatrix} 20 & 30 & 40 & 10 \\ 40 & 60 & 80 & 20 \\ 10 & 15 & 20 & 5 \end{bmatrix}Rank 1 means S is one column times one row (see matrix multiplication).
Answer: rank S = 1 and the nullity is 4 − 1 = 3. Every store follows the same seasonal pattern (2, 3, 4, 1), scaled by a store size (10, 20, 5). The 12 numbers can be stored as just 3 + 4 = 7, which is the idea behind data compression with low-rank matrices.
Common mistakes
| Mistake | Example of the error | Fix |
|---|---|---|
| Counting nonzero rows before row reducing | Saying [1 2; 2 4] has rank 2 because neither row is zero | Row reduce first: R₂ − 2R₁ gives a zero row, so the rank is 1. |
| Subtracting the rank from the number of rows | For a 3 × 5 matrix of rank 2, saying the nullity is 3 − 2 = 1 | Nullity = n − rank, with n the number of columns: 5 − 2 = 3. |
| Using echelon columns for Col A | Giving the columns of the echelon form as a basis for Col A | Echelon rows are fine for Row A, but Col A needs the pivot columns of the original matrix. |
| Allowing a rank that is too big | Saying a 3 × 5 matrix has rank 4 | rank A ≤ min(m, n), so a 3 × 5 matrix has rank at most 3. |
| Confusing rank 0 with a singular matrix | Saying a singular 3 × 3 matrix has rank 0 | Only the zero matrix has rank 0. A singular 3 × 3 matrix has rank 1 or 2. |
Related ideas
Linear transformations. For T(x) = Ax from ℝⁿ to ℝᵐ, the theorem reads dim(range of T) + dim(kernel of T) = n. So T is onto when rank A = m and one-to-one when rank A = n.
Rank-1 matrices. Every rank-1 matrix is a column times a row, as in Example 5. Later in the course, the singular value decomposition writes any matrix as a sum of rank-1 pieces.
Coordinates. The next lesson, Change of Basis, uses bases to give vectors new coordinates and converts between them.
Practice problems
- Find the rank of \begin{bmatrix} 1 & 2 \\ 3 & 6 \end{bmatrix}.
- Find the rank of \begin{bmatrix} 2 & 1 \\ 1 & 3 \end{bmatrix}.
- Find the rank and nullity of \begin{bmatrix} 1 & 0 & 2 & -1 \\ 0 & 1 & -3 & 4 \end{bmatrix}.
- A is 5 × 8 with rank 5. Find the nullity. Is Col A = ℝ⁵?
- Can a 4 × 6 matrix have a null space of dimension 1? Explain.
- Find the rank and nullity of \begin{bmatrix} 1 & -1 & 2 \\ 2 & -2 & 4 \\ -1 & 1 & -2 \end{bmatrix}.
- Find all k for which \begin{bmatrix} 1 & k \\ k & 4 \end{bmatrix} has rank 1.
- Find a basis for the row space of \begin{bmatrix} 1 & 2 & 3 \\ 2 & 4 & 7 \end{bmatrix}, its rank and its nullity.
- T is a linear transformation from ℝ⁵ onto ℝ³. Find the dimension of the kernel of T.
- A is 3 × 3 and Nul A = Span{(1, 1, 1)}. Find rank A. Is A invertible?
Show answers
1.
\begin{bmatrix} 1 & 2 \\ 3 & 6 \end{bmatrix} \sim \begin{bmatrix} 1 & 2 \\ 0 & 0 \end{bmatrix}R₂ − 3R₁ → R₂.
Answer: one pivot, so the rank is 1.
2.
\begin{bmatrix} 2 & 1 \\ 1 & 3 \end{bmatrix} \sim \begin{bmatrix} 2 & 1 \\ 0 & \tfrac{5}{2} \end{bmatrix}R₂ − ½R₁ → R₂. The new entry is 3 − ½ = 5/2.
Answer: two pivots, so the rank is 2 (the matrix is invertible).
3.
\operatorname{rank} = 2The matrix is already in reduced row echelon form with pivots in columns 1 and 2.
\dim \operatorname{Nul} = 4 - 2 = 2Rank-nullity with n = 4.
Answer: rank 2, nullity 2.
4.
\dim \operatorname{Nul} A = 8 - 5 = 3Rank-nullity with n = 8.
Answer: the nullity is 3. Yes: rank A = 5 = m, so Col A is a 5-dimensional subspace of ℝ⁵, which is all of ℝ⁵.
5.
\operatorname{rank} A \le 4The rank is at most the number of rows.
\dim \operatorname{Nul} A = 6 - \operatorname{rank} A \ge 6 - 4 = 2Rank-nullity with n = 6.
Answer: no. The null space of a 4 × 6 matrix has dimension at least 2.
6.
\sim \begin{bmatrix} 1 & -1 & 2 \\ 0 & 0 & 0 \\ -1 & 1 & -2 \end{bmatrix}R₂ − 2R₁ → R₂.
\sim \begin{bmatrix} 1 & -1 & 2 \\ 0 & 0 & 0 \\ 0 & 0 & 0 \end{bmatrix}R₃ + R₁ → R₃.
Answer: rank 1 and nullity 3 − 1 = 2.
7.
\begin{bmatrix} 1 & k \\ k & 4 \end{bmatrix} \sim \begin{bmatrix} 1 & k \\ 0 & 4 - k^2 \end{bmatrix}R₂ − kR₁ → R₂.
4 - k^2 = 0
Rank 1 needs the second pivot to vanish. The first row is never zero, so the rank is never 0.
k^2 = 4
Add k² to both sides.
k = \pm 2
Take square roots.
Answer: k = 2 or k = −2.
8.
\begin{bmatrix} 1 & 2 & 3 \\ 2 & 4 & 7 \end{bmatrix} \sim \begin{bmatrix} 1 & 2 & 3 \\ 0 & 0 & 1 \end{bmatrix}R₂ − 2R₁ → R₂.
Answer: Row A has basis {(1, 2, 3), (0, 0, 1)}, the rank is 2, and the nullity is 3 − 2 = 1.
9.
\dim(\text{range}) = 3T is onto ℝ³, so its range is all of ℝ³.
\dim(\text{kernel}) = 5 - 3 = 2Rank-nullity with n = 5.
Answer: the kernel of T has dimension 2.
10.
\dim \operatorname{Nul} A = 1Nul A is spanned by one nonzero vector.
\operatorname{rank} A = 3 - 1 = 2Rank-nullity with n = 3.
Answer: rank A = 2. A is not invertible, because an invertible 3 × 3 matrix has rank 3 and nullity 0.
Rank of a matrix FAQ
What is the rank of a matrix?
The rank is the dimension of the column space. You find it by row reducing to an echelon form and counting the pivots.
What is the rank-nullity theorem?
For an m × n matrix, rank A + dim Nul A = n. Each column is either a pivot column or a free-variable column, so the two counts add up to the number of columns.
Is the row rank equal to the column rank?
Yes. The number of independent rows always equals the number of independent columns, because both equal the number of pivots. So rank Aᵀ = rank A.
Can the rank be larger than the number of rows?
No. Each pivot sits in its own row and its own column, so the rank is at most the smaller of m and n.
Summary
- rank A = dim Col A = dim Row A = the number of pivots in an echelon form.
- The nullity is dim Nul A, the number of free variables.
- Rank-nullity theorem: rank A + dim Nul A = n, the number of columns.
- rank A ≤ min(m, n); Ax = b is solvable for every b exactly when rank A = m.
- Echelon rows give a basis for Row A, but Col A needs the pivot columns of the original matrix.
Previous lesson: Basis and Dimension
Next lesson: Change of Basis
Back to the Linear Algebra Index