Math

Matrix Multiplication as Composition

Matrix multiplication is function composition. The product AB means first apply B and then A, so the order of the factors changes the geometry.

6 minLevel 2/3The interactive stage stays ad-free.
AShear xBRotate 90°det(AB)1.00Order mattersYes

AB = [0.80, -1.00; 1.00, 0.00] · (AB)x = A(Bx)

First apply B (cyan square), then A (amber square). Swapping the factors changes the combined map.

det(BA) 1.00

Matrix multiplication is composition. The cyan square is B applied to the original square; the amber square is A applied to that result. Swap the factors to see why AB and BA usually differ.

What you are seeing

1

Start with a point x. The map B sends it to Bx, then A sends that result to A(Bx).

2

The product AB is defined so that (AB)x = A(Bx). Its columns are A applied to the columns of B.

3

Matrix multiplication is not commutative in general: AB and BA can produce different transformations.

Why it matters

Composition explains graphics pipelines, robotics, changes of coordinates, and why matrix order matters in linear algebra and programming.

Complexity & details

For 2×2 matrices, multiplying two matrices costs O(1); applying the result to a point also costs O(1).

Frequently asked questions

Why does order matter?+

Matrix multiplication is composition of functions. Rotating then shearing is generally not the same as shearing then rotating.

What does AB mean visually?+

It is the single matrix that has the same effect as applying B first and A second. The intermediate square shows B; the final square shows AB.