Matrix Multiplication

Entry (i,j) of AB is row i of A dotted with column j of B; in general AB ≠ BA.

The idea

Matrix multiplication is defined so that the product $AB$ is the single matrix that carries out $B$ first and then $A$. A matrix is a rule for turning one list of numbers into another, and the product records the effect of applying two such rules in succession; that requirement, not entry-by-entry convenience, fixes the rule below.

The entry in row $i$ and column $j$ of $AB$ pairs row $i$ of $A$ with column $j$ of $B$, multiplying matching entries and adding: $(AB)_{ij} = a_{i1}b_{1j} + a_{i2}b_{2j} + \cdots + a_{in}b_{nj}.$ The sum makes sense only when row $i$ of $A$ is exactly as long as column $j$ of $B$. So an $m \times n$ matrix can multiply only an $n \times p$ matrix — the inner dimensions must agree — and the product has the outer dimensions, $m \times p$.

The order of the factors matters. Applying $B$ then $A$ need not have the same effect as applying $A$ then $B$, so in general $AB \neq BA$, and for rectangular shapes only one of the two products may exist at all.

Ways to work on it

Not sure where to start? Take the ten-question placement test.