Matrix Multiplication: Rules and Examples Made Simple
Matrix multiplication uses the row-by-column rule: the entry in row i, column j of AB is the dot product of row i of A with column j of B. Unlike addition, it is not entry-by-entry — each answer blends a whole row with a whole column.
Multiplication matters because it is how transformations compose and how systems of equations are written compactly: AX = B packs a whole system into three letters. The strict order rule — (m × n) times (n × p) gives (m × p) — is the single most tested fact in this chapter.
Key Concepts
- Compatibility rule: AB exists only if the number of columns of A equals the number of rows of B. (m × n) times (n × p) gives (m × p).
- Row-by-column: each entry of the product is a sum of pairwise products along one row of A and one column of B.
- Not commutative: in general AB ≠ BA — and often one of them does not even exist.
- Associative: (AB)C = A(BC), so chains of multiplications can be regrouped.
- Distributive: A(B + C) = AB + AC.
Formulas
- General entry: (AB)_ij = Σ_k=1^n a_ikb_kj, where A is m × n and B is n × p. The sum runs over the shared inner dimension n.
- 2 × 2 shortcut: [[a, b], [c, d]] × [[e, f], [g, h]] = [[ae + bg, af + bh], [ce + dg, cf + dh]]. Memorise the pattern: top-left = (row 1 of A)·(column 1 of B).
Worked Example
Compute AB for A = [[1, 2, 3], [4, 5, 6]] and B = [[7, 8], [9, 10], [11, 12]].
- Check compatibility: A is 2 × 3, B is 3 × 2. Inner dimensions match (3 = 3), so AB exists and will be 2 × 2.
- Entry (1,1): row 1 of A · column 1 of B = 1·7 + 2·9 + 3·11 = 7 + 18 + 33 = 58.
- Entry (1,2): row 1 of A · column 2 of B = 1·8 + 2·10 + 3·12 = 8 + 20 + 36 = 64.
- Entry (2,1): row 2 of A · column 1 of B = 4·7 + 5·9 + 6·11 = 28 + 45 + 66 = 139.
- Entry (2,2): row 2 of A · column 2 of B = 4·8 + 5·10 + 6·12 = 32 + 50 + 72 = 154.
- Result: AB = [[58, 64], [139, 154]].
Common Misconceptions
- "AB = BA." Almost never. Even when both exist, the answers differ — order matters because transformations applied in different sequences give different results.
- "Multiply matching entries like addition." That is the Hadamard product, a different operation. True matrix multiplication always uses row-by-column sums.
- "AB = O means A = O or B = O." False for matrices — non-zero matrices can multiply to the zero matrix, e.g. [[1, 0], [0, 0]] × [[0, 0], [1, 0]] = [[0, 0], [0, 0]].
Real-World Applications
- 3D graphics: rotating then moving an object multiplies its rotation matrix by its translation matrix; the order of multiplication is the order of the moves.
- Markov chains: multiplying a transition matrix repeatedly predicts probabilities many steps ahead (weather, web surfing, board games).
- Neural networks: every layer computes (weights × inputs) + bias — deep learning is chains of matrix multiplications.
Matrix multiplication follows the row-by-column rule with the compatibility condition (columns of A = rows of B). It is associative and distributive but not commutative, and it turns systems of equations into AX = B.
Related blogs
- Matrix Order and Types: Complete Guide with Examples
- Equality of Matrices: Concepts, Formulas and Examples
- Addition and Subtraction of Matrices: Rules & Examples
- Scalar Multiplication of Matrices: Rules and Examples
- Transpose of a Matrix: Definition, Properties, Examples
- Symmetric and Skew-Symmetric Matrices Explained with