How matrix multiplication works
The row-by-column rule, why dimensions have to match, why AB ≠ BA, and the properties that do still hold.
To multiply A (m×n) by B (n×p), the inner dimensions must match: the number of columns of A must equal the number of rows of B. The result is m×p.
The rule
Entry (i, j) of the product is the dot product of row i of A with column j of B:
c(i,j) = a(i,1)·b(1,j) + a(i,2)·b(2,j) + … + a(i,n)·b(n,j)
| 1 | 2 |
| 3 | 4 |
| 5 | 6 |
| 7 | 8 |
| 19 | 22 |
| 43 | 50 |
Check the first entry: 1·5 + 2·7 = 19. Our calculator shows every one of these expansions when you open the step-by-step panel.
AB is not BA
Matrix multiplication is not commutative. Often BA is not even defined, and when both products exist they are usually different matrices. Reversing the order of a product of transformations genuinely changes what happens — rotate then reflect is not reflect then rotate.
What does hold
- Associative:
(A·B)·C = A·(B·C) - Distributive:
A·(B + C) = A·B + A·C - Identity:
I·A = A·I = A - Transpose reverses:
(A·B)ᵀ = Bᵀ·Aᵀ - Determinants multiply:
det(A·B) = det(A)·det(B)
One more warning: A·B = 0 does not imply that A or B is zero. Matrices have zero divisors, unlike ordinary numbers.
Powers
Aⁿ only makes sense for square matrices, and A⁰ is defined as the identity. Computing it by repeated squaring — A⁸ = ((A²)²)² — takes 3 multiplications instead of 7.