Advanced Placement
Skip to the notes

AP Precalculus

Topic 4.13: Matrices as Functions

Watch now21 min

Updated · For the May 2027 AP exam

Matrices as functions: the columns show where î and ĵ land, with rotations, area scaling, composition and inverses. Guide a video-game explorer through gates that turn and stretch them, then find the one gate that sets everything back.

Topic 4.13 key terms

matrix of a linear transformation
The 2 × 2 matrix whose first column is where the transformation sends î = ⟨1, 0⟩ and whose second column is where it sends ĵ = ⟨0, 1⟩. The rule ⟨x, y⟩ ↦ ⟨a₁₁x + a₁₂y, a₂₁x + a₂₂y⟩ goes with [[a₁₁, a₁₂], [a₂₁, a₂₂]].
rotation matrix
[[cos θ, −sin θ], [sin θ, cos θ]] turns every vector by θ counterclockwise about the origin; column 1 is (cos θ, sin θ), column 2 is (−sin θ, cos θ).
determinant as an area factor
A transformation with matrix A multiplies the area of every region by |det A|. A negative determinant means the picture is flipped (its orientation reverses); a determinant of 0 flattens the plane onto a line or a point.
composition of linear transformations
Doing A and then B is the linear transformation v ↦ B(Av) = (BA)v: its matrix is the product BA, with the first transformation on the right. In general BA ≠ AB.
inverse transformation
Two linear transformations are inverses when doing one and then the other sends every vector to itself. The inverse of v ↦ Av is v ↦ A⁻¹v, which exists exactly when det A ≠ 0; for two steps, undo the last one first: (BA)⁻¹ = A⁻¹B⁻¹.

Transcript

2,640 words · 7 parts

The noodle

This little explorer with the lantern is a drawing, and like the characters in a lot of video games, that drawing is really just a list of points. When our explorer lands, the game moves every one of those points with a tiny grid of numbers that squashes the drawing, and when they turn around, a different grid of numbers flips it, every single frame. In this level, the gates do it to you. The first one turns you a quarter turn, and the second one stretches you sideways.

Which is how you end up like this. But send a second explorer through the very same two gates in the other order, the stretch first and then the turn. Same gates, so you’d expect the same noodle, right?

Same two gates, and a completely different hero. By the end of this lesson, you’ll be able to read the four numbers on any gate and know exactly what it will do to you, and then you’ll build this last gate yourself, the one that puts our explorer back together, exactly the way they were. So let’s start with the move every character makes a hundred times a level, turning around.

Two arrows

Let’s step inside this gate and switch on its grid. Now we see our explorer the way the game does: points on a plane, with the origin at their middle. These two arrows go one step to the right and one step up. We call them i-hat and j-hat.

Every point of the drawing is some number of i-hats plus some number of j-hats, and the lantern is the easiest point of all, because it’s exactly one of each. Now let’s turn around and keep our eyes on just the two arrows. I-hat flips over and points left, and j-hat doesn’t move at all.

If we write down where they landed, i-hat’s new spot, negative one, zero, as the first column and j-hat’s spot, zero, one, as the second, we get four numbers, and those four numbers are this gate. Those two arrows are all we need, and the lantern shows why. It was one i-hat plus one j-hat, so now it has to be one new i-hat plus one new j-hat, negative one, one, and that’s exactly where it is.

Now let’s try a much stranger gate. This one sends i-hat to two, one and j-hat to one, two, and the whole drawing has to follow. And the lantern, one of each, goes to two, one plus one, two, which is three, three, and there it is. Let’s write this gate down. It sends i-hat to two, one and j-hat to one, two.

And any point x, y is x copies of i-hat plus y copies of j-hat, so after the gate, it becomes x copies of two, one plus y copies of one, two. Add those up and you get the gate’s rule, two x plus y across, and x plus two y up. Now look at its matrix. The first column is two, one, exactly where i-hat landed, and the second column is one, two, exactly where j-hat landed.

A gate like this is what we called a linear transformation back in four point twelve, and every one of them works this way. The numbers in front of x and y in the rule sit in the matrix in the same places, so the top line of the rule becomes the top row.

Let’s send the point two, one through our strange gate. That’s two copies of the first column plus one copy of the second, which is five, four, and row times column, the way we did it in four point ten, gives the same five and four. Going the other way is just as easy. The rule three x minus y, two y gives three, negative one on top and zero, two on the bottom, and that zero is there because the second line has no x.

So be careful with rows and columns. A row is the recipe for one output, and a column is where one arrow lands, so this gate sends i-hat to three, zero, not to three, negative one. Now try one yourself, with a gate whose rule is x plus two y, three x. Which matrix goes with it?

Back inside the gate, remember how our explorer landed after that jump, squashed down to twice as wide and half as tall? Here’s a ghost of that squash. Drag the two arrows to build the gate that makes it, and watch the whole explorer follow until they fit the ghost.

Any angle

This next gate spins you a quarter turn counterclockwise, so before it fires, think about where the two arrows are going to end up. I-hat swings up to zero, one, and j-hat swings over to point left, at negative one, zero. So the first column is zero, one, and the second column is negative one, zero, and that negative one is there because j-hat ended up pointing left. Now let’s turn by any angle, say thirty degrees. Both arrows turn together, and i-hat’s tip slides around a circle of radius one.

A point on that circle at angle theta is cosine theta, sine theta, just like on the unit circle back in Unit 3, so after a turn through theta, i-hat lands at cosine theta, sine theta, and that’s the first column. J-hat always stays a quarter turn ahead of i-hat, and the spin gate we just met sends any point a, b to negative b, a.

So we take i-hat’s landing spot, cosine theta, sine theta, and give it one more quarter turn, and j-hat lands at negative sine theta, cosine theta, which is why the minus sign sits on the sine. Put those side by side and you get the rotation matrix, cosine theta and negative sine theta on top, sine theta and cosine theta on the bottom, and it turns every point of the plane by theta, counterclockwise around the origin.

Let’s check it with ninety degrees. Cosine of ninety is zero and sine of ninety is one, so we get zero, negative one, one, zero, which is exactly the spin gate. Now see if you can do sixty degrees yourself, with the two values on the board. Which matrix turns every vector sixty degrees counterclockwise?

How much bigger?

Let’s light up the little square between the two arrows, from the explorer’s middle out to the lantern, and since its sides are one, its area is one. This gate is a power-up that makes the explorer twice as tall and twice as wide, so the square becomes two by two, and its area is four, not two. The landing squash makes it twice as wide but half as tall, so the area stays at exactly one, and animators do that on purpose, because in a flat drawing, keeping the area the same is what stops the character from looking like they grew or shrank.

Here’s the lean a game might use when our explorer runs really fast. The square tips over and one side even gets longer, but it keeps the same base and the same height, so its area is still one. And when the explorer turns around, the area is one again, but the square comes out inside out, because i-hat now points left, so the corners go around the other way.

Now let’s work out each gate’s determinant, a d minus b c, the way we did in four point eleven. For the power-up, a d minus b c is two times two, minus zero. That’s four. The squash gives two times one half: one. The lean gives one times one, minus one times zero: one again. Turning around gives negative one.

The area is always the size of the determinant. Its sign tells you whether the picture flipped. And that’s true for every region, not just the little square, because every square of the grid turns into the same parallelogram, so the area of the explorer’s whole drawing gets multiplied by the absolute value of the determinant.

Let’s test it on the strange gate from before, two, one, one, two. Its determinant is two times two minus one times one, which is three. And the square really does become a parallelogram of area three, because a three by three box around it, minus six corner pieces of area one each, four triangles and two little squares, leaves nine minus six, which is three.

A gate like one, two, three, four has determinant four minus six, negative two, so it doubles every area and flips the picture. And a gate that makes everything three times as wide and three times as tall has determinant nine, not three.

Now I’ve got a puzzle for you. What positive number k on the diagonal of this gate makes the explorer exactly twice the area, without changing their shape? Give it to two decimal places.

Two gates, one gate

Now let’s go back to the noodle and figure out what really happened to it, by riding along with the two arrows. The first gate turns everything a quarter turn, so i-hat now points up, at zero, one, and j-hat points left, at negative one, zero. Then the stretch gate doubles everything sideways. I-hat is pointing straight up, so it doesn’t change at all, but j-hat is pointing sideways, so it doubles to negative two, zero.

So after both gates, i-hat ended up at zero, one and j-hat at negative two, zero, and that means the two gates together act like one single gate, with those two spots as its columns. Watch what happens when a single gate carries those four numbers. It does the whole job in one step and lands exactly on our noodle.

Call the turn R and the stretch D. A point v goes through R first and becomes R v, and then D acts on that, giving D of R v. That’s the single matrix D R times v, with R written on the right, next to v, because R happens first, so we read the gates from right to left.

Multiply D times R, row times column, and you get zero, negative two, one, zero, exactly the columns our arrows gave us. Now swap the order. R times D, the stretch first and then the turn, gives zero, negative one, two, zero, and that’s the chunky explorer.

Both have determinant two, so both explorers cover twice the area, but they’re different shapes, which means the order of the gates really does matter. Two gates can always be squeezed into one, because every point is still some i-hats plus some j-hats, so it follows the two arrows through both gates, and the combination is a linear transformation with its own matrix.

Let’s try one in the game. These two moves flip the explorer and then spin them a quarter turn, and here’s where they end up, as a ghost. Build a single gate that does both steps at once, by dragging the two arrows to where they end up after the flip and the spin.

Let’s turn the explorer thirty degrees, and then sixty more. I-hat lands on zero, one. Thirty plus sixty is ninety, one quarter turn. Any two turns add up like that. A turn by beta, then a turn by alpha, is one turn by alpha plus beta. That simple fact hides something you learned in three point twelve.

After thirty degrees, i-hat sits at root three over two, one half. Then it goes through the sixty-degree gate you picked in the check. That gate takes root three over two copies of its first column, plus one half copy of its second. Across, root three over four minus root three over four is zero. Up, three quarters plus one quarter is one. That’s zero, one, the quarter turn we just watched.

Now the same steps with letters. After a turn by beta, i-hat sits at cosine beta, sine beta. The alpha gate takes cosine beta copies of its first column, plus sine beta copies of its second. Across, that’s cosine alpha cosine beta, minus sine alpha sine beta. Up, it’s sine alpha cosine beta, plus cosine alpha sine beta.

One turn by alpha plus beta sends i-hat to cosine of alpha plus beta, sine of alpha plus beta. That’s the same landing spot, so the entries have to match. The cosine of alpha plus beta is cosine alpha cosine beta minus sine alpha sine beta. The sine of alpha plus beta is sine alpha cosine beta plus cosine alpha sine beta. Those are the identities from three point twelve, and two turns just remembered them for you.

The undo gate

So how do you undo a gate? If the stretch gate doubled everything sideways, the undo gate has to squeeze everything sideways by a half. And now both arrows are back home, at one, zero and zero, one, and when both arrows are home, every single point of the drawing is home too.

One arrow isn’t enough, though. This gate leaves i-hat exactly where it was, but it stretches j-hat to twice its length, so one arrow home doesn’t mean the whole explorer is home. And some gates can’t be undone at all. This crusher flattens everything onto a line, so the lantern and the tip of i-hat land on the very same spot, one, zero, and no gate could ever tell which was which.

The crusher’s determinant is one times zero minus zero times zero, which is zero, so it squashes every area down to nothing, and a determinant of zero always means the gate can’t be undone. In general, two transformations undo each other when doing one and then the other, in either order, sends every vector back to where it started. If a gate is the matrix A, its undo gate is A inverse, the matrix you learned to find in four point eleven.

Let’s fix the chunky explorer. Their gate R D is zero, negative one, two, zero, and its determinant is zero times zero minus negative one times two, which is two. Swap the two diagonal entries, change the signs of the other two, and divide by the determinant, and you get zero, one half, negative one, zero.

Let’s check it on the lantern at negative one, two. Zero times negative one plus one half times two is one, and negative one times negative one plus zero is one, so the lantern is home at one, one.

There’s another way to see that answer. The chunky explorer got the stretch first and the turn second, so you undo the turn first and then the stretch, the way you take off your shoes before your socks. In matrices that’s D inverse times R inverse, with R inverse on the right because it happens first, and it multiplies out to the very same matrix.

Put them back together

And now it’s your turn to keep the promise. The noodle went through the turn first and then the stretch, which made the single gate zero, negative two, one, zero. Build the gate that puts our explorer back together. Type its four numbers into the slots, and the gate will run whatever you build.

And there they are, back in one piece. So a matrix is a function that moves every point of the plane at once, and its columns tell you where i-hat and j-hat land. The size of its determinant tells you how much every area gets multiplied by.

Two gates in a row are one gate, their product, with the first gate on the right, and the gate that undoes a matrix is its inverse, which exists exactly when the determinant isn’t zero. And the next time a character in a game turns around, you’ll know exactly which four numbers just flipped them.

Unit 4: Functions Involving Parameters, Vectors, and Matrices

  1. 4.1Parametric Functions
  2. 4.2Parametric Functions Modeling Planar Motion
  3. 4.3Parametric Functions and Rates of Change
  4. 4.4Parametrically Defined Circles and Lines
  5. 4.5Implicitly Defined Functions
  6. 4.6Conic Sections
  7. 4.7Parametrization of Implicitly Defined Functions
  8. 4.8Vectors
  9. 4.9Vector-Valued Functions
  10. 4.10Matrices
  11. 4.11The Inverse and Determinant of a Matrix
  12. 4.12Linear Transformations and Matrices
  13. 4.13Matrices as Functions
  14. 4.14Matrices Modeling Contexts