linear algebra · machine learning · math
The four fundamental subspaces
Mar 8, 2016 · 9 min read
Gilbert Strang has been drawing the same picture on the same blackboard for decades. Two blobs, one on the left and one on the right, an arrow between them labelled A, and inside each blob a smaller shape nested inside the larger one. He calls it the picture of the four fundamental subspaces, and generations of MIT students have watched him sketch it and felt something click. What clicks is this: a matrix isn't just a machine that eats vectors and spits out other vectors. It sorts. It takes the space it eats from and cleaves it into "matters" and "vanishes," and it takes the space it spits into and cleaves that into "reachable" and "unreachable." Four pieces, two on each side, and every question you ever want to ask about a linear system — does it have a solution? is that solution unique? — is really a question about which piece a vector lands in.
None of the underlying mathematics is Strang's invention; rank, null spaces, and the theorem tying their dimensions together were classical by the nineteenth century, the common inheritance of Cayley's matrices and the theory of linear equations. What Strang did was frame it — insist that you draw all four spaces at once, in one picture, so the perpendicular pairings jump out at you. We built the matrix-as-map picture in the last essay, where a matrix grabs the plane and bends it, and we ended on the unsettling case: sometimes the map flattens space, crushing whole directions to nothing. This essay is about what gets crushed and what survives. Let's draw the picture.
Two spaces, and the map between them
An m \times n matrix A is a map from \mathbb{R}^n to \mathbb{R}^m. Feed it a vector x with n components and it returns a vector Ax with m components. So there are two spaces in play from the start, and they usually have different dimensions: the domain \mathbb{R}^n on the left, where inputs live, and the codomain \mathbb{R}^m on the right, where outputs land. Keeping these two straight is half the battle — a lot of confusion about matrices comes from imagining a single space when there are really two, wired together by A.
Now, we saw in the last essay that Ax is a combination of the columns of A, weighted by the entries of x:
Ax = x_1\,(\text{column } 1) + x_2\,(\text{column } 2) + \cdots + x_n\,(\text{column } n).
That one identity is the key that opens all four doors. Read from left to right, it tells you which outputs are reachable. Read the other way, it tells you which inputs get wasted. Let's take both readings in turn.
The column space: everything the map can reach
As x ranges over all of \mathbb{R}^n, the output Ax ranges over every possible combination of the columns of A. That set — the span of the columns — is the column space, written C(A). It lives on the right, inside the codomain \mathbb{R}^m, and it is precisely the set of reachable outputs: the vectors b that some input can actually produce.
This is the whole answer to solvability. The equation Ax = b asks: is there an input that produces b? And b is producible exactly when it's a combination of the columns — that is, exactly when
Ax = b \text{ has a solution} \quad\Longleftrightarrow\quad b \in C(A).
If your target lies in the column space, the map can reach it, and there's an x that gets you there. If it lies outside, no input on earth will do — the system is inconsistent, full stop. Solvability isn't an algebraic accident you discover by grinding through elimination and hitting a contradiction like 0 = 1. It's geometry: either your target is inside the reachable set or it isn't. (And when it isn't, you don't give up — you settle for the closest reachable point instead. That's the pivot to least squares, which is nothing but "project b onto C(A) when b refuses to lie in it.")
The dimension of the column space has a name: the rank r of the matrix. It counts how many genuinely independent directions the columns span — how "fat" the reachable set is. A full-rank map reaches everything; a rank-deficient one reaches only a thin slice.
The null space: everything the map crushes
Now read the identity the other way. Which inputs does A send to the zero vector? These are the x with Ax = 0 — the combinations of columns that cancel out to nothing. This set is the null space, written N(A), and it lives on the left, inside the domain \mathbb{R}^n. It's the collection of inputs the map annihilates, the directions that get crushed flat in the flattening we met last time.
The null space is exactly what governs uniqueness. Suppose x solves Ax = b, and suppose z is some nonzero vector in the null space. Then
A(x + z) = Ax + Az = b + 0 = b,
so x + z is also a solution. Every element of the null space is a free direction you can slide along without changing the output. So the solution is unique precisely when there's nowhere to slide — when the null space contains nothing but the origin:
Ax = b \text{ has a unique solution} \quad\Longleftrightarrow\quad N(A) = \{0\}.
A nontrivial null space means redundancy: several inputs collapsing onto the same output, information thrown away, no way back. That's the algebraic face of the determinant-zero collapse from the last essay. When \det A = 0, the null space is nonempty, and the crushed directions are its members.
Rank plus nullity: the conservation law
Here's where the two readings meet, and it's the cleanest theorem in the subject. The domain \mathbb{R}^n has n dimensions to spend. Every one of those dimensions either survives the map (contributing to the reachable output, and so to the rank) or dies in the null space. There's no third option, and no dimension can do both. So the dimensions have to add up:
\operatorname{rank}(A) + \dim N(A) = n.
This is the rank–nullity theorem, and it's a conservation law. The map has exactly n input dimensions to work with; r of them come through alive as independent output directions, and the remaining n - r get spent collapsing to zero. Widen the null space and you must narrow the rank by exactly as much; there's no free lunch. If you understand nothing else about a matrix, understand this trade: reach and redundancy are two ends of one budget.
The other side of the mirror: rows and the perpendicular pairs
We have two subspaces so far — column space (right) and null space (left). The other two come from the same construction applied to the transpose A^\top, which swaps the roles of rows and columns. The row space C(A^\top) is the span of A's rows, living on the left in \mathbb{R}^n; the left null space N(A^\top) is what A^\top crushes, living on the right in \mathbb{R}^m. Four subspaces, two on each side. And a small miracle: the row space also has dimension r — the number of independent rows equals the number of independent columns. Row rank equals column rank, always.
Now stare at the left side, where both the row space and the null space live inside the same \mathbb{R}^n. They are not just two arbitrary subspaces sharing a room — they are orthogonal complements. Every vector in the row space is perpendicular to every vector in the null space, and together they fill all of \mathbb{R}^n. The reason is almost too short to be satisfying: a vector x is in the null space when Ax = 0, and Ax is just the list of dot products of x with each row of A. So Ax = 0 says x is perpendicular to every row — perpendicular to the entire row space. The null space is defined as "everything at right angles to the rows." Their dimensions confirm it: r + (n - r) = n, the two pieces exactly tiling the domain with no overlap and no gap.
The same story plays out on the right: the column space and the left null space are orthogonal complements inside \mathbb{R}^m. This perpendicular structure is the whole reason projection works — when your target b misses the column space, the error you're forced to accept lands squarely in the perpendicular piece, the left null space, and that right-angle is what makes the closest point unique and computable. It's also, quietly, why the matrix X^\top X that shows up in the least-squares normal equations is invertible exactly when X's columns are independent: independent columns mean a trivial null space, and a trivial null space is precisely what stops X^\top X from crushing anything of its own.
Where this goes
The four subspaces turn every question about a linear system into a question about geometry: solvability is "is b in the column space?", uniqueness is "is the null space trivial?", and the rank–nullity theorem is the budget tying it all together. Once you're comfortable moving between the algebra and the picture, the natural next step is to make the perpendicularity do real work — to take a vector that isn't in a subspace and find the closest one that is. That's orthogonality and projection, the machinery that turns "b isn't reachable" into "here's the best reachable stand-in," and it's the direct bridge from this essay to least squares.
But first, get your hands on the reachable set. The four-subspaces playground fixes the columns of a small matrix and lets you drag a target vector b around the output space. Watch the column space light up as a line or a plane — the set of everything the map can reach — and watch the badge flip between solvable and not solvable the instant your target crosses in or out of it. The null-space direction is drawn too, the direction the map crushes to nothing. It's one thing to read that solvability is "b \in C(A)." It's another to drag b across the boundary and feel the system snap from possible to impossible.
Thoughts? Find me on LinkedIn.