linear algebra · machine learning · math

A matrix is a verb: what a linear map does

Jan 19, 2016 · 9 min read

Ask most people what a matrix is and they'll tell you it's a box of numbers — a grid, a spreadsheet with pretensions. Then they'll recite a rule for multiplying two of them that sounds like an incantation: rows times columns, sum as you go. Nobody remembers why. It's the kind of thing you learn to do without ever learning what it means, like conjugating a verb in a language you can't actually speak. And that's the tell, because a matrix really is a verb. It doesn't sit there being a grid. It acts. Hand it a vector and it hands you back a different vector — it takes the point where you are and moves you somewhere else. The grid of numbers is just the verb written down.

The man who first wrote it down deliberately was Arthur Cayley, in his 1858 A Memoir on the Theory of Matrices. What's striking, reading it now, is that Cayley didn't start from the grid at all. He started from the transformations — the substitutions that carry one set of variables into another — and noticed that these transformations could be composed, chained one after another, and that the chaining obeyed its own tidy arithmetic. The rectangular array was his bookkeeping for that arithmetic. The verb came first; the grid was invented to hold it still. We've been teaching it backwards ever since. Let's put it right way round.

Linearity is the whole definition

A matrix doesn't move vectors in just any old way. It moves them linearly, and that single word carries the entire theory. A map A is linear if it respects addition and scaling — if, for any vectors x and y and any scalars \alpha and \beta,

A(\alpha x + \beta y) = \alpha Ax + \beta Ay.

Read it as a promise. Whatever A does, it does it before or after you mix vectors and you get the same answer either way. Stretch two arrows, add them, then apply the map — or apply the map to each, then stretch and add the results. The map can't tell the difference. It has no way to treat a combination as anything other than the combination of what it does to the parts.

That looks like a modest little rule, but it is startlingly restrictive, and the restriction is the point. Most functions in the world are not linear — x \mapsto x^2 isn't, x \mapsto \sin x isn't, your electricity bill as a function of usage almost certainly isn't. What linearity buys you is this: if you know what the map does to a few well-chosen inputs, you know what it does to every input, for free, forever. Because every input is just a combination of those few, and the map is contractually obligated to send the combination to the same combination of the outputs. There is nowhere for surprises to hide. Fix the behavior on a basis and the map is completely pinned down. Which raises the obvious question — which few inputs? — and the answer is sitting in the matrix the whole time.

The columns are where the basis vectors land

In the plane, every vector is built from two atoms: e_1 = \begin{bmatrix} 1 \\ 0 \end{bmatrix}, one step east, and e_2 = \begin{bmatrix} 0 \\ 1 \end{bmatrix}, one step north. Any vector x = \begin{bmatrix} x_1 \\ x_2 \end{bmatrix} is just x_1 e_1 + x_2 e_2 — "x_1 steps east and x_2 steps north." These are the few well-chosen inputs. So by linearity, if we know Ae_1 and Ae_2, we're done:

Ax = A(x_1 e_1 + x_2 e_2) = x_1\,(Ae_1) + x_2\,(Ae_2).

Now watch what Ae_1 actually computes. Multiply a matrix by the vector \begin{bmatrix} 1 \\ 0 \end{bmatrix} and you pick out the first column, untouched; multiply by \begin{bmatrix} 0 \\ 1 \end{bmatrix} and you pick out the second. So Ae_j is the j-th column of A. That is the secret the notation keeps. The columns of a matrix are not coefficients to be shuffled — they are the destinations of the basis vectors, the answer to "where does east go, and where does north go?" Everything else is filled in by the promise of linearity:

Ax = \sum_j x_j\,(Ae_j) = x_1\,(\text{column } 1) + x_2\,(\text{column } 2).

The output is a recipe: take x_1 copies of where e_1 landed, add x_2 copies of where e_2 landed. The whole plane's fate is written in two columns.

e₁ e₂ before A [1.4 0.6] [0.4 1.1] Ae₁ = col 1 Ae₂ = col 2 after
The unit grid before and after a 2×2 map; the two heavy arrows are where e₁ and e₂ land — the columns of A.

Look at the picture and the phrase "linear map" stops being jargon. The map grabs the two basis arrows, drops their tips onto the two columns of A, and then — because it can't do anything else — drags the entire grid along for the ride. Straight lines stay straight, evenly spaced lines stay evenly spaced, and the origin stays put. That rigid, uniform bending of the graph paper is what a matrix is. The numbers just record where the corners of one little square end up.

Multiplication is composition

Now we can say what multiplying matrices means, and it isn't the incantation. If A and B are both maps — both verbs — then doing B first and A second is itself a map: apply B to x, then apply A to the result. The matrix that captures "B then A" in one shot is defined to be the product AB:

(AB)x = A(Bx).

That's it. Matrix multiplication is function composition, full stop. And once you believe that, the row-times-column ritual you were forced to memorize stops being arbitrary — it's forced. Column j of AB has to be where the product sends e_j, which is (AB)e_j = A(Be_j): first find where B sends e_j (that's column j of B), then push that vector through A (that's A times a vector, which combines A's columns). Grinding through the two-dimensional case, entry (i,j) of the product comes out as the dot of row i of A with column j of B. The rule is a consequence of "do one map, then the other," not a definition handed down from on high. You could have derived it yourself.

Composition also explains, without any computation, why matrix multiplication is not commutative — why AB \neq BA in general. Order matters for verbs. Putting on your socks then your shoes is not the same as your shoes then your socks. Take the plane: let R rotate everything a quarter-turn counterclockwise and let S be the projection that flattens everything onto the horizontal axis. Do S then R on the vector e_1 (east): S leaves it alone, R swings it up to north. Do R then S on the same e_1: R swings it to north, then S flattens it to zero. Same two maps, same starting vector, and one order lands on north while the other annihilates it. Concretely,

R = \begin{bmatrix} 0 & -1 \\ 1 & 0 \end{bmatrix}, \quad S = \begin{bmatrix} 1 & 0 \\ 0 & 0 \end{bmatrix}, \qquad RS = \begin{bmatrix} 0 & 0 \\ 1 & 0 \end{bmatrix} \neq \begin{bmatrix} 0 & -1 \\ 0 & 0 \end{bmatrix} = SR.

The algebra disagrees because the geometry disagrees. Composition remembers which verb went first.

The determinant measures the stretch

If a matrix bends the graph paper, there's a natural thing to ask: by how much? Take the unit square — the little tile with corners at the origin, e_1, e_2, and e_1 + e_2 — and push it through A. It lands as a parallelogram, spanned by the two columns of A. The determinant of A is the signed area of that parallelogram, and it answers, in one number, how the map rescales every area in the plane. A determinant of 3 means the map triples areas everywhere; a determinant of \tfrac{1}{2} means it halves them. In three dimensions it's the volume of the image of the unit cube, and the story is identical.

The word signed is doing real work. The determinant also carries the map's orientation. If A keeps east-to-north running counterclockwise — the same handedness the plane started with — the determinant is positive. If the map flips the plane over, swapping the handedness like a reflection in a mirror, the determinant comes out negative. Sign is orientation; magnitude is the area factor. One number, two facts.

And now the case that matters most. What if the determinant is zero? Zero area means the parallelogram has collapsed — the two columns no longer span a proper patch of the plane, but have fallen onto the same line (or, in three dimensions, into the same plane). The map has taken the whole two-dimensional plane and squashed it flat onto a lower-dimensional shadow. And here's the fatal consequence: once you've flattened the plane onto a line, whole rafts of different points get crushed onto the same output, and there is no way back. You cannot un-flatten. A map that isn't reversible has no inverse, so

\det A = 0 \quad\Longrightarrow\quad A \text{ is not invertible.}

That's why the determinant appears, seemingly out of nowhere, in the formula for a matrix inverse — you divide by it, and dividing by zero is the algebra screaming that the map threw information away. This flattening is not a footnote; it's the doorway to the next essays. When a map crushes space, what exactly gets crushed to zero, and what survives? That question splits the plane into a small cast of characters — a matrix's four fundamental subspaces — and it's where this series goes next.

Where this goes

Once you see a matrix as a verb, the rest of linear algebra reads like a study of what verbs can do. The flattening we just met — the collapse when \det A = 0 — opens onto the four fundamental subspaces, which sort every vector into "survives the map" or "gets crushed to nothing" and explain exactly what a non-invertible matrix keeps and what it destroys. And running the other way is the question of whether a map has favorite directions — vectors it doesn't rotate at all, only stretches. Those are the eigenvectors, and chasing them leads to the spectral picture that turns a complicated map into a handful of clean, independent scalings.

But the fastest way to feel any of this is to bend the paper yourself. The matrix-as-map playground lets you grab the two columns of a 2\times2 matrix and drag them around, and watch the entire unit grid warp to follow — the basis arrows tracking your cursor, the shaded unit square swelling and shrinking as the determinant changes, and the whole plane flipping inside-out the moment you drag one column past the other and the determinant crosses through zero. Slide the columns onto the same line and watch the plane pancake into a single streak. It's one thing to read that a matrix is a verb. It's another to hold the verb in your hand and shove it around.


Thoughts? Find me on LinkedIn.