# matrices

> a grid of numbers that moves every point by one rule: turns, stretches and shears.

source: https://learning.anthnydas.com/math/matrices/

## tl;dr

a 2 × 2 matrix moves every point of the plane by one rule. its first column is where i = (1, 0) lands and its second is where j = (0, 1) lands, and every other point follows, since (x, y) is x of i plus y of j. straight lines stay straight, the origin stays put.

- **the columns:** Ai, Aj (where i and j land. read a matrix by its columns, not its rows)
- **A(x, y):** x·Ai + y·Aj (x times the first column plus y times the second)
- **AB:** B first, then A (AB and BA are different moves)
- **det A:** ad − bc (the factor every area is scaled by. negative: flipped over. 0: squashed flat)
- **inverse:** [d −b; −c a] / det (swap a and d, negate b and c, divide by det. none when det = 0)
- **turn by θ:** cos θ, sin θ (the columns are i and j turned by θ: (cos θ, sin θ) and (−sin θ, cos θ))
- **reach for it:** turning, stretching and leaning shapes in 2d, and in 3d with one row and column more, the arrows of the vectors page, all moved at once by the same rule, solving linear systems and finding eigenvectors, the next two pages

## the idea

a matrix is a rule for moving every point of the plane at once. a 2 × 2 matrix is four numbers in a grid, and the picture to keep is this: its two columns are where the two unit arrows land. $i = (1, 0)$ goes to the first column and $j = (0, 1)$ to the second. every other point is some amount of $i$ plus some amount of $j$, and it goes where that recipe says.

$$
\begin{gathered}
A = \begin{pmatrix} a & b \\ c & d \end{pmatrix} \\[8pt]
A \begin{pmatrix} x \\ y \end{pmatrix}
= x \begin{pmatrix} a \\ c \end{pmatrix} + y \begin{pmatrix} b \\ d \end{pmatrix} \\[8pt]
= \begin{pmatrix} ax + by \\ cx + dy \end{pmatrix}
\end{gathered}
$$

so a matrix moves the whole grid in one piece: grid lines stay straight, parallel lines stay parallel and evenly spaced, and the origin never moves. what changes is where $i$ and $j$ point. the movie moves the plane one matrix at a time and follows the point $(2, 1)$, which is $2i + j$.

> **interactive figure:** an animation in five chapters on a grid from −3 to 3, with the unit square filled in, an arrow to where i lands in cyan and one to where j lands in amber, the matrix in brackets with its determinant, and the point (2, 1) followed. first the shear \[1 1; 0 1]: i stays at (1, 0), j leans to (1, 1), the grid leans with it, the square becomes a parallelogram of area 1, and (2, 1) lands on (3, 1). second, a quarter turn on top of it: everything turns 90 degrees counter-clockwise, (3, 1) goes to (−1, 3), and the one matrix for both moves is \[0 −1; 1 1]. third, both are undone in the reverse order: the turn back first, then the lean, and the grid is at rest again. fourth, the mirror \[1 0; 0 −1]: j slides down to (0, −1), the square flips over, the determinant goes from 1 through 0 to −1, and (2, 1) lands on (2, −1). fifth, the squash \[1 0; 0 0]: j slides onto the origin, the whole plane lands on the x axis, the determinant is 0, and (2, 1) and (2, −1) both land on (2, 0).

the shear $A = \begin{pmatrix} 1 & 1 \\ 0 & 1 \end{pmatrix}$. its first column is $(1, 0)$, so $i$ stays. its second is $(1, 1)$, so $j$ leans over, and the grid leans with it. the unit square becomes a parallelogram with the same base and height: area 1, and $\det A = 1 \cdot 1 - 1 \cdot 0 = 1$. the point $(2, 1) = 2i + j$ lands on $2 \cdot (1, 0) + (1, 1) = (3, 1)$.

then a second matrix after the first: the quarter turn $B = \begin{pmatrix} 0 & -1 \\ 1 & 0 \end{pmatrix}$, applied to the leaned plane. $(3, 1)$ turns to $(-1, 3)$. the one matrix that does both is $BA = \begin{pmatrix} 0 & -1 \\ 1 & 1 \end{pmatrix}$: its columns are $B$ applied to the columns of $A$, which is where $i$ and $j$ have ended up.

undo it. the turn came last, so it goes first: $B^{-1}$ turns everything back a quarter turn, then $A^{-1}$ unleans the grid. $(BA)^{-1} = A^{-1} B^{-1} = \begin{pmatrix} 1 & 1 \\ -1 & 0 \end{pmatrix}$: the moves undone in the reverse order, and the plane is at rest.

the mirror $F = \begin{pmatrix} 1 & 0 \\ 0 & -1 \end{pmatrix}$: $j$ slides down to $(0, -1)$ and the square flips over. its corners now run clockwise, and the determinant reads $-1$. on the way the square had to go flat for a moment: a signed area can't get from 1 to $-1$ without passing 0. $(2, 1)$ lands on $(2, -1)$.

the squash $P = \begin{pmatrix} 1 & 0 \\ 0 & 0 \end{pmatrix}$: $j$ slides onto the origin and the whole plane lands on the $x$ axis. the square is flat, $\det P = 0$, and $(2, 1)$ and $(2, -1)$ both land on $(2, 0)$. two points in one place: no matrix can send them both back, so $P$ has no inverse.

## explore

set the matrix by hand. the tip of the cyan arrow is the first column and the tip of the amber one is the second, so dragging them is writing the matrix.

> **interactive figure:** a grid from −3 to 3 with the unit square filled in, an arrow to where i lands in cyan and one to where j lands in amber, and the matrix beside it with its first column in cyan and its second in amber. drag either tip, or tab to it and use the arrow keys, half a unit a step, and the grid and the square follow. it opens with i at (2, 0) and j at (1, 1): the matrix \[2 1; 0 1], a stretch and a lean at once, and the square is a parallelogram of area 2. the readout gives the two columns, the rule A(x, y) = x·(2, 0) + y·(1, 1), the determinant worked out, 2·1 − 1·0 = 2, and what it says about the square: its area, and whether it is flipped over or flat. buttons set a preset: rest, a stretch by 2 along x, a turn of 90 degrees, a shear, the mirror that swaps i and j with determinant −1, and a squash with columns (1, 0.5) and (2, 1) that sends every point onto one line, determinant 0.

## try it

> **interactive figure:** a practice exercise with a matrix in brackets and a small grid under it: where the matrix sends a point, which move the matrix is (a stretch, a turn, a shear, a mirror or a squash onto a line), its determinant, or whether it has an inverse. after an answer the grid shows where i and j land, the image of the unit square, and for a point question where the point went.

## the rules

### the columns

$$
\begin{gathered}
A i = \begin{pmatrix} a \\ c \end{pmatrix}, \qquad
A j = \begin{pmatrix} b \\ d \end{pmatrix} \\[8pt]
A(x, y) = x \, A i + y \, A j
\end{gathered}
$$

the first column is where $i$ lands and the second is where $j$ lands. that is the whole matrix: a point is $x$ of $i$ and $y$ of $j$, and a matrix keeps sums and multiples, so its image is $x$ of the first column and $y$ of the second. the derivation is below, in [the key idea up close](#the-key-idea-up-close). to read a matrix, read its columns. $\begin{pmatrix} 2 & 1 \\ 1 & 3 \end{pmatrix}$ sends $i$ to $(2, 1)$ and $j$ to $(1, 3)$, so it sends $(2, 1)$ to $2 \cdot (2, 1) + 1 \cdot (1, 3) = (5, 5)$.

### the moves to know

$$
\begin{gathered}
\text{stretch: } \begin{pmatrix} s_x & 0 \\ 0 & s_y \end{pmatrix} \\[8pt]
\text{turn by } \theta \text{: } \begin{pmatrix} \cos\theta & -\sin\theta \\ \sin\theta & \cos\theta \end{pmatrix} \\[8pt]
\text{shear: } \begin{pmatrix} 1 & k \\ 0 & 1 \end{pmatrix} \\[8pt]
\text{mirror: } \begin{pmatrix} 1 & 0 \\ 0 & -1 \end{pmatrix} \\[8pt]
\text{squash: } \begin{pmatrix} 1 & 0 \\ 0 & 0 \end{pmatrix}
\end{gathered}
$$

each one is its columns. a **stretch** is diagonal: $i$ goes to $(s_x, 0)$ and $j$ to $(0, s_y)$, so each axis is scaled on its own, and the same number twice scales everything evenly. a **turn** by $\theta$ sends $i$ to the point at angle $\theta$ on the unit circle, $(\cos\theta, \sin\theta)$, and $j$ to the point a quarter turn further, $(-\sin\theta, \cos\theta)$: the circle picture from the [trig page](/math/trig/), once for each column. with $\theta = 90°$ it's $\begin{pmatrix} 0 & -1 \\ 1 & 0 \end{pmatrix}$, and $\theta = 180°$ is a stretch by $-1$ both ways. a **shear** leaves $i$ alone and leans $j$ to $(k, 1)$: every point slides sideways by $k$ times its height, so horizontal lines stay where they are and vertical ones tilt. a **mirror** flips the plane over: this one negates $y$, across the $x$ axis. $\begin{pmatrix} -1 & 0 \\ 0 & 1 \end{pmatrix}$ mirrors across the $y$ axis, and $\begin{pmatrix} 0 & 1 \\ 1 & 0 \end{pmatrix}$ swaps $i$ and $j$, a mirror across the line $y = x$. a **squash**, a projection, drops a dimension: this one sends $j$ to the origin, so every point lands on the $x$ axis, at its own $x$. any matrix whose two columns point along one line squashes the plane onto that line.

### one move after another

$$
\begin{gathered}
(AB)\,p = A\,(B\,p) \\[8pt]
AB = \big(\, A\,(Bi) \;\; A\,(Bj) \,\big) \\[8pt]
\begin{pmatrix} a & b \\ c & d \end{pmatrix}
\begin{pmatrix} e & f \\ g & h \end{pmatrix} \\[8pt]
= \begin{pmatrix} ae + bg & af + bh \\ ce + dg & cf + dh \end{pmatrix}
\end{gathered}
$$

$AB$ is the one matrix that does $B$ first and then $A$, read from the right, the way $f(g(x))$ runs $g$ first. its columns come one at a time: the first column of $AB$ is where $i$ ends up after both moves, which is $A$ applied to the first column of $B$, and the second column is $A$ applied to the second column of $B$. the formula is that, written out: each column of $B$ is fed through $A$ with the rule above. entry by entry, the number in row $r$ and column $c$ of $AB$ is row $r$ of $A$ times column $c$ of $B$, matching parts multiplied and added, which is the dot product of the [vectors page](/math/vectors/#the-dot-product).

the order matters. the shear $A$ and the quarter turn $B$ from the movie:

$$
\begin{gathered}
BA = \begin{pmatrix} 0 & -1 \\ 1 & 0 \end{pmatrix}\begin{pmatrix} 1 & 1 \\ 0 & 1 \end{pmatrix} \\[8pt]
= \begin{pmatrix} 0 & -1 \\ 1 & 1 \end{pmatrix} \\[14pt]
AB = \begin{pmatrix} 1 & 1 \\ 0 & 1 \end{pmatrix}\begin{pmatrix} 0 & -1 \\ 1 & 0 \end{pmatrix} \\[8pt]
= \begin{pmatrix} 1 & -1 \\ 1 & 0 \end{pmatrix}
\end{gathered}
$$

lean then turn sends $i$ to $(0, 1)$. turn then lean sends it to $(1, 1)$. two different pictures, so $AB \ne BA$ in general. they agree for some pairs, like two turns, or two stretches, and the [cg fundamentals](/graphics/cg-fundamentals/#transforms) page has a figure of the same thing with a turn and a move.

### the determinant

$$
\det A = \det \begin{pmatrix} a & b \\ c & d \end{pmatrix} = ad - bc
$$

the determinant is the factor every area is multiplied by. the unit square, with corners at $0$, $i$, $i + j$ and $j$, lands on the parallelogram with sides $(a, c)$ and $(b, d)$, and that parallelogram has area $|ad - bc|$: the derivation is below. since the grid is moved evenly, every shape's area is scaled by the same factor, not only the square's. the sign tells you which way round the shape came out. positive, and the corners still run counter-clockwise. negative, and the plane has been flipped over, as by a mirror. zero, and the square has been squashed flat: the two columns point along one line, or one of them is $0$, and all of the plane lands on a line or a point. a turn and a shear have determinant 1, a stretch has $s_x s_y$, a mirror $-1$. doing two moves multiplies the factors: $\det(AB) = \det A \cdot \det B$.

### the inverse and the identity

$$
\begin{gathered}
I = \begin{pmatrix} 1 & 0 \\ 0 & 1 \end{pmatrix}, \qquad A I = I A = A \\[8pt]
A^{-1} = \frac{1}{ad - bc} \begin{pmatrix} d & -b \\ -c & a \end{pmatrix} \\[8pt]
A A^{-1} = A^{-1} A = I \\[8pt]
(AB)^{-1} = B^{-1} A^{-1}
\end{gathered}
$$

the identity $I$ moves nothing: $i$ lands on $i$ and $j$ on $j$. the inverse of $A$ undoes it: whatever $A$ did to a point, $A^{-1}$ sends it back, so one after the other is $I$. for a $2 \times 2$ the recipe is: swap $a$ and $d$, change the signs of $b$ and $c$, and divide by the determinant. multiply it out and the off-diagonal entries cancel to $0$ while the diagonal ones come to $ad - bc$, which the division turns into $1$. the division is why a determinant of $0$ means there is no inverse, and the picture says the same: a squash sends two different points to one place, and no rule can send that one place back to both. undoing two moves goes in the reverse order, the last move first: $(AB)^{-1} = B^{-1} A^{-1}$. a turn's inverse is the turn back, $\theta$ to $-\theta$, which is the same matrix with its rows and columns swapped. a mirror is its own inverse.

## worked examples

**where a point goes.** $M = \begin{pmatrix} 2 & 1 \\ 1 & 3 \end{pmatrix}$ and the point $(2, 1)$. $x$ times the first column plus $y$ times the second: $2 \cdot (2, 1) + 1 \cdot (1, 3) = (4, 2) + (1, 3) = (5, 5)$. the formula agrees: $(2 \cdot 2 + 1 \cdot 1,\ 1 \cdot 2 + 3 \cdot 1) = (5, 5)$.

**a quarter turn.** the turn by $90°$ has $\cos 90° = 0$ and $\sin 90° = 1$, so it is $\begin{pmatrix} 0 & -1 \\ 1 & 0 \end{pmatrix}$: $i$ goes to $(0, 1)$, straight up, and $j$ to $(-1, 0)$. the point $(3, 1)$ goes to $3 \cdot (0, 1) + 1 \cdot (-1, 0) = (-1, 3)$. for $30°$ the entries are $\cos 30° = \sqrt 3 / 2 \approx 0.866$ and $\sin 30° = 1/2$, so $i$ lands on $(0.866, 0.5)$, a point on the unit circle.

**two moves as one.** the shear $A$ and the quarter turn $B$ from the movie. $BA$ column by column: $B$ applied to $A$'s first column, $(1, 0)$, is $(0, 1)$. $B$ applied to the second, $(1, 1)$, is $(-1, 1)$. so $BA = \begin{pmatrix} 0 & -1 \\ 1 & 1 \end{pmatrix}$. check with the point $(2, 1)$: the shear sends it to $(3, 1)$ and the turn sends that to $(-1, 3)$, and $BA$ sends it to $2 \cdot (0, 1) + 1 \cdot (-1, 1) = (-1, 3)$ in one step.

**the determinant.** $\det \begin{pmatrix} 3 & 1 \\ 1 & 2 \end{pmatrix} = 3 \cdot 2 - 1 \cdot 1 = 5$: a shape of area 1 comes out with area 5. for any turn, $\cos^2\theta + \sin^2\theta = 1$, so a turn never changes an area. $\det \begin{pmatrix} 2 & 4 \\ 1 & 2 \end{pmatrix} = 4 - 4 = 0$: the columns $(2, 1)$ and $(4, 2)$ point the same way, and every point lands on that line.

**the inverse.** $M = \begin{pmatrix} 2 & 1 \\ 1 & 3 \end{pmatrix}$ has $\det M = 6 - 1 = 5$. swap the diagonal, negate the rest, divide by 5: $M^{-1} = \frac{1}{5} \begin{pmatrix} 3 & -1 \\ -1 & 2 \end{pmatrix} = \begin{pmatrix} 0.6 & -0.2 \\ -0.2 & 0.4 \end{pmatrix}$. check: $M M^{-1}$ has first column $M (0.6, -0.2) = 0.6 \cdot (2, 1) - 0.2 \cdot (1, 3) = (1, 0)$ and second column $M(-0.2, 0.4) = (0, 1)$: the identity. and $\begin{pmatrix} 2 & 4 \\ 1 & 2 \end{pmatrix}$, with determinant 0, has none: the formula would divide by 0.

**undoing two moves.** $BA$ above has $\det = 0 \cdot 1 - (-1) \cdot 1 = 1$, so $(BA)^{-1} = \begin{pmatrix} 1 & 1 \\ -1 & 0 \end{pmatrix}$. the other way to get it: $B^{-1}$ is the turn back, $\begin{pmatrix} 0 & 1 \\ -1 & 0 \end{pmatrix}$, and $A^{-1}$ is the shear back, $\begin{pmatrix} 1 & -1 \\ 0 & 1 \end{pmatrix}$. $A^{-1} B^{-1}$, turn back then unlean, is $\begin{pmatrix} 1 & 1 \\ -1 & 0 \end{pmatrix}$: the same. it takes $(-1, 3)$ back to $(2, 1)$.

## the key idea up close

### why the columns are where i and j land

a matrix is a rule with two properties: it keeps sums and it keeps multiples. move two arrows and add them, or add them and move the sum, and you land in the same place; stretch an arrow by $k$ and move it, or move it and stretch, the same.

$$
\begin{gathered}
A(p + q) = Ap + Aq \\[6pt]
A(kp) = k\,Ap
\end{gathered}
$$

that is what it means for the grid to move as one piece, with the lines kept straight and evenly spaced. now write any point as its recipe in $i$ and $j$ and move it:

$$
\begin{aligned}
(x, y) &= x\,i + y\,j \\[6pt]
A(x, y) &= A(x\,i) + A(y\,j) \\[6pt]
&= x\,Ai + y\,Aj
\end{aligned}
$$

so the whole move is pinned down by two arrows, $Ai$ and $Aj$: where $i$ lands and where $j$ lands. write those two arrows side by side as columns and you have the matrix. the formula $(ax + by,\ cx + dy)$ is this sum with the columns filled in. the same reasoning in three dimensions gives three columns, where $i$, $j$ and $k$ land, and the $3 \times 3$ and $4 \times 4$ matrices of the [cg fundamentals](/graphics/cg-fundamentals/#vectors--matrices) page read the same way.

### why the area factor is ad − bc

the unit square lands on the parallelogram with sides $(a, c)$ and $(b, d)$. take the case where both columns point into the first quadrant with the first one lower, as in the explore figure's opening matrix. box the parallelogram in the rectangle from the origin to $(a + b, c + d)$, area $(a + b)(c + d)$, and cut away what isn't parallelogram: two $a \times c$ right triangles, two $b \times d$ right triangles, and two $b \times c$ rectangles.

$$
\begin{aligned}
&(a + b)(c + d) - ac - bd - 2bc \\[6pt]
&= ac + ad + bc + bd \\[2pt]
&\qquad - ac - bd - 2bc \\[6pt]
&= ad - bc
\end{aligned}
$$

in the other arrangements the same bookkeeping gives $ad - bc$ or its negative, and the sign records which way round the corners run: negative when the second column sits clockwise of the first, which is the flip. every other shape is scaled by the same factor, because a shape is a sum of small squares of the grid and each one lands on a copy of the same parallelogram.

## pitfalls

- **$AB$ isn't $BA$.** the matrix on the right acts first. lean then turn and turn then lean are different pictures, and in general swapping the order changes every entry. write the product in the order the moves happen, right to left, and check it on $i$: the first column of $AB$ is $A$ applied to the first column of $B$.
- **row times column: the first index is the row.** the entry in row $r$, column $c$ of $AB$ is row $r$ of $A$ against column $c$ of $B$. a matrix written by rows, as on paper, has its columns split across the lines, so where $i$ lands is $(a, c)$, the first number of each row, not $(a, b)$. code often stores the numbers a column at a time instead: css's `matrix(a, b, c, d, tx, ty)` and canvas's `transform(a, b, c, d, e, f)` send $(x, y)$ to $(ax + cy + e,\ bx + dy + f)$, so there $a$ and $b$ are where $i$ lands, and $c$ and $d$ where $j$ lands.[^mdn-canvas] the [cg fundamentals](/graphics/cg-fundamentals/#vectors--matrices) page has the same note for glsl and three.js.
- **a determinant of 0 means no inverse.** the formula divides by it, and the picture says why: the plane has been squashed onto a line, two points share an image, and no rule can send one point back to two. a determinant that's merely tiny isn't 0, but the inverse's entries are huge, and in floating point that's nearly as bad.
- **on a screen, y points down.** the turn by $\theta$ above is counter-clockwise with $y$ pointing up, the way math draws it and the way gl's window coordinates run. a canvas, the dom and css count $y$ downward from the top edge, and the same matrix, with the same $\cos\theta$ and $\sin\theta$ in the same places, then shows up as a clockwise turn: css's `rotate(90deg)` turns an element a quarter turn clockwise, and its matrix is the one above.[^css-transforms][^mdn-rotate] the matrix didn't change, the picture is a mirror image of the math one. so a turn that goes the wrong way is often a sign that $y$ is flipped, not that the matrix is.
- **$(AB)^{-1}$ is $B^{-1} A^{-1}$.** the moves are undone in the reverse order, the last one first, like shoes before socks. $A^{-1} B^{-1}$ undoes $BA$, not $AB$, and the two differ unless $A$ and $B$ happen to commute.
- **a matrix can't move the origin.** $A \cdot (0, 0) = (0, 0)$ for every matrix, so sliding everything over by a fixed amount, a translation, isn't a $2 \times 2$ matrix. graphics gets it by adding a coordinate: the $4 \times 4$ matrices and the $w$ of the [cg fundamentals](/graphics/cg-fundamentals/#transforms) page, where the translation sits in the last column.

## practice

1. $A = \begin{pmatrix} 1 & 2 \\ 3 & 4 \end{pmatrix}$. where does it send $(1, -1)$, and where $(0, 2)$?

   **answer:** $x$ times the first column plus $y$ times the second. $(1, -1) \to 1 \cdot (1, 3) - 1 \cdot (2, 4) = (-1, -1)$. $(0, 2) \to 0 \cdot (1, 3) + 2 \cdot (2, 4) = (4, 8)$: a point on the $y$ axis lands on a multiple of the second column.

2. which move is $\begin{pmatrix} 0 & 1 \\ 1 & 0 \end{pmatrix}$, and which is $\begin{pmatrix} 3 & 0 \\ 0 & 3 \end{pmatrix}$? give each determinant.

   **answer:** the first sends $i$ to $(0, 1)$ and $j$ to $(1, 0)$: they trade places, which is the mirror across the line $y = x$. $\det = 0 \cdot 0 - 1 \cdot 1 = -1$, the flip. the second is diagonal with the same number twice: a stretch by 3 in every direction. $\det = 9$, since a square 3 times as wide and 3 times as tall has 9 times the area.

3. $S = \begin{pmatrix} 2 & 0 \\ 0 & 1 \end{pmatrix}$ stretches $x$ by 2 and $H = \begin{pmatrix} 1 & 1 \\ 0 & 1 \end{pmatrix}$ is the shear. find $SH$ and $HS$, and say what each does to $j$.

   **answer:** $SH$ is $S$ applied to the columns of $H$: $S(1, 0) = (2, 0)$ and $S(1, 1) = (2, 1)$, so $SH = \begin{pmatrix} 2 & 2 \\ 0 & 1 \end{pmatrix}$. $HS$ is $H$ applied to the columns of $S$: $H(2, 0) = (2, 0)$ and $H(0, 1) = (1, 1)$, so $HS = \begin{pmatrix} 2 & 1 \\ 0 & 1 \end{pmatrix}$. lean first and then stretch, and the lean is stretched too: $j$ lands on $(2, 1)$. stretch first and then lean, and $j$ lands on $(1, 1)$, as under the shear alone, since the stretch left $j$ where it was.

4. find the determinant and the inverse of $\begin{pmatrix} 4 & 7 \\ 2 & 6 \end{pmatrix}$, and check the inverse on $i$.

   **answer:** $\det = 4 \cdot 6 - 7 \cdot 2 = 24 - 14 = 10$. swap the diagonal, negate the rest, divide by 10: $\frac{1}{10} \begin{pmatrix} 6 & -7 \\ -2 & 4 \end{pmatrix} = \begin{pmatrix} 0.6 & -0.7 \\ -0.2 & 0.4 \end{pmatrix}$. check: the matrix sends $i$ to $(4, 2)$, and the inverse sends $(4, 2)$ to $4 \cdot (0.6, -0.2) + 2 \cdot (-0.7, 0.4) = (2.4 - 1.4,\ -0.8 + 0.8) = (1, 0)$, which is $i$ again.

5. for which $k$ does $\begin{pmatrix} 2 & k \\ 3 & 6 \end{pmatrix}$ have no inverse? what does the matrix do to the plane then?

   **answer:** no inverse means $\det = 0$: $2 \cdot 6 - 3k = 0$, so $k = 4$. then the columns are $(2, 3)$ and $(4, 6)$, and the second is twice the first: both point along the same line, and every point lands on it. the plane is squashed onto the line through $(2, 3)$, and two different points land in one place, so there is nothing to invert.

6. a triangle has area 5. what is the area of its image under $M = \begin{pmatrix} 2 & 1 \\ 1 & 3 \end{pmatrix}$, and under the quarter turn $\begin{pmatrix} 0 & -1 \\ 1 & 0 \end{pmatrix}$? is either image flipped over?

   **answer:** every area is multiplied by the determinant's size. $\det M = 6 - 1 = 5$, so the image has area $5 \cdot 5 = 25$. the quarter turn has $\det = 0 \cdot 0 - (-1) \cdot 1 = 1$, so its image still has area 5. both determinants are positive, so neither image is flipped: the corners run the same way round as before. a mirror would give $-1$ and a flipped triangle of the same size.

[^mdn-canvas]: mdn's [CanvasRenderingContext2D.transform()](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/transform) page: `transform(a, b, c, d, e, f)` sends a point $(x, y)$ to $(ax + cy + e,\ bx + dy + f)$. with $b$ and $c$ at 0, $a$ and $d$ scale; with $a$ and $d$ at 1, $b$ and $c$ skew; $e$ and $f$ translate.

[^css-transforms]: [css transforms module level 1](https://www.w3.org/TR/css-transforms-1/), section 3, the transform rendering model: the $y$ axis increases vertically downwards. section 9.1, on `rotate()`: `rotate(90deg)` makes an element appear turned a quarter turn clockwise.

[^mdn-rotate]: mdn's [rotate()](https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Values/transform-function/rotate) page: in a left-to-right page a positive angle is a clockwise turn, and the function's matrix is written out with $\cos a$ and $\sin a$ in the same places as the turn above.

## related

- https://learning.anthnydas.com/math/vectors.md
- https://learning.anthnydas.com/math/linear-systems.md
- https://learning.anthnydas.com/math/eigenvectors.md
- https://learning.anthnydas.com/math/trig.md
- https://learning.anthnydas.com/graphics/cg-fundamentals.md
