The Null Space

Point a camera at the world and something quietly disappears: depth. A tall lamppost far away and a short pencil held close can land on exactly the same spot in the photograph. The camera squashes three dimensions down to two, and in doing so it throws a whole direction — "toward and away from the lens" — completely away. Every scene lined up along that direction collapses to a single point on the film.

A matrix does the same thing. Multiplying by a matrix A is a machine that takes an input vector and produces an output vector, and — just like the camera — it can flatten certain input directions all the way to nothing. The set of every input vector that A crushes to the zero vector has a name: the null space of A (also called its kernel). It is the complete list of directions the matrix erases.

Formally, the null space of an m \times n matrix A is

\operatorname{Null}(A) = \{\, \vec{x} \in \mathbb{R}^n : A\vec{x} = \vec{0} \,\}.

You find it by solving one specific system — the homogeneous system A\vec{x} = \vec{0} — and the whole toolkit you need is one you already own: Gaussian elimination.

The null space is a subspace — it always contains the origin

Before finding one, notice what kind of object a null space is. It is never just a scattered handful of vectors — it is always a subspace of the input space \mathbb{R}^n: a flat sheet of some dimension passing right through the origin. Three facts make it so, and each is a one-line check straight from the definition.

Closed under addition and scaling is exactly closed under linear combinations. So a null space is always the span of a few vectors — which is why the answer to "what is the null space?" is never a messy list but a clean geometric object: the point \{\vec{0}\}, or a line through the origin, or a plane through the origin, and so on upward.

Worked example: solving A\vec{x} = \vec{0} — a free variable and a line

Take A = \begin{bmatrix} 1 & 2 & -1 \\ 2 & 4 & 0 \end{bmatrix}, a machine from \mathbb{R}^3 to \mathbb{R}^2. To find its null space, row-reduce the (homogeneous) system A\vec{x} = \vec{0}. The right-hand side is all zeros and stays all zeros under every row operation, so we don't even bother writing the augmented column — we just reduce A itself.

\begin{bmatrix} 1 & 2 & -1 \\ 2 & 4 & 0 \end{bmatrix} \xrightarrow{R_2 - 2R_1} \begin{bmatrix} 1 & 2 & -1 \\ 0 & 0 & 2 \end{bmatrix} \xrightarrow{R_2 \div 2} \begin{bmatrix} 1 & 2 & -1 \\ 0 & 0 & 1 \end{bmatrix} \xrightarrow{R_1 + R_2} \begin{bmatrix} 1 & 2 & 0 \\ 0 & 0 & 1 \end{bmatrix}

That last matrix is the reduced row-echelon form. Read off the columns: columns 1 and 3 have leading 1s — they are pivot columns — while column 2 has no pivot. Its variable, x_2, is therefore a free variable: we may set it to anything we like, and the pivot variables are then forced. The two equations say x_1 + 2x_2 = 0 and x_3 = 0, so x_1 = -2x_2 and x_3 = 0.

Now write the general solution as a vector, pulling the one free variable out as a scalar factor:

\vec{x} = \begin{bmatrix} x_1 \\ x_2 \\ x_3 \end{bmatrix} = \begin{bmatrix} -2x_2 \\ x_2 \\ 0 \end{bmatrix} = x_2 \begin{bmatrix} -2 \\ 1 \\ 0 \end{bmatrix}.

The vector \vec{s} = (-2, 1, 0) — obtained by setting the free variable x_2 = 1 — is called a special solution. Every element of the null space is a multiple of it, so \operatorname{Null}(A) = \operatorname{span}\{(-2,1,0)\}: a single line through the origin, living inside \mathbb{R}^3. One free variable produced one special solution, so this null space is one-dimensional.

The recipe, and the word "nullity"

That example is the general method. To find the null space of any matrix:

  1. Row-reduce A to reduced row-echelon form.
  2. Spot the pivot columns (those with a leading 1); every other column is a free column.
  3. Give each free variable a turn at being 1 while the others are 0, and solve for the pivot variables. Each turn yields one special solution.
  4. The special solutions form a basis for the null space: \operatorname{Null}(A) is exactly their span.

The number of special solutions — equivalently, the number of free variables, equivalently the dimension of the null space — is called the nullity of A. Because free columns are precisely the columns without a pivot,

\text{nullity}(A) = (\text{number of columns}) - (\text{number of pivots}).

In the worked example above there were 3 columns and 2 pivots, giving nullity 3 - 2 = 1 — a line, exactly as we found. (That relationship between columns, pivots, and nullity grows up into the rank–nullity theorem.)

Worked example: two free variables give a plane

Nullity need not be 1. Consider a single-row matrix B = \begin{bmatrix} 1 & 2 & 3 \end{bmatrix}, already in reduced row-echelon form. Only column 1 has a pivot, so x_2 and x_3 are both free. The single equation x_1 + 2x_2 + 3x_3 = 0 gives x_1 = -2x_2 - 3x_3, and so

\vec{x} = x_2 \begin{bmatrix} -2 \\ 1 \\ 0 \end{bmatrix} + x_3 \begin{bmatrix} -3 \\ 0 \\ 1 \end{bmatrix}.

Two free variables, two special solutions, nullity 3 - 1 = 2: the null space is a whole plane through the origin in \mathbb{R}^3. This matches the geometry perfectly — B\vec{x} = 0 is the equation of a plane through the origin with normal vector (1,2,3), and every vector lying in that plane is flattened to zero.

See the collapse: a matrix flattening its null-space line to zero

Back in two dimensions, take A = \begin{bmatrix} 1 & 2 \\ 2 & 4 \end{bmatrix} (the second row is just twice the first, so it row-reduces to \begin{bmatrix} 1 & 2 \\ 0 & 0 \end{bmatrix}). Its null space is the line x + 2y = 0 — the span of the special solution (2, -1). Drag the slider to scale a vector \vec{x} up and down that dashed line: however far out it slides, its image A\vec{x} stays pinned to the origin. That is what "the direction a matrix flattens to nothing" looks like.

Worked example: why every solution set is a shifted null space

The null space also explains the shape of the solution set of a non-homogeneous system A\vec{x} = \vec{b}. Suppose two different vectors \vec{x}_1 and \vec{x}_2 both solve it, so A\vec{x}_1 = \vec{b} and A\vec{x}_2 = \vec{b}. Subtract:

A(\vec{x}_1 - \vec{x}_2) = A\vec{x}_1 - A\vec{x}_2 = \vec{b} - \vec{b} = \vec{0}.

So the difference \vec{x}_1 - \vec{x}_2 lands in the null space. Turn that around: if \vec{x}_p is any one particular solution and \vec{n} is anything in \operatorname{Null}(A), then A(\vec{x}_p + \vec{n}) = \vec{b} + \vec{0} = \vec{b} is a solution too. Every solution therefore has the form

\vec{x} = \vec{x}_p + \vec{n}, \qquad \vec{n} \in \operatorname{Null}(A).

The full solution set is a shifted copy of the null space — the same line or plane, picked up off the origin and slid over to pass through \vec{x}_p instead. This is exactly why elimination reports "infinitely many solutions" precisely when there is a free variable: a non-trivial null space is the reservoir those extra solutions are drawn from.

The null space measures failure of injectivity

The result above has a sharp consequence. If two different inputs \vec{x}_1 \neq \vec{x}_2 ever produce the same output, their non-zero difference sits in the null space. Contrapositively:

So "how big is the null space?" is really the question "how badly does this matrix fail to be reversible?" A trivial null space means nothing is lost — every output traces back to a single input. A one-dimensional null space means a whole line of inputs collapses to each output; a two-dimensional one means a whole plane does. The nullity is a precise count of the information the matrix destroys.

Picture standing inside the input space while the matrix acts. Vectors pointing in most directions get stretched, rotated, and land somewhere non-zero on the output side. But if you stand on the null space and look along it, the matrix stops caring where you are — step forward, step back, take a giant leap, and your shadow on the output side doesn't move a millimetre. It stays glued to the origin.

That is the intuition behind "kernel", the null space's other name (from the German Kern, "core"): it is the innermost set of inputs the transformation is completely blind to. Compression algorithms, dimensionality reduction, and shadows all live on this idea — deliberately picking directions safe to flatten because almost nothing important points along them.

Two things about the null space trip nearly everyone up at first: