MATRIX MULTIPLICATION, EXPLAINED VISUALLY

Why Does Matrix Multiplication Work This Way?

Why do we multiply a row from one matrix by a column from another? Why do we multiply the matching entries and then add them? And who decided that this should be the rule?

Why row × column? Why must dimensions match? Why does order matter?

The short answer: matrix multiplication is not an arbitrary way to multiply grids of numbers. It is the rule that lets two linear transformations be combined into one.

1. First, Stop Thinking of a Matrix as Just a Grid of Numbers

A useful way to think about a matrix is as a small machine. You give it a list of numbers, and it produces a new list of numbers.

Interactive visual: a matrix as a machine

Press the button and watch each row of the matrix build one output value.

Input
12
Matrix A
2 1 1 2
Each row creates one output value.
Output
??

With the example above, the first row says: take 2 times the first input and add 1 times the second input. The second row gives a different recipe for the second output.

Each row describes how to build one output number. That is why a matrix can represent a transformation, not just a table.

2. Now Put Two Matrix Machines Together

Suppose Matrix B changes your input first, and then Matrix A changes the result again. You could keep running both calculations every time. But it would be much more useful if one new matrix could do the same combined job.

Interactive visual: two transformations become one

The same input travels through B and then A. The product AB reproduces the same final output in one step.

Input v [1, 1]
Matrix B stretch x
Intermediate [2, 1]
Matrix A rotate 90°
B[1, 1] = [2, 1]   →   A[2, 1] = [-1, 2]
Same final output ✓   The two transformations have been combined into one matrix.

This is the central reason matrix multiplication exists. If B happens first and A happens second, the product AB is the single matrix that represents that composition.

3. Watch the Row × Column Rule Appear by Itself

Now we can answer the strange part: why rows and columns? Instead of declaring the rule, we can derive it.

Main interactive: derive the rule step by step

Use Next step, or click any numbered step. The familiar row-by-column rule appears from ordinary substitution and simplification.

Step 1 of 6
Start with two matrices and an input vector
A
abcd
×
B
efgh
Input vector: [x, y]

B will act first. Then A will act on B's output.

The key moment is not a memorized rule. It is the grouping:

a(ex + fy) + b(gx + hy) = (ae + bg)x + (af + bh)y

The coefficient ae + bg is the first row of A dotted with the first column of B. The coefficient af + bh is the first row of A dotted with the second column of B.

Do the same thing with the second row of A and you get the entire product:

AB = [[ae + bg, af + bh], [ce + dg, cf + dh]]

Row × column was not inserted into the calculation. It came out of the calculation.

4. Why Do We Multiply and Then Add?

Each entry in the product collects every path through which an input can contribute to that output.

Path 1
input → e → a → ae

The first contribution travels through e and then a.

Path 2
input → g → b → bg

The second contribution travels through g and then b.

Both paths affect the same output, so the contributions are added:

ae + bg

That is why entries in a matrix product are sums of products.

5. Why Do the Dimensions Have to Match?

The familiar dimension rule is also easier to understand as a connection between machines. One transformation's output must fit the next transformation's input.

Compatible ✓

B outputs three numbers, and A expects three numbers.

→

The connection fits.

Not compatible ✗

B outputs two numbers, but A expects three numbers.

→

There is no valid connection.

If A is m × n and B is n × p, the inner n values match, so AB exists and has size m × p.

Try the Matrix Multiplication Dimensions Checker →

6. Why Does Order Matter?

Matrix multiplication is usually not commutative: AB ≠ BA. That makes sense once matrices are transformations, because changing the order of transformations can change the result.

Interactive visual: stretch then rotate vs. rotate then stretch

Both paths use the same two transformations. Only the order changes.

Stretch → Rotate

Start with the same square.

Rotate → Stretch

Start with the same square.

Same transformations, different order, different final shape. Matrix multiplication preserves that order instead of pretending the two processes are interchangeable.

7. What Is Matrix Multiplication Actually Used For?

Once matrices can represent transformations and multiplication can combine them, the operation becomes useful almost everywhere systems and transformations appear.

3D
Graphics & Games

Combine rotation, scaling, camera and projection transformations.

R
Robotics

Combine joint and coordinate transformations along a robot arm.

E
Engineering

Model systems, coordinate changes and coupled quantities.

CV
Computer Vision

Transform image and camera coordinates and geometric models.

AI
Machine Learning

Transform large collections of numbers through layers of a model.

=
Systems of Equations

Represent and solve many related equations compactly.

8. Who Came Up With Matrix Multiplication?

The modern theory of matrices developed during the 19th century. James Joseph Sylvester introduced the word matrix in 1850, and Arthur Cayley developed matrix algebra much further, including the systematic treatment of matrix multiplication in his 1858 Memoir on the Theory of Matrices.

The important idea is not that someone simply announced, “rows must multiply columns.” The rule became fundamental because it makes matrix algebra match the composition of linear transformations.

9. The Short Answer

Matrix multiplication uses row-by-column multiplication because matrices can represent linear transformations, and the row-by-column rule is exactly what is needed to combine two transformations into one.

That same idea explains why products are added, why dimensions must match, and why changing the order can change the result.

Try the Rule Yourself

Understanding why the rule exists is one step. Actually using it yourself is another.