Matrix multiplication
Theory
To multiply matrices, the entry in row \(i\), column \(j\) of the product is the dot product of row \(i\) of the first matrix with column \(j\) of the second.
This only works when the inner dimensions match: an \(m\times n\) times an \(n\times p\) gives an \(m\times p\) result.
The multiplication rule:
How to multiply matrices
- Check the inner dimensions match.
- For each entry, dot the correct row with the correct column.
- Sum the products to get that entry.
- Assemble the \(m\times p\) result.
Row 1 of the first, dotted with column 1 of the second.
| \((1)(5)+(2)(7)\) | \(=\) | \(5+14=19\) |
Each entry is a row-by-column dot product.
The inner dimensions (3 and 3) match, so the product exists.
| \((2\times 3)(3\times 2)\) | \(\to\) | \(2\times 2\) |
In general no: \(AB\neq BA\). The products can even have different sizes, or one may not exist.
| \(AB\) | \(\neq\) | \(BA\) |
Common pitfalls
Frequently asked questions
How do you multiply two matrices?
Each entry of the product is the dot product of a row of the first matrix with a column of the second.
When can two matrices be multiplied?
When the inner dimensions match: an \(m\times n\) times an \(n\times p\). The result is \(m\times p\).
Is matrix multiplication commutative?
No. In general \(AB\neq BA\); the order changes the result, and one order may not even be defined.
What size is the product?
The outer dimensions: an \(m\times n\) times \(n\times p\) gives an \(m\times p\) matrix.