Matrix multiplication is the computational engine of linear models, graphics transformations, and data projections.
It is distinct from element-wise multiplication, which simply multiplies matching positions in arrays of identical shape.
The standard matrix product requires an inner dimension match: matrix A must have as many columns as matrix B has rows.
If A has shape m by k and B has shape k by n, their product C will have shape m by n.
The entry in row i and column j of product C is computed as the dot product between row i of A and column j of B.
This involves taking pairs of numbers, multiplying them together, and accumulating their sum into a single output cell.
Because row vectors multiply column vectors, changing the order of multiplication changes the entire operation.
For most matrices, A times B does not equal B times A, and in many cases B times A is not even dimensionally valid.
Matrix multiplication is associative, meaning A times the product of B and C equals the product of A and B times C.
It is also distributive over matrix addition: A times the sum of B and C equals A times B plus A times C.
In analytical pipelines, multiplying a feature matrix by a vector of weights calculates predicted scores for all rows at once.
A common beginner error is trying to multiply two matrices simply because they share identical dimensions.
Two rectangular matrices of shape three-by-four cannot be multiplied together because the inner dimensions four and three do not match.
Modern computing hardware uses specialised parallel processors to execute massive matrix multiplications at high speed.
Understanding matrix multiplication allows you to express thousands of individual calculations in a single compact equation.