---
title: The Dimension of a Vector Space and Rank
module: Vector Spaces
moduleNumber: 4
lessonNumber: 5
order: 405
summary: >
  Every basis of a space has the same number of vectors, and that number is the
  dimension. Rank is the dimension of the column space, equal to the dimension of
  the row space and to the number of pivots. The Rank Theorem, rank plus nullity
  equals the number of columns, ties the four fundamental subspaces of a matrix
  together and adds six lines to the Invertible Matrix Theorem.
topics: [Vector Spaces]
draft: false
sources:
  - book: Lay
    ref: "§4.5 The Dimension of a Vector Space; §4.6 Rank"
---

Coordinates showed that an $n$-vector basis makes a space behave like
$\mathbb{R}^n$. The next question is whether that $n$ is a property of the space or
an accident of the basis. It is a property: every basis of a given space has the
same number of vectors. That count is the **dimension**, and applied to the column
space of a matrix it becomes the **rank** — the single number that ties together a
matrix's rows, columns, and null space.[^lay-dim]

## Dimension is well defined

The key fact is a counting bound: a basis of $n$ vectors caps the size of any
independent set.

> **Theorem (Independent sets are bounded by a basis).** If a vector space $V$
> has a basis $\mathcal{B} = \{b_1, \dots, b_n\}$, then any set in $V$ with more
> than $n$ vectors is linearly dependent.

The proof runs through coordinates. If $\{u_1, \dots, u_p\}$ has $p > n$ vectors,
their coordinate vectors $[u_1]_{\mathcal{B}}, \dots, [u_p]_{\mathcal{B}}$ are $p$
vectors in $\mathbb{R}^n$, more vectors than entries, so they are dependent. The
coordinate mapping is an isomorphism, so a dependence relation among the coordinate
vectors is a dependence relation among the $u_i$ themselves. From this, equal size
of all bases follows at once.

> **Theorem (All bases have the same size).** If a vector space $V$ has a basis
> of $n$ vectors, then every basis of $V$ consists of exactly $n$ vectors.

Given two bases $\mathcal{B}_1$ of $n$ vectors and $\mathcal{B}_2$, independence of
$\mathcal{B}_2$ against the basis $\mathcal{B}_1$ forces $|\mathcal{B}_2| \le n$,
and the symmetric argument forces $|\mathcal{B}_2| \ge n$. So $|\mathcal{B}_2| =
n$, and the count is unambiguous.

> **Definition (Dimension).** If $V$ is spanned by a finite set, $V$ is
> finite-dimensional and its dimension $\dim V$ is the number of vectors in any
> basis. The dimension of $\{0\}$ is $0$. If $V$ is not spanned by any finite set,
> $V$ is infinite-dimensional.

A few dimensions to anchor the definition:

- $\dim \mathbb{R}^n = n$, from the standard basis $\{e_1, \dots, e_n\}$.
- $\dim \mathbb{P}_n = n + 1$, from $\{1, t, \dots, t^n\}$.
- $\mathbb{P}$, the space of all polynomials, is infinite-dimensional, and so is
  the space $C(\mathbb{R})$ of continuous functions.

### Subspaces of $\mathbb{R}^3$ by dimension

Dimension classifies the subspaces of $\mathbb{R}^3$ completely. The value of
$\dim$ names the geometric type.

$$
% caption: The subspaces of $\mathbb{R}^3$ sorted by dimension: the origin,
% lines, planes, and all of $\mathbb{R}^3$; each contains those of lower dimension.
\begin{tikzpicture}[>=stealth, font=\footnotesize]
\definecolor{acc}{HTML}{2F6DB5}
% 0-dim
\fill[black] (0,0) circle (2pt);
\node[font=\scriptsize, anchor=north] at (0,-0.5) {$\dim 0$: origin};
% 1-dim line
\begin{scope}[xshift=3cm]
  \draw[thick] (-1,-0.8) -- (1,0.8);
  \fill[black] (0,0) circle (1.4pt);
  \node[font=\scriptsize, anchor=north] at (0,-0.9) {$\dim 1$: line};
\end{scope}
% 2-dim plane
\begin{scope}[xshift=6.2cm]
  \draw[thick] (-1,-0.7) -- (1,-0.4) -- (1,0.9) -- (-1,0.6) -- cycle;
  \fill[black] (0,0) circle (1.4pt);
  \node[font=\scriptsize, anchor=north] at (0,-0.9) {$\dim 2$: plane};
\end{scope}
% 3-dim R3
\begin{scope}[xshift=9.4cm]
  \draw[thick] (-0.8,-0.6) -- (0.8,-0.6) -- (0.8,0.8) -- (-0.8,0.8) -- cycle;
  \draw[thick] (0.8,-0.6) -- (1.3,-0.1) -- (1.3,1.3) -- (0.8,0.8);
  \draw[thick] (-0.8,0.8) -- (-0.3,1.3) -- (1.3,1.3);
  \node[font=\scriptsize, anchor=north] at (0.3,-0.9) {$\dim 3$: $\mathbb{R}^3$};
\end{scope}
\end{tikzpicture}
$$

## Building and recognizing bases

Two theorems make dimension a practical tool: independent sets can always be grown
to a basis, and once the dimension is known, either half of the basis definition
suffices.

> **Theorem (Extension and the subspace bound).** Let $H$ be a subspace of a
> finite-dimensional space $V$. Any linearly independent set in $H$ can be
> expanded, if necessary, to a basis for $H$, and
> $$
> \dim H \le \dim V.
> $$

Adding vectors outside the current span keeps a set independent (by the predecessor
test), and the theorem bounding independent sets by a basis caps how far the process can run, so it terminates at a basis.

> **Theorem (Basis theorem).** Let $V$ be $p$-dimensional with $p \ge 1$. Any
> linearly independent set of exactly $p$ vectors in $V$ is a basis. Any set of
> exactly $p$ vectors that spans $V$ is a basis.

With the right number of vectors, spanning and independence each imply the other.
This shortcut is decisive in applied settings — solutions of a differential or
[difference equation](/linear-algebra/vector-spaces/difference-equations-and-markov)
— where independence is easy to verify but spanning is not.

### Dimensions of the null and column spaces

The basis-finding procedures for a matrix immediately give the two dimensions.

> **Dimensions from a row reduction.** The dimension of $\operatorname{Nul} A$ is
> the number of free variables in $Ax = 0$; the dimension of $\operatorname{Col}
> A$ is the number of pivot columns of $A$.

The null-space method produces one independent vector per free variable, and the
pivot columns are a basis for the column space. So both dimensions are read off a
single echelon form.

> **Worked example.** Find $\dim \operatorname{Nul} A$ and $\dim \operatorname{Col} A$
> for
> $$
> A = \begin{bmatrix} -3 & 6 & -1 & 1 & -7 \\ 1 & -2 & 2 & 3 & -1 \\ 2 & -4 & 5 & 8 & -4 \end{bmatrix}.
> $$
>
> Row reduction — carried out for this matrix under
> [null and column spaces](/linear-algebra/vector-spaces/null-and-column-spaces) —
> gives an echelon form with pivots in columns $1$ and $3$ and free variables
> $x_2, x_4, x_5$. So $\dim \operatorname{Col} A = 2$, one per pivot column, and
> $\dim \operatorname{Nul} A = 3$, one per free variable. Both dimensions come from a
> single echelon form.

$$
% caption: The reduced echelon form of the $3\times 5$ matrix has pivots in two
% columns and three free columns, so $\dim\operatorname{Col}A = 2$ and
% $\dim\operatorname{Nul}A = 3$, together accounting for all $5$ columns.
\begin{tikzpicture}[font=\footnotesize]
\definecolor{acc}{HTML}{2F6DB5}
\fill[acc!14] (0,0) rectangle (1,1.8);
\fill[acc!14] (2,0) rectangle (3,1.8);
\draw[black] (0,0) rectangle (5,1.8);
\foreach \c in {1,2,3,4} { \draw[black] (\c,0) -- (\c,1.8); }
\foreach \r in {1,2} { \draw[black] (0,\r*0.6) -- (5,\r*0.6); }
\node[acc, font=\scriptsize] at (0.5,-0.35) {piv};
\node[black, font=\scriptsize] at (1.5,-0.35) {free};
\node[acc, font=\scriptsize] at (2.5,-0.35) {piv};
\node[black, font=\scriptsize] at (3.5,-0.35) {free};
\node[black, font=\scriptsize] at (4.5,-0.35) {free};
\node[acc, anchor=west, font=\scriptsize] at (5.3,1.25) {$\dim\operatorname{Col}A = 2$};
\node[black, anchor=west, font=\scriptsize] at (5.3,0.5) {$\dim\operatorname{Nul}A = 3$};
\end{tikzpicture}
$$

## Rank and the row space

The rows of $A$ span a subspace in their own right. If $A$ is $m \times n$, each
row has $n$ entries, so the **row space** $\operatorname{Row} A$ is a subspace of
$\mathbb{R}^n$, equal to $\operatorname{Col} A^\top$.

> **Theorem (Row space under row reduction).** If $A$ and $B$ are row
> equivalent, they have the same row space. If $B$ is in echelon form, its nonzero
> rows form a basis for the row space of both $A$ and $B$.

Row operations replace rows by linear combinations of rows, which cannot enlarge or
shrink their span, and they are reversible. The nonzero rows of an echelon form are
independent because no such row is a combination of those below it. Unlike the
column-space basis, this basis uses rows of the _echelon form_, which are valid
representatives since the row space is preserved.

> **Definition (Rank).** The rank of $A$ is the dimension of its column space,
> $\operatorname{rank} A = \dim \operatorname{Col} A$.

Because $\operatorname{Row} A = \operatorname{Col} A^\top$, the dimension of the row
space is $\operatorname{rank} A^\top$. The central theorem says these two ranks
coincide.

> **Theorem (Rank theorem).** For an $m \times n$ matrix $A$, the column space
> and row space have equal dimension. This common value, the rank, also equals the
> number of pivot positions, and
> $$
> \operatorname{rank} A + \dim \operatorname{Nul} A = n.
> $$

Every pivot contributes one pivot column (a column-space basis vector) and one
nonzero echelon row (a row-space basis vector), so $\dim \operatorname{Col} A =
\dim \operatorname{Row} A = (\text{number of pivots})$. The columns split into pivot
and nonpivot, and the nonpivot columns correspond to the free variables counted by
$\dim \operatorname{Nul} A$:

$$
\underbrace{(\text{pivot columns})}_{\operatorname{rank} A}
+ \underbrace{(\text{nonpivot columns})}_{\dim \operatorname{Nul} A}
= \underbrace{n}_{\text{total columns}}.
$$

$$
% caption: The Rank Theorem as a partition: the $n$ columns split into
% rank-many pivot columns and nullity-many free columns, so rank plus nullity is
% exactly $n$.
\begin{tikzpicture}[font=\footnotesize]
\definecolor{acc}{HTML}{2F6DB5}
\draw[acc, thick, fill=acc!14] (0,0) rectangle (5.2,0.9);
\node[acc] at (2.6,0.45) {$\operatorname{rank} A$ (pivot columns)};
\draw[black, thick, fill=black!8] (5.2,0) rectangle (8.6,0.9);
\node[black] at (6.9,0.45) {$\dim\operatorname{Nul}A$ (free)};
\draw[<->, black] (0,-0.4) -- (8.6,-0.4);
\node[anchor=north] at (4.3,-0.45) {$n$ columns};
\end{tikzpicture}
$$

The theorem is a fast reasoning tool.

> **Worked example.** (a) A $7 \times 9$ matrix has a two-dimensional null space.
> What is its rank? (b) Could a $6 \times 9$ matrix have a two-dimensional null
> space?
>
> (a) With $9$ columns, $\operatorname{rank} A + \dim \operatorname{Nul} A = 9$, so
> $$
> \operatorname{rank} A = 9 - 2 = 7.
> $$
> (b) No. A two-dimensional null space would force $\operatorname{rank} A = 9 - 2 = 7$.
> But the columns of a $6 \times 9$ matrix lie in $\mathbb{R}^6$, so
> $\dim \operatorname{Col} A \le 6$; the rank cannot exceed $6$.

The same counting settles questions phrased without any linear-algebra vocabulary.

> **Worked example.** A scientist finds two solutions of a homogeneous system of
> $40$ equations in $42$ variables. The two are not multiples of each other, and
> every solution is a combination of them. Must the associated nonhomogeneous system
> $Ax = b$, with the same coefficients, have a solution?
>
> Yes. Let $A$ be the $40 \times 42$ coefficient matrix. The two independent
> solutions span $\operatorname{Nul} A$, so $\dim \operatorname{Nul} A = 2$. By the
> rank theorem,
> $$
> \dim \operatorname{Col} A = 42 - 2 = 40.
> $$
> The only $40$-dimensional subspace of $\mathbb{R}^{40}$ is $\mathbb{R}^{40}$
> itself, so $\operatorname{Col} A = \mathbb{R}^{40}$. Every equation $Ax = b$ is
> then consistent.

## The four fundamental subspaces

A matrix $A$ and its transpose together carry four subspaces. Two live in the
domain $\mathbb{R}^n$ and two in the codomain $\mathbb{R}^m$, and their dimensions
are fixed by the rank $r$.

| Subspace | Ambient space | Dimension |
| --- | --- | --- |
| $\operatorname{Col} A$ | $\mathbb{R}^m$ | $r$ |
| $\operatorname{Nul} A^\top$ | $\mathbb{R}^m$ | $m - r$ |
| $\operatorname{Row} A = \operatorname{Col} A^\top$ | $\mathbb{R}^n$ | $r$ |
| $\operatorname{Nul} A$ | $\mathbb{R}^n$ | $n - r$ |

$$
% caption: The four fundamental subspaces. In the domain, $\operatorname{Row} A$
% and $\operatorname{Nul} A$ have dimensions $r$ and $n-r$; in the codomain,
% $\operatorname{Col} A$ and $\operatorname{Nul} A^\top$ have dimensions $r$ and
% $m-r$.
\begin{tikzpicture}[>=stealth, font=\footnotesize]
\definecolor{acc}{HTML}{2F6DB5}
% domain box
\draw[black] (-0.4,-2.6) rectangle (3.4,2.6);
\node[anchor=south, font=\small] at (1.5,2.6) {$\mathbb{R}^n$ (domain)};
\fill[acc!12] (0.2,0.5) -- (2.8,0.95) -- (2.8,2.15) -- (0.2,1.7) -- cycle;
\node[acc, font=\scriptsize, align=center] at (1.5,1.3) {$\operatorname{Row}A$\\dim $r$};
\draw[black] (0.2,-2.15) -- (2.8,-1.7) -- (2.8,-0.5) -- (0.2,-0.95) -- cycle;
\node[black, font=\scriptsize, align=center] at (1.5,-1.3) {$\operatorname{Nul}A$\\dim $n$-$r$};
% codomain box
\begin{scope}[xshift=7cm]
  \draw[black] (-0.4,-2.6) rectangle (3.4,2.6);
  \node[anchor=south, font=\small] at (1.5,2.6) {$\mathbb{R}^m$ (codomain)};
  \fill[acc!12] (0.2,0.5) -- (2.8,0.95) -- (2.8,2.15) -- (0.2,1.7) -- cycle;
  \node[acc, font=\scriptsize, align=center] at (1.5,1.3) {$\operatorname{Col}A$\\dim $r$};
  \draw[black] (0.2,-2.15) -- (2.8,-1.7) -- (2.8,-0.5) -- (0.2,-0.95) -- cycle;
  \node[black, font=\scriptsize, align=center] at (1.5,-1.3) {$\operatorname{Nul}A^{T}$\\dim $m$-$r$};
\end{scope}
\draw[->, very thick] (3.6,0) -- (6.6,0) node[midway, above] {$x$ to $Ax$};
\end{tikzpicture}
$$

Within each ambient space the two subspaces are more than a partition of dimension:
$\operatorname{Row} A$ and $\operatorname{Nul} A$ meet only at $0$ and are in fact
orthogonal, as are $\operatorname{Col} A$ and $\operatorname{Nul} A^\top$. That
orthogonality is the subject of
[inner products and orthogonality](/linear-algebra/orthogonality-least-squares/inner-product-length-orthogonality);
here it is enough that the dimensions add to $n$ and to $m$ respectively.

## Rank in the Invertible Matrix Theorem

For a square $n \times n$ matrix, full rank is equivalent to invertibility. The
following statements join the Invertible Matrix Theorem, each equivalent to $A$
being invertible.

- **(m)** The columns of $A$ form a basis of $\mathbb{R}^n$.
- **(n)** $\operatorname{Col} A = \mathbb{R}^n$.
- **(o)** $\dim \operatorname{Col} A = n$.
- **(p)** $\operatorname{rank} A = n$.
- **(q)** $\operatorname{Nul} A = \{0\}$.
- **(r)** $\dim \operatorname{Nul} A = 0$.

These follow from the rank theorem and the earlier
[invertibility conditions](/linear-algebra/matrix-algebra/matrix-inverse-and-invertibility)
by a short chain: full column span gives $\dim \operatorname{Col} A = n$, hence
rank $n$, hence $\dim \operatorname{Nul} A = 0$ by $\operatorname{rank} A + \dim
\operatorname{Nul} A = n$, hence only the trivial solution to $Ax = 0$.

> **Numerical note.** Counting pivots is exact only in exact arithmetic. On a
> computer a nearly-dependent set of columns can appear to have full rank or not,
> depending on rounding. Practical rank determination uses the
> [singular value decomposition](/linear-algebra/symmetric-quadratic-svd/singular-value-decomposition),
> which also yields reliable bases for all four fundamental subspaces.

[^lay-dim]: **Lay**, _Linear Algebra and Its Applications_, §4.5 — The Dimension of a Vector Space (Theorems 9–12, dimensions of $\operatorname{Nul} A$ and $\operatorname{Col} A$) and §4.6 — Rank (row space, Theorem 13, the Rank Theorem, the four fundamental subspaces, and the Invertible Matrix Theorem statements (m)–(r)).
