Advanced Placement
Skip to the notes

AP Precalculus

Topic 2.8: Inverse Functions

Watch now19 min

Updated · For the May 2027 AP exam

Inverse functions: reversing input-output pairs, reflecting over y = x, restricting domains and solving for the inverse. Learn the flaw that let codebreakers read Enigma, and break a message yourself.

Topic 2.8 key terms

inverse function
The function f−1f^{-1} that maps each output of ff back to its input: if f(a)=bf(a)=b, then f−1(b)=af^{-1}(b)=a. The −1-1 is part of the name, not an exponent: f−1(x)≠1f(x)f^{-1}(x)\neq\frac{1}{f(x)}.
reflection over y = x
The graph of f−1f^{-1} is the graph of ff with the roles of the axes reversed: each point (a,b)(a,b) becomes (b,a)(b,a), the reflection over the line y=xy=x.
one-to-one (invertible)
On a given domain, ff is invertible if each output value comes from exactly one input value.
restricting the domain
Keeping only part of a function's domain so that it becomes one-to-one; it can usually be done in many ways (e.g. x2x^2 on x≥0x\ge0 has inverse x\sqrt{x}, on x≤0x\le0 it has inverse −x-\sqrt{x}).
horizontal line test
If some horizontal line meets the graph of ff more than once, ff is not one-to-one on that domain and has no inverse function there: after the reflection that line would be a vertical line meeting the graph twice.
identity function
h(x)=xh(x)=x. A function composed with its inverse in either order is the identity: f(f−1(x))=f−1(f(x))=xf(f^{-1}(x))=f^{-1}(f(x))=x.
contextual restriction
In a real situation the context can limit where an inverse applies: the skid rule s=20ds=\sqrt{20d} needs s≥0s\ge0, a full skid on a dry road, and speeds up to about 70 mph, where the rule was built.

Transcript

2,500 words · 8 parts

The message with no L

During the Second World War, messages like this one arrived every night at Bletchley Park, a country house northwest of London where thousands of people worked in secret to break enemy codes. This one came from the Italian navy, and if you count its letters, something strange happens, because every letter of the alphabet keeps turning up except one. There isn’t a single L anywhere in it.

A young codebreaker named Mavis Lever, who had joined Bletchley at nineteen, spotted that missing L, and from that one missing letter she guessed what the whole message said. It said L. L. L. L. L, over and over. She guessed that an operator, told to send a test message, had just pressed the last key on the keyboard, L, again and again.

That sounds completely backwards, a message with no L’s turning out to be nothing but L’s. By the end of this lesson you’ll know exactly why it had to be that way, and you’ll use the same flaw to break an Enigma message yourself. And that flaw hides inside the one idea this lesson is about, running a function backwards, so let’s see what this machine does when you press a single key.

The same wire, backwards

This is an Enigma, the German military’s code machine, and the Italian navy used a version of it too. You press a key, like A, a lamp lights up, B, and the operator writes that letter down. Press A again, and this time it’s D, because this wheel, the rotor, clicked forward a step, and every click makes the machine a different code.

So let’s lock the rotors where they were for that first A, and keep the machine one fixed code. Now every key lights exactly one lamp, which makes it a function, with the key as the input and the lamp as the output. Let’s look inside. When I press A, a current runs from the key through three scrambled wheels, bounces off a plate at the far end, and comes back through the same wheels on different wires, up to the lamp for B.

Now think about the person who receives that B. They want their A back, so what should they press? Try it yourself. Press any letter you like, then press whichever letter lights up, and see what you get.

Watch the wire when I press B. The current runs along the exact same path in the other direction, and it lights A. So to decode, you don’t need a different machine, you need the same wire, traveled backwards.

That’s exactly what an inverse function does. If a function f takes a to b, its inverse takes b right back to a. In symbols, f of a equals b exactly when f inverse of b equals a. That little negative one is part of the name, it doesn’t mean one over f, since nobody decodes a message by dividing one by the machine.

In a table it’s even easier to see. Here’s a function that turns Celsius into Fahrenheit, so zero goes to thirty-two, ten to fifty, and a hundred to two hundred twelve. To get the inverse, swap the two columns, and now it turns Fahrenheit back into Celsius. The outputs of f became the inputs of the inverse, so the domain and the range just trade jobs.

Here’s a different function, g, given by a table, and this exact kind of question shows up on the AP exam. What is g inverse of negative three?

The graph of a code

Back to the machine. There’s a way to see a whole code at once. Let’s lift the lamps off the machine into a big grid. The keys along the bottom are the inputs, and the lamps up the side are the outputs. Every time I press a key, one bulb lights where its column meets its lamp’s row, and after all twenty-six keys we have the whole code in one picture, its graph, with letters instead of numbers.

Every column has exactly one lit bulb, which makes it a function, and every row has exactly one too. Now look along this diagonal, where a key would light its own lamp, A to A, B to B, up to Z. It’s completely dark, because the way the current bounces back means a letter can never come out as itself.

So think about that test message. The operator presses L hundreds of times, every L comes out as some other letter, and the one letter that can never appear is L. A long message with no L’s in it is exactly what a message made of L’s looks like.

There’s one more thing hiding in this picture, and I love this part. Let’s turn the whole grid over, a half-turn around that dark diagonal. Halfway, it’s standing straight up, and when it lands, every lit bulb comes down exactly on another lit bulb.

Turning it over swaps every bulb’s two coordinates, so the bulb at A across and B up lands at B across and A up, and pressing B to get A back is exactly what the decoder does. That makes the flipped grid the graph of the decoder, and Enigma’s lands on itself because Enigma is its own decoder.

Here’s a much older code, the one Julius Caesar used, where every letter moves three places forward, so A becomes D and B becomes E. If we turn this grid over its diagonal, what do you think it will land on?

Watch it turn, and this time the bulbs land on empty spots, three steps below the diagonal instead of three above, and that’s Caesar’s decoder, shift every letter three places back. Now swap the letters for numbers, A is zero, B is one, up to Z, twenty-five, and forget the wrap at the end. Caesar’s code is just x plus three, and turned over the diagonal, it lands on x minus three, its decoder.

On graph paper that diagonal is the line y equals x, and turning a graph over it is the same as reflecting it in that line. It’s like flipping the page over along that line and holding it up to a light. Take one point, say two, five. The reflection sends it to five, two, straight across the mirror, so every point a, b of f becomes b, a on its inverse. So, for any function, the graph of f inverse is the graph of f reflected over the line y equals x.

When you can’t go back

Not every code can be decoded, though. Here’s one a careless spy might invent, which doubles each letter’s number, so B, which is one, becomes C, which is two, and past Z it wraps back round to A.

Send the word hero, and you get O, I, I, C. Send herb, and you get… O, I, I, C. Whoever receives it can’t tell which word you meant. On the grid, every lit row has two bulbs, two different keys lighting the same lamp. Turn it over, and those pairs land in the same column, one input with two outputs, which isn’t a function at all, so this code has no inverse.

But you can still rescue this code. Switch off letters until no lamp is lit by two keys, and keep as many letters as you can.

Some people keep A through M, some keep N through Z, some keep a mix, and every one of those works. That’s restricting the domain, keeping only some inputs so the function can be undone, and there’s usually more than one way to do it.

So a function has an inverse only when every output comes from exactly one input, and then we call it one-to-one. If it isn’t, you restrict the domain until it is. It’s also why a well-built website can’t tell you your own password. It only keeps a scrambled version, made by a function built to run one way only, where endless different passwords share outputs, so there’s no way back, even for the site.

The marks on the road

Now let’s take all this out onto a real road, one you might remember from lesson one point three. A car locked its brakes here just before the rain started and left these skid marks, and the driver swears, I was only doing thirty. The marks measure a hundred twenty-five feet. So was the driver telling the truth?

Here’s a car really doing thirty. It locks its brakes at the same spot and stops after forty-five feet, nowhere near the end of those marks. The braking distances in lesson one point three came from one rule, the speed squared, divided by twenty, so thirty gives forty-five feet. That rule takes a speed and gives a distance, but we have the distance, so we need it to run backwards.

Let’s draw it. As a pure formula it would happily take negative speeds too, and then fifty and negative fifty both give a hundred twenty-five feet. Flip the whole thing anyway, and that horizontal line becomes a vertical line that hits the flipped graph twice, one input with two outputs.

That’s the horizontal line test, because whenever a horizontal line hits a graph twice, its flip can’t be a function, so the function has no inverse. But the road settles it, because a speed can’t be negative, so we restrict the domain and keep only the right half. Flip that half over y equals x, and we get the inverse, which takes a distance and gives back a speed.

In algebra it’s the same story. Multiply both sides by twenty, take the square root, which gives plus or minus, and the road keeps the plus. For our skid, twenty times a hundred twenty-five is two thousand five hundred, and its square root is fifty. The car was doing fifty, not thirty, and less than twice the speed left almost three times the skid, because the rule squares the speed.

The context limits this inverse in one more way. It only works for a full skid to a stop on a dry road, and only near the speeds the rule was built from, up to about seventy miles an hour. So when five hundred sixty feet of marks gives about a hundred six miles an hour, we’re past anything the rule was built from, outside the model.

This is exactly the kind of context question the exam loves. Using this skid rule, what does d inverse of eighty equals forty mean?

Undo it

Now the algebra. It starts with something you do every day. You put on your socks and then your shoes, and to undo it, you take off your shoes first, then your socks. The Enigma’s current did the same, in through the right, middle and left rotors, and back out left, middle, right. To undo a list of steps, undo each step in reverse order.

Take f of x equals three x plus five, which triples a number and then adds five. To undo it we subtract five first, then divide by three, so f inverse of x is x minus five, over three.

There’s a second way, and it’s the one you’ll use most on the exam. Write y equals three x plus five, swap the x and the y, and solve for y again. Take away five, then divide by three. Same answer, because swapping x and y is the flip over y equals x, just written in algebra.

And here’s where that negative one catches people. f inverse of two is two minus five, over three, which is negative one, but one over f of two is one eleventh. Not even close. Now run a number through both. Four goes into f and comes out seventeen, and f inverse takes seventeen back to four.

In fact f of f inverse of x is always x, because times three and divide by three cancel, and so do plus five and minus five, and f inverse of f of x is x too, which we call the identity. So if someone asks for f inverse of f of five hundred twelve point five, put the calculator away, it’s five hundred twelve point five.

Now a rational one, the kind the exam asks for all the time. f of x equals two x plus one, over x minus three. Swap x and y, and multiply both sides by y minus three to clear the fraction. Distributing the x gives x y minus three x equals two y plus one.

Here’s where most people get stuck, because the letter y now shows up in two different places. What’s the best next move? Now the y comes out as a factor, y times x minus two, and dividing by x minus two leaves y equals three x plus one, over x minus two, which is f inverse.

Look at the graphs. f has a vertical asymptote at x equals three and a horizontal one at y equals two, and when we reflect it over y equals x, the asymptotes trade places, to x equals two and y equals three. That’s the domain and range trading jobs again, because f never takes in a three and never puts out a two, so its inverse never takes in a two and never puts out a three.

Break it yourself

So let’s go back to Bletchley and break one. Here’s the first line of an intercept, and messages like this often carried a weather report, so somewhere in it is probably the German word for weather, Wetter.

The trick is knowing where the guess can’t go. Put it at the start, and this E lands on top of an E. That would mean E turned into itself, so the guess can’t sit there. Now you try it. Slide the word along the message and find the one place where it can fit.

That was step one. Step two happened overnight, in huts across the yard, where a machine called the bombe tested settings against a guess like yours. So set the machine to the settings the bombe found. Type the gibberish back in. And out comes the message.

It’s a storm warning, sent to a weather station in the north. The machine decoded it by running its own wires backwards, and it was beaten by its blind spot, the empty diagonal.

Inverse functions on one board

So here’s the whole lesson. An inverse runs every pair backwards, so a table just swaps its columns. Its graph is f reflected over y equals x, and it only exists when f is one-to-one, so sometimes you restrict the domain. To find it, undo the steps in reverse, or swap x and y and solve. f of f inverse of x is always x, and the context decides which inputs make sense.

So the next time someone tells you a message with no L’s was made of nothing but L’s, you’ll know exactly why. Next, we’ll meet the most important inverse in this course, the logarithm, which undoes an exponential.

Unit 2: Exponential and Logarithmic Functions

  1. 2.1Change in Arithmetic and Geometric Sequences
  2. 2.2Change in Linear and Exponential Functions
  3. 2.3Exponential Functions
  4. 2.4Exponential Function Manipulation
  5. 2.5Exponential Function Context and Data Modeling
  6. 2.6Competing Function Model Validation
  7. 2.7Composition of Functions
  8. 2.8Inverse Functions
  9. 2.9Logarithmic Expressions
  10. 2.10Inverses of Exponential Functions
  11. 2.11Logarithmic Functions
  12. 2.12Logarithmic Function Manipulation
  13. 2.13Exponential and Logarithmic Equations and Inequalities
  14. 2.14Logarithmic Function Context and Data Modeling
  15. 2.15Semi-log Plots