Matrix Multiplication
Visualize how 2x2 matrices transform space and combine through multiplication.
By Riano · Published · Updated · Report a correction
Matrix multiplication: the right-hand transformation acts first
A product AB represents two transformations applied to column vectors: first B, then A. In this experiment, a quarter-turn followed by a horizontal stretch changes a square differently from applying those operations in the reverse order. Calculate the product, identify its two columns, and compare them with the module's transformed basis vectors.
Rows calculate entries; columns explain geometry
For A = [[a, b], [c, d]], multiplying A by (x, y) gives (ax + by, cx + dy). Each entry of AB is a row of A dotted with a column of B. Equivalently, column j of AB is A applied to column j of B.
The first column is the image of e1 = (1, 0); the second is the image of e2 = (0, 1). Knowing those images determines a linear transformation of every vector in the plane. This is why the displayed basis vectors help explain the multiplication rather than merely decorate it.
Worked example: rotate, then stretch
Choose A = [[2, 0], [0, 1]], which doubles horizontal coordinates, and B = [[0, −1], [1, 0]], a counterclockwise quarter-turn.
- The first column of B is (0, 1). Applying A leaves it at (0, 1), so that is column one of AB.
- The second column of B is (−1, 0). Applying A gives (−2, 0), so that is column two.
- Therefore AB = [[0, −2], [1, 0]]. In contrast, BA = [[0, −1], [2, 0]].
| Input | B then A: AB | A then B: BA |
|---|---|---|
| (1, 0) | (0, 1) | (0, 2) |
| (0, 1) | (−2, 0) | (−1, 0) |
Both products have determinant 2 and double area. Their different columns show that equal area factors do not imply equal transformations. Matrix multiplication is associative, so (AB)v = A(Bv), but it is generally not commutative: AB need not equal BA.
Match the product to the displayed controls
Open Matrix Multiplication. Matrix A has four sliders; Matrix B is chosen from a fixed set of transformations.
- Set a = 2, b = 0, c = 0 and d = 1. Select “Rotate 90°” as Matrix B Type.
- Read Matrix C = A × B. Its first column should be (0.0, 1.0) and its second (−2.0, 0.0). Compare those columns with the transformed coordinate directions.
- Select “Identity” for B without changing A. Predict why C now equals A.
- Restore “Rotate 90°,” then change d to 0. The product becomes [[0, −2], [0, 0]], collapsing the transformed square onto a line.
The BA column in the worked table is a paper comparison. The interface has no order-swap button and does not offer every possible matrix as B. Do not interpret changing an unrelated B preset as automatically reversing this particular pair.
What this two-dimensional model leaves out
The module uses 2 × 2 real matrices and column vectors. A different convention using row vectors changes how composition is written. For larger rectangular matrices, A's column count must equal B's row count; this condition is automatic for the square matrices here.
A zero determinant means some direction is collapsed and the transformation has no inverse. Ordinary 2 × 2 multiplication keeps the origin fixed, so it cannot represent a translation of the whole plane. Translating with homogeneous coordinates requires a larger representation. Screen scaling, grid spacing and decimal rounding do not alter the algebraic transformation.
Try a second prediction
Keep B as the quarter-turn but use A = [[1, 0], [0, 2]]. The product is [[0, −1], [2, 0]], which matches BA from the earlier pair. Explain why changing the direction of the stretch reproduces that result, even though the module still computes A × B in the same order.
Source for the multiplication viewpoints
MIT OpenCourseWare, Gilbert Strang: Multiplication and Inverse Matrices presents row, column and transformation viewpoints. The stretch-and-rotation matrices and control comparisons here are Riano's independently calculated example.
Experience it interactively
Adjust parameters, observe in real time, and build deep intuition with Riano’s interactive Matrix Multiplication module.
Try Matrix Multiplication on Riano →