Back to courseLesson 6 of 13

Composing and undoing

What you'll learn

Chain transformations with matrix multiplication, undo them with the inverse — and see why det = 0 can't be undone.

One motion is a matrix. What about two motions in a row — shear, then rotate? Higher math's favorite trick: the combination is just another matrix, and finding it is what matrix multiplication is for.

Composition: do A, then B

startAshearedBthen rotatedfirst A, then B — one matrix: BA
Matrix multiplication is function composition, read right to left: (BA)v = B(Av). Order matters — shearing then rotating is not rotating then shearing.

Apply A to a vector, then apply B to the result: B(Av). The single matrix with the same total effect is the product BA — written right to left, like function composition f(g(x)), because the vector meets A first.

Computing BA needs no new idea: its columns are the landing spots of î and ĵ under the combined trip. Push î through A, push the result through B — that's column 1 of BA. Same for ĵ.

Order matters

Shear-then-rotate is not rotate-then-shear — run both orders in the visualizer and watch the grids disagree. In symbols: AB ≠ BA in general. Matrix multiplication is the first multiplication most people meet that refuses to commute, and it refuses for an honest reason: sequences of actions don't commute. Socks then shoes.

The inverse: undoing a motion

If A moves the plane, A⁻¹ is the matrix that moves everything back: A⁻¹A = I, the identity (the do-nothing matrix). Rotate 30° back, stretch ×2 down to ×½ — every step reversed. For a 2×2 there's even a closed form:

A1=1detA(dbca)A^{-1} = \frac{1}{\det A}\begin{pmatrix} d & -b \\ -c & a \end{pmatrix}

When undoing is impossible

Look at that formula: it divides by det A. If det A = 0 the inverse doesn't exist — and the last lesson showed why in pictures. A determinant of zero means the plane was squashed onto a line; two different inputs now share one output, and no map can tell them apart again. Singular matrices aren't a computational inconvenience — they've destroyed information.

Why this matters

"Solve Ax = b" — the most common request in applied math — is exactly "undo A": x = A⁻¹b, possible precisely when det A ≠ 0. And composition is how every complex motion (a robot arm, a graphics pipeline) is built from simple ones. Next: the hidden skeleton inside any single matrix.

Check your understanding

Question 1 of 2

"Apply A first, then B" is written as the single matrix:

Next lesson