Algebra
Matrix multiplication
Row times column — a rule that's everywhere from graphics to neural nets.
To multiply A (m×n) by B (n×p): each entry of AB is the dot product of a row of A with a column of B.
Walk through
Step 1 of 5
The set-up
Multiply A = [1 2; 3 4] by B = [5 6; 7 8]. The result AB is 2×2. Each entry of AB is a row of A dotted with a column of B.
Dimensions must line up: (m × n)(n × p) gives m × p. If the inner numbers differ, the product simply doesn't exist.
Your turn
Can you multiply a 2×3 matrix by a 2×2 matrix (in that order)?
Recap
- Entry (i, j) of AB = (row i of A) · (column j of B).
- Inner dimensions must match; the result takes the outer dimensions.
- AB ≠ BA in general — order matters.
The inner dimensions must match: (m×n)(n×p) = m×p. Order matters — AB ≠ BA in general.