Matrix Multiplication Explained with Visual Examples

Row times column feels like an arbitrary rule until you see what it's actually doing: gluing two space-warping machines into one. Here's the intuition, built up from a single dot product to full transformations.

By Petrus Sheya

July 31, 2026 · 5 min read

Why do you multiply a row by a column to get a single number? Whoever taught you matrix multiplication probably just handed you the rule and moved on. Let's actually figure out where it comes from.

Most people memorize it: take a row from the first matrix, take a column from the second, multiply matching entries, add them up. It works, but it feels arbitrary. It isn't. By the end of this, you'll see matrix multiplication as something much simpler: gluing two transformations of space into one.


What does one entry of the product actually mean?

Let's start small. Say AA is 2×32\times 3 and BB is 3×23\times 2. Their product C=ABC = AB is 2×22\times 2, and each entry of CC is built the same way:

Cij=kAikBkjC_{ij} = \sum_k A_{ik} B_{kj}

In plain English: to get the entry in row ii, column jj of CC, take row ii of AA, take column jj of BB, multiply them position by position, and add up the results.

Visualizer 01

Every Entry Is a Dot Product

Click a cell in C. Its value comes from one row of A and one column of B, multiplied term by term and added up.

A (2×3)20113−1B (3×2)12013−1C = AB53−26row 1 of A · column 1 of B → entry (1,1) of C
2×1 + 0×0 + 1×3 = 5
Selected cellC[1,1]
Value5

Click around the result grid. Every cell in C pulls from exactly one row of A and one column of B, nothing else. That's the whole rule. The "multiply and add" part has a name: it's a dot product. Matrix multiplication is just a grid of dot products, one for every combination of row and column.


But why a dot product? What is A actually doing to a vector?

Here's the thing that makes it click: before we multiply two matrices, look at what a matrix does to a single vector.

Take AvA\mathbf{v} where v=(v1,v2)\mathbf{v} = (v_1, v_2). Write it out:

Av=v1[A11A21]+v2[A12A22]A\mathbf{v} = v_1 \begin{bmatrix} A_{11} \\ A_{21} \end{bmatrix} + v_2 \begin{bmatrix} A_{12} \\ A_{22} \end{bmatrix}

Multiplying a matrix by a vector isn't some abstract operation. It's just scaling A's columns by v's entries and adding the results. v1v_1 tells you how much of column 1 to take, v2v_2 tells you how much of column 2, and you add them.

Visualizer 02

A Vector Times a Matrix Is a Blend of Columns

Spin the input vector v around the circle. The output is always v's first coordinate times A's first column, plus its second coordinate times A's second column.

INPUT vOUTPUT Avvv₁·col 1v₂·col 2Av
v(0.82, 0.57)
Av(1.06, 1.97)

Spin the vector v around and watch the output. It never does anything mysterious, it's always just a blend of the same two fixed columns, in different proportions. And hey, notice that a dot product is exactly this same blending idea, just for a single output number instead of a full vector.


So what happens when B is a whole matrix instead of one vector?

Now for the interesting part. A matrix BB is really just a bundle of column vectors stacked side by side. When we compute ABAB, we're not doing anything new, we're applying the "blend A's columns" trick to every column of B, one at a time.

AB=A[b1b2]=[Ab1Ab2]AB = A \begin{bmatrix} \mathbf{b_1} & \mathbf{b_2} \end{bmatrix} = \begin{bmatrix} A\mathbf{b_1} & A\mathbf{b_2} \end{bmatrix}

Which means ABAB is what you get if you take every vector B would produce, and run it through A afterward. Applying ABAB to something is the same as applying BB, then applying AA to the result. Multiplying matrices is composing transformations.

Visualizer 03

AB Means "Do B, Then Do A"

Step through shearing the square with B, then rotating the result with A. On the last step, the dashed outline shows AB applied directly, same shape, one move.

Start: the unit square
Step1 / 3
AB corner (1,1) →(-1.00, 1.60)

Press play. First B shears the square, then A rotates whatever B produced. On the last step, the dashed outline shows what ABAB does in a single move, applied directly to the original square, and it lands in exactly the same place. Two steps, or one matrix. Same answer.

We write this as:

(AB)x=A(Bx)(AB)\mathbf{x} = A(B\mathbf{x})

Read right to left: BB acts first, then AA acts on whatever came out.


Does the order we multiply in matter?

You'd think ABAB and BABA should give the same thing, addition doesn't care about order, so why would this? But matrix multiplication represents doing one thing, then another, and doing things in a different order usually lands you somewhere else.

Visualizer 04

Order Matters: AB vs BA

Toggle which product runs first. The faint dashed shape is the other order, same two matrices, different result. Matrix multiplication is not commutative.

A(Bv): rotate, then stretch
AB corner (1,1)(-1.00, 2.00)
BA corner (1,1)(-2.00, 1.00)

Toggle between AB and BA. Same two matrices, same starting square, genuinely different results. Rotating a shape and then stretching it sideways does not land in the same place as stretching it first and then rotating it, picture stretching a photo horizontally versus rotating it 90° first, then stretching, the stretch now runs along a completely different direction of the shape.

We write this fact compactly:

ABBA(in general)AB \neq BA \quad \text{(in general)}

There are special matrices where order stops mattering (identity matrices, for one), but in general, matrix multiplication is not commutative. Order is part of the meaning.


Where this shows up

Every 3D game and CAD program chains rotation, scale, and translation matrices together for every object on screen, in a specific order, every frame.

Neural networks are, at their core, layers of matrix multiplications stacked one after another, each layer's output feeding into the next layer's input, exactly the composition idea from above.

Robotics uses chained matrix products to track a robot arm's joints, each joint's rotation composed on top of the last one's position.

Computer graphics pipelines multiply a whole sequence of transformation matrices together in advance, precisely because ABAB collapsing two steps into one saves recomputing the whole chain for every point on screen.


The plain-English version

Matrix multiplication looks like an odd row-times-column rule, but it's really composition in disguise. Each entry of the product is a dot product because that's what "how much of this output direction comes from that input direction" boils down to. Multiplying a matrix by a vector blends the matrix's columns. Multiplying two matrices does that blending for every column of the second matrix at once, which is exactly the same as running one transformation through another. And because order changes what "running one thing, then another" means, ABAB and BABA are usually different matrices entirely.


All four visualizations are interactive React components running in your browser. No libraries beyond React.