MathemagiciansLibraryExplorationsDeep Dives
← Mathematics · Upper Secondary
MathematicsUpper Secondary

Inverse functions — undoing a function

U2 — Algebra Advancing › U2.5 — FunctionsLecture 3 of 4~2740 words

Two secret codes, and one of them cannot be read

Ayesha and Tomás send each other coded messages. First they turn each letter into its position in the alphabet: A is 1, B is 2, and so on up to Z, which is 26. Then they put each number through a rule.

Ayesha's rule is "multiply by 3, then subtract 5". Tomás receives four numbers from her: 34, −2, 55, 19. Can he read the message?

He can. He just has to work backwards. The last thing Ayesha did was subtract 5, so Tomás first adds 5 back: 34 becomes 39. Before that, she multiplied by 3, so he divides by 3: 39 becomes 13. The 13th letter is M. Doing the same to the other three numbers gives 1, 20 and 8. The message is MATH.

Now Tomás tries a new rule for his reply: "subtract 13, then square". Ayesha receives the number 121. She works backwards. The last step was squaring, so she takes the square root: 11. Then she adds 13 and gets 24, the letter X.

But Tomás meant B. Check it: B is 2, and , and . The letter X also gives 121, because and . Two different letters give the same code. Nobody can read this message for certain, even with the rule.

So some rules can be run backwards, and some cannot. This lecture is about that difference. It shows how to undo a function, and how to tell in advance whether a function can be undone at all.

Undoing is running the pipeline backwards

The last lecture solved by working backwards through a pipeline, and promised that running a pipeline backwards would be the idea of this lecture. It also promised a pair of functions where the second one exactly undoes the first, so that every input comes back to where it started. Here is that pair.

Write Ayesha's rule as a function: . It is a pipeline of two steps:

To undo it, Tomás did two things. He undid each step with its opposite: adding undoes subtracting, and dividing undoes multiplying. He also did the steps in the reverse order. The step that happened last is the step he undid first.

Think about getting dressed: socks first, then shoes. To undo this, the shoes come off first. The reverse order is not a rule someone invented. It is forced, because the shoes are on the outside.

So the undoing of is "add 5, then divide by 3". As a formula, this is a new function. We call it the inverse of , and we write it :

Check it with a number. . Now put 1 into the inverse: . The 2 came back.

Inverse function

The inverse of , written , is the function that undoes . If , then .

Applying one and then the other returns the input: and .

Read the second line with the last lecture in mind. In , the function acts first and undoes it, so the pipeline changes nothing. This is one of the rare pairs where the order of composition does not matter, because both orders give .

You say as "f inverse of x".

Stop and think

You know from indices that . So with , is the same as ?

Show the answer

No. The on a function name does not mean "one over". It means "the inverse". Work out both. , so . But . The question asks "which input does send to 4?" The answer is 3, because . The notation looks like an index, which is unfortunate. In , the small belongs to the name of the function, not to its output. If a question wants the reciprocal, it writes or , with brackets.

A method that always works: swap, then rearrange

Undoing the steps in reverse works well when you can list the steps. But look at this function:

Here appears twice, once on top and once underneath. There is no single chain of steps to reverse. We need a method that does not depend on seeing the steps.

Start from the meaning. The inverse takes an output and returns the input that made it. So write the output as : for Ayesha's function, . Now ask: if I know , what is ? That is a rearranging problem, the same skill as making a new subject of a formula:

, so , so

This line already is the inverse. It turns an output into the input . There is only one problem: the letters. We always call the input of a function . In this line, the inverse's input is called . So we rename the letters, swapping and :

Most books swap first and rearrange second. The answer is the same, because the swap is only a change of names. The method has three steps.

Do not learn the swap as a trick. Learn what it does. An inverse exchanges the roles of input and output. Swapping the letters is how we write that exchange down.

Now the hard case. This is the hard part of the lecture, so go slowly. When appears in two places, you must bring both to the same side and then take out as a common factor.

Step through — inverting a fraction

Find the inverse of g(x) = (2x + 1)/(x − 3). Press Next to add one line. Read the reason before you go on.

Each line of the working, with the reason it is allowed.

  1. . Write the function with as the output.
  2. . Swap and . Now is the number we want.
  3. . Multiply both sides by to clear the fraction.
  4. . Expand the bracket.
  5. . Collect every term with on the left and every other term on the right.
  6. . Take out as a common factor. Now appears only once.
  7. . Divide both sides by .

So . Check: , and .

Look at what happened there. The sequence was: clear the fraction, expand, collect the terms, factorise, divide. It works for every function of this shape. The factorising step is the one students skip. Without it, stays in two places.

Notice one more thing. The input 2 is not allowed in , because it makes the bottom zero. This means that never gives the output 2. The next lecture, on domain and range, explains why.

The graph of an inverse is a mirror image

If , then the point is on the graph of . The inverse sends back to , so the point is on the graph of . Every point of one graph has a partner on the other, with its two coordinates swapped.

Swapping the coordinates of a point has a picture. It reflects the point in the line , the diagonal line through the origin. The point and the point are mirror images in that line. So the whole graph of is the reflection of the graph of in the line .

x y −2 −2 2 2 4 4 6 6 O P(2, 5) Q(5, 2) y = 2x + 1 y = ½(x − 1) y = x
The graph of (teal) and its inverse (dark). The point is on because . Its mirror image in the dashed line is , on the inverse, because .

Swapping and in the method is this same reflection, done in the algebra.

When there is no inverse

Now return to the code that could not be read. The problem was two inputs with the same output. The function has the same problem: and . If an inverse existed, would have to be 3 and also . But a function must give exactly one output for each input. So has no inverse.

The graph shows this too. Reflect the whole parabola in the line . You get a parabola lying on its side. A vertical line at meets it twice, at heights 3 and . From the first lecture in this topic, a graph that a vertical line meets twice is not the graph of a function.

A vertical line on the reflection is a horizontal line on the original. So you can test the original graph directly.

The horizontal line test

A function has an inverse if every output comes from exactly one input. On the graph, this means that no horizontal line meets the graph more than once.

Explore it below. Choose a function and move the point along its graph. Watch its mirror image, and watch the horizontal line.

Explore — reflecting a graph to find its inverse

Choose a function. Move the input a. The teal point P is (a, f(a)) on the graph of f. The dark point Q is its mirror image in the line y = x. The dashed dark curve is the mirror image of the whole graph. Which functions give a mirror image that is a function?

Five functions and their mirror images in the line y = x.

f(x)InverseWhy
2x + 1½(x − 1)No horizontal line meets the graph twice.
¼x³∛(4x)The graph always rises, so every output comes from one input.
x²nonef(2) = 4 and f(−2) = 4. The line y = 4 meets the graph twice.
x², x ≥ 0√xOnly the right half is kept, so each output comes from one input.
4/x4/xThe graph is its own mirror image in y = x.

The figure shows the fourth row: the right half of the parabola and its mirror image, the square root graph.

x y 1 1 2 2 3 3 4 4 5 5 O (2, 4) (4, 2) y = x², x ≥ 0 y = √x y = x

What should you have seen? For , and , the mirror image is the graph of a function, so each has an inverse. For , the horizontal line meets the graph twice, and the mirror image fails the vertical line test. For , the mirror image is the original graph: the function is its own inverse.

Repairing a function by restricting its inputs

The parabola fails the test because its two halves give the same outputs. So keep only one half. If we only allow inputs that are 0 or more, then each output comes from exactly one input. This version of passes the horizontal line test, and it has an inverse.

Use the method. Write with . Swap: , with . Rearrange: . We take the positive root because must be 0 or more. This is why always means the positive square root. The square root function is the inverse of squaring, restricted to inputs that are 0 or more.

Restricting the inputs is called restricting the domain. Your calculator does this with the button . Many angles have the same sine, so the calculator always chooses its answer from one restricted range of angles.

Stop and think

Is for every number ? Try .

Show the answer

No. , not . Squaring and then taking the square root returns the input only when the input is 0 or more. For negative inputs, it returns the positive number with the same size. This is exactly what restricting the domain means: undoes only on the half where has an inverse. In the other order, is true for every allowed input of .

Worked examples

Worked Example 1 — Find the inverse, then prove it

. Find , and check that and .

Write . Swap: . Rearrange: , so . Therefore .

This matches the reverse-order idea: multiplies by 5 and then adds 2, so the inverse subtracts 2 and then divides by 5.

Check 1: . ✓

Check 2: . ✓

A check with one number is quick, but one number could agree by chance. These algebraic checks prove the inverse is right for every input.

Worked Example 2 — A cube can be undone

. Find .

Write . Swap: . Rearrange: , so . Therefore .

Why does a cube have an inverse when a square does not? Because cubing keeps the sign: but . Different inputs always give different outputs, so every number has exactly one cube root.

Check: , and . ✓

Worked Example 3 — A value of the inverse, without its formula

. Find .

You could find the formula first: . But you do not need it. The question means "which input does send to 10?" So solve : , so and .

Check: . ✓

A value of an inverse is the solution of an equation. When the formula is hard to find, the values can still be found this way.

Worked Example 4 — Restrict, then invert

, for . Find .

Without the restriction, would have no inverse, because . Its graph is a parabola with its lowest point at . The restriction keeps only the right half.

Write , with . Swap: , with . Rearrange: . Take the square root. Since , the number is 0 or more, so we take the positive root: . Therefore .

Check: , and . ✓ The restriction decided the sign of the root. With the left half, , the inverse would be .

Three classic mistakes

Trap 1 — Reading f⁻¹(x) as 1/f(x)

The in is part of the function's name. With , , but . Ask "which input gives 4?", not "what is one over the output?"

Trap 2 — Undoing the steps in the same order

multiplies by 3 and then subtracts 5. Undoing in the same order, "divide by 3, then add 5", gives , which is wrong. Test it: , but , not 2. The last step done is the first step undone, so the inverse is .

Trap 3 — Inverting a function that has no inverse

Before you find an inverse, check that each output comes from only one input. for all numbers has no inverse, because 3 and both give 9. The method of swapping and rearranging will still give , but that is two answers, not a function. Restrict the domain first, and let the restriction choose the sign.

Try it yourself

Work each one on paper first. Open a hint only when you are stuck.

  1. . Find , and check your answer with .

    Hint 1

    Write , then swap and .

    Hint 2

    From , add to both sides and subtract : .

    Full answer

    , so and . So . Check: , and . ✓ A second check with a negative input: , and . ✓

  2. , for . Find . What do you notice?

    Hint 1

    After swapping, multiply both sides by , then collect the terms on one side.

    Hint 2

    You should reach . Take out as a common factor.

    Full answer

    Swap: . Multiply: . Collect: . Factorise: . Divide: . So , which is itself. The function is its own inverse. Check: , and . ✓ Applying twice brings 3 back. Its graph is its own mirror image in .

  3. and . Find and its inverse. Then find and . Which one equals the inverse of ? Explain why, using the socks and shoes.

    Hint 1

    . Find its inverse with the three-step method.

    Hint 2

    and . In , the function acts first.

    Full answer

    . Swap and rearrange: , so and the inverse of is . Next, . This is the same. But , which is different. The reason: in , acts first (socks) and second (shoes). To undo, take off the shoes first: acts first, then . Check with numbers: , and . ✓ But , not 2.

  4. The function changes a temperature in degrees Celsius into degrees Fahrenheit. Find , and use it to convert 212 °F. Then find the one temperature that has the same number on both scales. Explain why the graphs of and cross at that temperature.

    Hint 1

    multiplies by 1.8 and then adds 32. Undo the steps in reverse order.

    Hint 2

    "The same number on both scales" means . Solve .

    Full answer

    Undo in reverse: subtract 32, then divide by 1.8. So . For 212 °F: °C, the boiling point of water. ✓ Next, gives , so . Check: . ✓ So −40 °C is the same temperature as −40 °F. The graph of meets the line at , because there the output equals the input. A point on the mirror line is its own reflection, so is on the graph of too. That is where the two graphs cross.

The bigger idea

Much of mathematics is the search for the inverse of an operation. Subtraction undoes addition. Division undoes multiplication. Square roots undo squares. Later in this course, logarithms appear as the inverse of powers: if , the logarithm is the function that gives back . Each new inverse lets you solve a new kind of equation, because solving an equation is undoing what was done to the unknown.

The codes in the hook show why this matters outside mathematics. A good code must be easy to undo for the person who should read it. Some modern codes are built so that the forward function is quick, while the inverse is extremely slow to find without a secret piece of information.

Key concepts in this lesson