Matrices: grids that do things
Helpful first: Pythagoras for the distance check in the example, and Fibonacci and the golden ratio for the stretch. Ready if you can give the next three Fibonacci numbers after 5, 8, 13.
Tonight's idea
A matrix is a grid of numbers. That sounds dull until you learn what a matrix does: it is a machine that takes a point and moves it somewhere else. Every rotation, stretch, squash and reflection in a video game is a matrix at work.
Here is the machine with the numbers \(a, b, c, d\), and here is what it does to the point \((x, y)\):
\[ \begin{pmatrix} a & b \\ c & d \end{pmatrix} \begin{pmatrix} x \\ y \end{pmatrix} = \begin{pmatrix} ax + by \\ cx + dy \end{pmatrix} \]Read it row by row. The new \(x\) is "top row times the point": \(a\) times \(x\) plus \(b\) times \(y\). The new \(y\) is "bottom row times the point". That is the whole rule.
Some machines are famous. The identity \(\begin{pmatrix} 1 & 0 \\ 0 & 1 \end{pmatrix}\) sends every point to itself. The doubler \(\begin{pmatrix} 2 & 0 \\ 0 & 2 \end{pmatrix}\) pushes every point twice as far from the origin (the point \((0, 0)\)). The quarter turn \(\begin{pmatrix} 0 & -1 \\ 1 & 0 \end{pmatrix}\) rotates everything 90° anticlockwise. The mirror \(\begin{pmatrix} 1 & 0 \\ 0 & -1 \end{pmatrix}\) flips the picture over the \(x\)-axis.
And you can chain machines. Running machine \(B\) and then machine \(A\) is the same as running one machine called \(AB\). Surprise: \(AB\) and \(BA\) are usually different machines. Order matters, just as "put on socks, then shoes" is not "put on shoes, then socks".
Watch one: the quarter turn on (3, 1)
Top row \((0, -1)\) times the point: \(0 \times 3 + (-1) \times 1 = -1\). Bottom row \((1, 0)\) times the point: \(1 \times 3 + 0 \times 1 = 3\). So \((3, 1)\) goes to \((-1, 3)\).
Sketch both points. \((3, 1)\) sits low and to the right; \((-1, 3)\) sits high and a little left. It really has been swung a quarter turn anticlockwise around the origin, and it is the same distance away: \(3^2 + 1^2 = 10\) and \((-1)^2 + 3^2 = 10\).
To chain two machines, multiply the matrices. The rule: each entry of the answer is a row of the first times a column of the second, multiplied pair by pair and added. The top-left entry uses the top row of the first and the left column of the second. For the quarter turn \(R\) followed by itself, top-left is \(0 \cdot 0 + (-1) \cdot 1 = -1\). The other three entries work the same way:
\[ RR = \begin{pmatrix} 0 & -1 \\ 1 & 0 \end{pmatrix}\begin{pmatrix} 0 & -1 \\ 1 & 0 \end{pmatrix} = \begin{pmatrix} -1 & 0 \\ 0 & -1 \end{pmatrix} \]Two quarter turns make a half turn, and the half-turn machine sends \((x, y)\) to \((-x, -y)\). The arithmetic agrees with the geometry.
Your turn
Tonight's core: the example and exercises 1 to 3. The rest can wait for another visit.
- Apply the machine \(M = \begin{pmatrix} 2 & 1 \\ 1 & 3 \end{pmatrix}\) to the points \((1, 2)\) and \((-1, 4)\).
- The shear \(\begin{pmatrix} 1 & 1 \\ 0 & 1 \end{pmatrix}\) is what turns a square into a leaning parallelogram. Apply it to the four corners of the unit square: \((0,0), (1,0), (1,1), (0,1)\). Plot the results and join them up.
- Apply the quarter turn \(R\) four times in a row to \((2, 5)\). What do you get, and why did you already know that would happen?
- Let \(R\) be the quarter turn and \(F\) the mirror \(\begin{pmatrix} 1 & 0 \\ 0 & -1 \end{pmatrix}\). Compute \(RF\) and \(FR\). Are they the same machine?
- Take the point \((1, 0)\). Run it through \(F\) first, then \(R\). Now run it through \(R\) first, then \(F\). Which matrix from question 4 matches "F first, then R"? (Careful: the machine that runs first is written on the right.)
- Write down a matrix that stretches everything to three times as wide but leaves heights alone. Then one that rotates by a half turn. Check each on the point \((1, 1)\).
Play with these on screen at mathdetours.com/demos/matrix.html, where you can type any four numbers and watch a picture warp.
Stretch: the Fibonacci machine
Let \(Q = \begin{pmatrix} 1 & 1 \\ 1 & 0 \end{pmatrix}\). Compute \(Q^2 = QQ\) and \(Q^3 = Q^2 Q\) by hand. Look at the four numbers in each answer. Do you recognise them? Predict \(Q^{10}\) without multiplying anything, then explain why the machine behaves this way. (Hint: what does \(Q\) do to the point \((F_{n}, F_{n-1})\)?)
Answers
- \((1,2) \to (2\cdot1 + 1\cdot2,\ 1\cdot1 + 3\cdot2) = (4, 7)\). \((-1, 4) \to (-2 + 4,\ -1 + 12) = (2, 11)\).
- \((0,0)\to(0,0)\), \((1,0)\to(1,0)\), \((1,1)\to(2,1)\), \((0,1)\to(1,1)\). The bottom edge stays put and the top edge slides one unit to the right: a parallelogram leaning right.
- \((2,5)\to(-5,2)\to(-2,-5)\to(5,-2)\to(2,5)\). Four quarter turns is a full turn, so every point comes home. In matrix language \(R^4 = I\).
- \(RF = \begin{pmatrix} 0 & 1 \\ 1 & 0 \end{pmatrix}\) and \(FR = \begin{pmatrix} 0 & -1 \\ -1 & 0 \end{pmatrix}\). Different machines. \(RF\) swaps \(x\) and \(y\) (a mirror in the diagonal line \(y = x\)); \(FR\) is a mirror in the line \(y = -x\).
- \(F\) first: \((1,0)\to(1,0)\), then \(R\): \((1,0)\to(0,1)\). \(R\) first: \((1,0)\to(0,1)\), then \(F\): \((0,1)\to(0,-1)\). "F first, then R" matches \(RF\) (check: \(RF\) sends \((1,0)\) to \((0,1)\)). The first machine to act sits nearest the point, on the right.
- Stretch: \(\begin{pmatrix} 3 & 0 \\ 0 & 1 \end{pmatrix}\), sending \((1,1)\to(3,1)\). Half turn: \(\begin{pmatrix} -1 & 0 \\ 0 & -1 \end{pmatrix}\), sending \((1,1)\to(-1,-1)\).
Stretch. \(Q^2 = \begin{pmatrix} 2 & 1 \\ 1 & 1 \end{pmatrix}\), \(Q^3 = \begin{pmatrix} 3 & 2 \\ 2 & 1 \end{pmatrix}\). The entries are consecutive Fibonacci numbers: \(Q^n = \begin{pmatrix} F_{n+1} & F_n \\ F_n & F_{n-1} \end{pmatrix}\), so \(Q^{10} = \begin{pmatrix} 89 & 55 \\ 55 & 34 \end{pmatrix}\). Why: \(Q\) sends \((F_n, F_{n-1})\) to \((F_n + F_{n-1}, F_n) = (F_{n+1}, F_n)\). It is the "add the last two" rule in matrix form, so each extra power steps the sequence forward once.