---
title: Subspaces of Rⁿ, Dimension, and Rank
module: Matrix Algebra
moduleNumber: 2
lessonNumber: 4
order: 204
summary: >
  A subspace is a set closed under addition and scalar multiplication. Every
  matrix carries two: the column space of all attainable outputs Ax, and the null
  space of all solutions of Ax = 0. A basis measures each with a minimal spanning
  set, dimension counts it, and the Rank Theorem ties pivots and free variables
  together as rank + nullity = n.
topics: [Matrix Algebra]
sources:
  - book: Lay
    ref: "Ch. 2 — Matrix Algebra; §2.8 Subspaces of Rⁿ, §2.9 Dimension and Rank"
---

Sets of vectors closed under the two linear operations, addition and scalar
multiplication, recur throughout the subject: the span of a set of vectors, the
outputs a matrix can produce, the solutions of a homogeneous system. Such a set
is a subspace. Every matrix carries two of them, and basis, dimension, and rank
measure their size. The general
[abstract vector space](/linear-algebra/vector-spaces/vector-spaces-and-subspaces)
generalizes the construction; here everything lives inside $\mathbb{R}^n$.

## Subspaces

> **Definition (Subspace).** A **subspace** of $\mathbb{R}^n$ is a set $H$ in
> $\mathbb{R}^n$ with three properties:
>
> - the zero vector is in $H$;
> - for all $u, v \in H$, the sum $u + v \in H$ (closed under addition);
> - for all $u \in H$ and scalars $c$, the vector $cu \in H$ (closed under
>   scaling).

A subspace is closed under linear combinations. The span of any set of vectors is
the standard example: for $v_1, \dots, v_p$ in $\mathbb{R}^n$, the set
$\operatorname{Span}\{v_1, \dots, v_p\}$ contains $0$, and a sum or scalar multiple
of linear combinations is again a linear combination, so all three properties
hold. Geometrically, $\operatorname{Span}\{v_1\}$ with $v_1 \ne 0$ is a line through
the origin, and $\operatorname{Span}\{v_1, v_2\}$ with $v_1, v_2$ independent is a
plane through the origin.

$$
% caption: Span{v₁, v₂} is a plane through the origin; any sum or scalar multiple
% of vectors in it stays in the plane, so it is a subspace.
\begin{tikzpicture}[>=stealth, font=\footnotesize]
  \definecolor{acc}{HTML}{4A6FA5}
  % plane as a parallelogram
  \fill[acc!10] (-2.6,-1.2) -- (2.6,-1.2) -- (3.4,1.2) -- (-1.8,1.2) -- cycle;
  \draw[black] (-2.6,-1.2) -- (2.6,-1.2) -- (3.4,1.2) -- (-1.8,1.2) -- cycle;
  \node[black, font=\scriptsize] at (2.5,0.85) {$\operatorname{Span}(v_1, v_2)$};
  % origin
  \fill (0,0) circle (1.6pt);
  \node[anchor=north east, font=\scriptsize] at (0,0) {$0$};
  % basis vectors
  \draw[->, acc, very thick] (0,0) -- (1.9,-0.55) node[anchor=north, font=\scriptsize] {$v_1$};
  \draw[->, acc, very thick] (0,0) -- (0.7,0.95) node[anchor=south, font=\scriptsize] {$v_2$};
  % a combination stays inside
  \draw[->, black, thick] (0,0) -- (2.6,0.4);
  \node[black, font=\scriptsize, anchor=west] at (2.6,0.4) {$v_1 + v_2$};
\end{tikzpicture}
$$

A line **not** through the origin is not a subspace: it fails the first property
and is closed under neither operation. The whole space $\mathbb{R}^n$ is a subspace
of itself, and the set $\{0\}$ containing only the zero vector is the **zero
subspace**.

## Column space and null space

Two subspaces attach to every matrix, and they capture the two basic questions
about $Ax = b$: which $b$ are reachable, and which $x$ collapse to zero.

> **Definition (Column space).** The **column space** $\operatorname{Col} A$ of an
> $m \times n$ matrix $A$ is the set of all linear combinations of its columns.
> Equivalently, $\operatorname{Col} A = \{\,Ax : x \in \mathbb{R}^n\,\}$, a
> subspace of $\mathbb{R}^m$.

Because $Ax$ is a combination of the columns, $b$ lies in $\operatorname{Col} A$
exactly when $Ax = b$ is consistent. The column space is
[Span](/linear-algebra/linear-systems/vector-and-matrix-equations) of the columns,
so it is described **explicitly** — its vectors are built directly from the
columns. It equals all of $\mathbb{R}^m$ only when the columns span
$\mathbb{R}^m$.

> **Definition (Null space).** The **null space** $\operatorname{Nul} A$ of an
> $m \times n$ matrix $A$ is the set of all solutions of the homogeneous equation
> $Ax = 0$, a subset of $\mathbb{R}^n$.

> **Theorem (Null space is a subspace).** The null space of an $m \times n$
> matrix $A$ is a subspace of $\mathbb{R}^n$.

The proof checks the three properties: $A0 = 0$, so $0 \in \operatorname{Nul} A$;
if $Au = 0$ and $Av = 0$, then $A(u+v) = 0$ and $A(cu) = 0$. The null space is
described **implicitly** — a vector belongs only if it passes the test $Ax = 0$ —
so producing its members takes work. Solving $Ax = 0$ and writing the answer in
[parametric vector form](/linear-algebra/linear-systems/solution-sets-and-applications)
turns the implicit description into an explicit spanning set.

| | $\operatorname{Col} A$ | $\operatorname{Nul} A$ |
| --- | --- | --- |
| Lives in | $\mathbb{R}^m$ | $\mathbb{R}^n$ |
| Defined by | the columns of $A$ (explicit) | the equation $Ax = 0$ (implicit) |
| Membership of $b$ | $Ax = b$ is consistent | $Ab = 0$ |
| Easy to | list a member | test a member |

$$
% caption: The null space sits in the domain and the column space in the
% codomain; A acts on x to give Ax, and every null-space vector collapses to 0.
\begin{tikzpicture}[>=stealth, font=\footnotesize]
  \definecolor{acc}{HTML}{4A6FA5}
  \draw[black] (0,0) ellipse (1.5 and 2.0);
  \node[black, font=\scriptsize] at (0,2.3) {domain $\mathbb{R}^n$};
  \fill[acc!12] (0,-0.9) ellipse (0.9 and 0.6);
  \draw[acc] (0,-0.9) ellipse (0.9 and 0.6);
  \node[acc, font=\scriptsize] at (0,-0.9) {$\operatorname{Nul} A$};
  \fill (0.1,0.9) circle (1.4pt);
  \node[font=\scriptsize, anchor=south] at (0.1,1.05) {$x$};
  \begin{scope}[xshift=5.4cm]
    \draw[black] (0,0) ellipse (1.5 and 2.0);
    \node[black, font=\scriptsize] at (0,2.3) {codomain $\mathbb{R}^m$};
    \fill[acc!12] (0,0.1) ellipse (0.95 and 0.95);
    \draw[acc] (0,0.1) ellipse (0.95 and 0.95);
    \node[acc, font=\scriptsize] at (0,0.55) {$\operatorname{Col} A$};
    \fill (0,-0.3) circle (1.4pt);
    \node[font=\scriptsize, anchor=west] at (0.15,-0.35) {$0$};
    \fill (0.25,0.85) circle (1.4pt);
    \node[font=\scriptsize, anchor=west] at (0.35,0.9) {$Ax$};
  \end{scope}
  \draw[->, acc, thick] (1.6,0.9) .. controls (3.2,1.7) .. (5.0,0.9);
  \node[acc, font=\scriptsize] at (3.3,1.75) {$A$ acts};
  \draw[->, black, thick] (0.9,-0.95) .. controls (3.2,-1.5) .. (5.15,-0.35);
  \node[black, font=\scriptsize] at (3.3,-1.6) {collapses to $0$};
\end{tikzpicture}
$$

## Basis

A subspace holds infinitely many vectors, but a finite, non-redundant spanning set
describes it completely.

> **Definition (Basis).** A **basis** for a subspace $H$ of $\mathbb{R}^n$ is a
> linearly independent set in $H$ that spans $H$.

Independence removes redundancy; spanning guarantees coverage. The columns of an
invertible $n \times n$ matrix form a basis for $\mathbb{R}^n$, and the simplest
case is the **standard basis** $\{e_1, \dots, e_n\}$, the columns of $I_n$.

### A basis for the null space

The parametric vector form of the solution set of $Ax = 0$ yields a basis for
$\operatorname{Nul} A$ directly: one basis vector per free variable.

> **Worked example.** Suppose the reduced echelon form of $A$ gives the general
> solution $x_1 = 2x_2 + x_4 - 3x_5$, $x_3 = -2x_4 + 2x_5$ with $x_2, x_4, x_5$
> free. Writing $x$ as a combination of the free variables,
>
> $$
> x = x_2\underbrace{\begin{bmatrix} 2\\1\\0\\0\\0 \end{bmatrix}}_{u}
> + x_4\underbrace{\begin{bmatrix} 1\\0\\-2\\1\\0 \end{bmatrix}}_{v}
> + x_5\underbrace{\begin{bmatrix} -3\\0\\2\\0\\1 \end{bmatrix}}_{w}.
> $$
>
> The set $\{u, v, w\}$ spans $\operatorname{Nul} A$, and it is automatically
> independent: entries $2, 4, 5$ (the free positions) force the weights
> $x_2, x_4, x_5$ to vanish in any dependence relation. So $\{u, v, w\}$ is a
> basis, and $\dim \operatorname{Nul} A = 3$.

### A basis for the column space

For the column space, take the pivot columns of $A$ itself, not of an echelon
form.

> **Theorem (Basis for Col A).** The pivot columns of a matrix $A$ form a basis
> for $\operatorname{Col} A$.

Row reduction changes the columns, yet it preserves every linear dependence
relation among them: $Ax = 0$ and $Bx = 0$ have the same solutions when $B$ is an
echelon form of $A$. So the non-pivot columns of $A$ are the same combinations of
pivot columns that they are in $B$, hence redundant, while the pivot columns
inherit the independence of the pivot columns of $B$.

> **Warning.** Use the pivot columns **of $A$**, located by reducing to echelon
> form. The columns of the echelon form itself usually do not lie in
> $\operatorname{Col} A$ and must not be used as the basis.

$$
% caption: Reduce A to locate pivots, then take the corresponding columns of the
% original A — not of the echelon form — as a basis for Col A.
\begin{tikzpicture}[font=\footnotesize]
  \definecolor{acc}{HTML}{4A6FA5}
  % A with pivot columns 1,2,5 shaded
  \fill[acc!16] (0,0) rectangle (0.5,1.6);
  \fill[acc!16] (0.5,0) rectangle (1.0,1.6);
  \fill[acc!16] (2.0,0) rectangle (2.5,1.6);
  \draw[black, thick] (0,0) rectangle (2.5,1.6);
  \draw[black] (0.5,0) -- (0.5,1.6); \draw[black] (1.0,0) -- (1.0,1.6);
  \draw[black] (1.5,0) -- (1.5,1.6); \draw[black] (2.0,0) -- (2.0,1.6);
  \node[black, font=\scriptsize] at (1.25,1.85) {$A$};
  \node[acc, font=\scriptsize] at (1.25,-0.35) {cols $1,2,5$ = pivot cols};
  % arrow
  \draw[->, acc, very thick] (3.0,0.8) -- (4.4,0.8) node[midway,above,font=\scriptsize]{reduce};
  % echelon form
  \draw[black, thick] (4.9,0) rectangle (7.4,1.6);
  \draw[black] (5.4,0)--(5.4,1.6);\draw[black](5.9,0)--(5.9,1.6);
  \draw[black] (6.4,0)--(6.4,1.6);\draw[black](6.9,0)--(6.9,1.6);
  % staircase pivots
  \fill[acc] (5.15,1.25) circle (1.6pt);
  \fill[acc] (5.65,0.85) circle (1.6pt);
  \fill[acc] (7.15,0.45) circle (1.6pt);
  \node[black, font=\scriptsize] at (6.15,1.85) {echelon form};
  \node[acc, font=\scriptsize] at (6.15,-0.35) {pivots mark columns};
\end{tikzpicture}
$$

> **Worked example.** The matrix
> $A = \begin{bmatrix} 1 & 3 & 3 & 2 & -9 \\ -2 & -2 & 2 & -8 & 2 \\ 2 & 3 & 0 & 7 & 1 \\ 3 & 4 & -1 & 11 & -8 \end{bmatrix}$
> reduces to the echelon form
>
> $$
> \begin{bmatrix} 1 & 0 & -3 & 5 & 0 \\ 0 & 1 & 2 & -1 & 0 \\ 0 & 0 & 0 & 0 & 1 \\ 0 & 0 & 0 & 0 & 0 \end{bmatrix},
> $$
>
> with pivots in columns $1, 2, 5$. A basis for $\operatorname{Col} A$ is the set
> of pivot columns **of $A$ itself**:
>
> $$
> \left\{ \begin{bmatrix} 1\\-2\\2\\3 \end{bmatrix},\; \begin{bmatrix} 3\\-2\\3\\4 \end{bmatrix},\; \begin{bmatrix} -9\\2\\1\\-8 \end{bmatrix} \right\}.
> $$
>
> The echelon form exposes the dependence relations $a_3 = -3a_1 + 2a_2$ and
> $a_4 = 5a_1 - a_2$, so columns $3$ and $4$ are redundant. Its own columns,
> however, are not vectors of $\operatorname{Col} A$ and must not be used. Here
> $\operatorname{rank} A = 3$, so by the Rank Theorem
> $\dim \operatorname{Nul} A = 5 - 3 = 2$.

## Coordinate systems

The point of choosing a basis, rather than any spanning set, is uniqueness of
representation.

> **Theorem (Unique representation).** If $\mathcal{B} = \{b_1, \dots, b_p\}$ is a
> basis for $H$, then each $x$ in $H$ can be written in exactly one way as
> $x = c_1 b_1 + \cdots + c_p b_p$.

Uniqueness follows from independence: two representations subtract to a dependence
relation, which must be trivial. The unique weights are the **coordinates** of $x$
relative to $\mathcal{B}$, collected into the coordinate vector

$$
[x]_{\mathcal{B}} = \begin{bmatrix} c_1 \\ \vdots \\ c_p \end{bmatrix} \in \mathbb{R}^p.
$$

The map $x \mapsto [x]_{\mathcal{B}}$ is a one-to-one correspondence between $H$ and
$\mathbb{R}^p$ that preserves linear combinations — an **isomorphism**. A
$p$-dimensional subspace of $\mathbb{R}^n$, whatever the ambient $n$, looks and
behaves like $\mathbb{R}^p$ through its coordinate map;
[coordinate systems](/linear-algebra/vector-spaces/coordinate-systems) develop this
in the abstract setting.

$$
% caption: A basis puts a coordinate grid on the plane H; the point x = 2v₁ + 3v₂
% has coordinate vector (2, 3) even though H sits inside R³.
\begin{tikzpicture}[>=stealth, font=\footnotesize]
  \definecolor{acc}{HTML}{4A6FA5}
  % skewed basis grid via a coordinate transform (unit square -> parallelogram)
  \begin{scope}[cm={1.5,0.2,-0.4,1.05,(0,0)}]
    \fill[acc!8] (-1,-1) rectangle (3,3);
    \draw[black] (-1,-1) grid (3,3);
    \draw[black] (-1,-1) rectangle (3,3);
  \end{scope}
  \fill (0,0) circle (1.6pt); \node[anchor=north east, font=\scriptsize] at (0,0){$0$};
  \draw[->, acc, very thick] (0,0) -- (1.5,0.2) node[anchor=north,font=\scriptsize]{$v_1$};
  \draw[->, acc, very thick] (0,0) -- (-0.4,1.05) node[anchor=east,font=\scriptsize]{$v_2$};
  % x = 2v1 + 2v2 = T(2,2) = (2.2, 2.5)
  \fill[black] (2.2,2.5) circle (1.8pt);
  \node[black, anchor=west, font=\scriptsize, fill=white, inner sep=1.5pt] at (2.3,2.5) {$x = 2v_1 + 2v_2$};
\end{tikzpicture}
$$

## Dimension and rank

Every basis of a given subspace has the same number of vectors, so counting them
is well defined.

> **Definition (Dimension).** The **dimension** $\dim H$ of a nonzero subspace $H$
> is the number of vectors in any basis for $H$; $\dim\{0\} = 0$.

Thus $\dim \mathbb{R}^n = n$, a plane through $0$ in $\mathbb{R}^3$ has dimension
$2$, and a line through $0$ has dimension $1$. The dimension of $\operatorname{Nul}
A$ is the number of free variables in $Ax = 0$, since each free variable
contributes one basis vector.

> **Definition (Rank).** The **rank** of $A$ is the dimension of its column space,
> $\operatorname{rank} A = \dim \operatorname{Col} A$. Because the pivot columns form
> a basis, $\operatorname{rank} A$ equals the number of pivot columns.

Every column of $A$ is either a pivot column, contributing to the rank, or a
non-pivot column, contributing a free variable and so a dimension of the null
space. Since the columns are exhausted by these two kinds, their counts add to the
number of columns.

> **Theorem (Rank Theorem).** If $A$ has $n$ columns, then
> $$
> \operatorname{rank} A + \dim \operatorname{Nul} A = n.
> $$

$$
% caption: The Rank Theorem as a partition of the n columns: pivot columns set the
% rank, non-pivot columns set the nullity, and the two counts fill n.
\begin{tikzpicture}[font=\footnotesize]
  \definecolor{acc}{HTML}{4A6FA5}
  % full bar of n columns
  \draw[black, thick] (0,0) rectangle (8,0.9);
  \fill[acc!22] (0,0) rectangle (5,0.9);
  \draw[acc, thick] (0,0) rectangle (5,0.9);
  \foreach \x in {1,2,3,4} \draw[black] (\x,0)--(\x,0.9);
  \foreach \x in {5.75,6.5,7.25} \draw[black] (\x,0)--(\x,0.9);
  \node[acc] at (2.5,0.45) {rank $A$ (pivot cols)};
  \node[black] at (6.5,0.45) {$\dim \operatorname{Nul} A$};
  % brace for total
  \draw[black] (0,-0.25) -- (0,-0.45) -- (8,-0.45) -- (8,-0.25);
  \node[black, font=\scriptsize] at (4,-0.75) {$n$ columns};
\end{tikzpicture}
$$

> **Worked example.** A $4 \times 5$ matrix that reduces to an echelon form with
> three pivot columns has $\operatorname{rank} A = 3$. The Rank Theorem gives
> $\dim \operatorname{Nul} A = 5 - 3 = 2$: three columns are pivots, two are free.

A useful shortcut follows once the dimension of a subspace is known: it already
determines how many vectors a basis needs.

> **Theorem (Basis Theorem).** Let $H$ be a $p$-dimensional subspace of
> $\mathbb{R}^n$. Any linearly independent set of exactly $p$ vectors in $H$ is a
> basis for $H$; likewise, any set of exactly $p$ vectors that spans $H$ is a
> basis.

With the right count, only one of "independent" and "spanning" needs checking; the
other follows.

## The Invertible Matrix Theorem, continued

For a square matrix these dimension counts become new equivalent conditions for
invertibility, extending the [earlier list](/linear-algebra/matrix-algebra/matrix-inverse-and-invertibility).[^lay-imt2]

> **Theorem (Invertible Matrix Theorem, continued).** Let $A$ be $n \times n$.
> Each statement below is equivalent to "$A$ is invertible":
>
> - the columns of $A$ form a basis of $\mathbb{R}^n$;
> - $\operatorname{Col} A = \mathbb{R}^n$;
> - $\dim \operatorname{Col} A = n$;
> - $\operatorname{rank} A = n$;
> - $\operatorname{Nul} A = \{0\}$;
> - $\dim \operatorname{Nul} A = 0$.

By the Rank Theorem, full rank $\operatorname{rank} A = n$ forces
$\dim \operatorname{Nul} A = 0$, so $Ax = 0$ has only the trivial solution — exactly
the earlier condition (d). An invertible matrix has the largest possible column
space and the smallest possible null space.

## Numerical note

Counting pivots to find rank is exact only with exact arithmetic. In floating
point, a matrix entry stored inexactly can make a would-be zero appear nonzero (or
the reverse), changing the apparent rank. The reliable notion in practice is the
**effective rank**, read from the
[singular value decomposition](/linear-algebra/symmetric-quadratic-svd/singular-value-decomposition):
count the singular values that are large relative to the rounding level, rather
than counting pivots.

[^lay-imt2]: **Lay**, _Linear Algebra and Its Applications_, §2.9 — the Rank Theorem $\operatorname{rank} A + \dim \operatorname{Nul} A = n$, the Basis Theorem, and the continuation of the Invertible Matrix Theorem with statements (m)–(r) on column space, rank, and null space; §2.8 supplies the definitions of subspace, column space, null space (Theorem 12), basis, and Theorem 13 on pivot columns.
