+15 XP

Multiplying Two Matrices

Multiplying a matrix by a matrix (not just a vector) is how you chain transformations — do one, then another. It's the operation every deep network is built from. The rule is simple once you see it.

C = A B, where C[i][j] = (row i of A) · (column j of B)

Each entry of the result is one dot product: a row of A combined with a column of B.

Tap each cell of C below to see exactly which row and column build it, and the dot product that produces the number:

Tap a cell in C to see how it's built: (row of A) · (column of B).

A (2×3)
3
2
1
1
2
7
×
B (3×2)
0
1
2
4
5
1
=
C (2×2)
C[0][0] = 3×0 + 2×2 + 1×5 = 9

Every entry of the answer is one dot product: row i of A with column j of B. This single operation — matmul — is the heartbeat of AI: a neural-network layer is exactly weights × inputs, done billions of times.

Dimensions must line up: an (m × n) matrix times an (n × p) matrix gives an (m × p) result — the inner numbers must match (that shared n is the length of the rows and columns being dotted). Here A is 2×3, B is 3×2, so C is 2×2.

🤖 This IS a neural network: feed inputs through layer 1 (a matmul), then layer 2 (another matmul), then layer 3… Chaining matrix multiplies is the computation inside every image classifier, every language model, every transformer. GPUs exist mostly to do this one operation fast.