Inverse Functions
Every function is a journey. You feed in an input, the function marches it
through its steps, and out comes an output. The inverse function, written
f^{-1}, is the journey home: it takes the output and
walks it back, step by step, to exactly the input you started with.
f^{-1}\bigl(f(x)\bigr) = x
You already use inverse pairs every day. Wrap a gift — the inverse is unwrapping it. Convert
a temperature from °C to °F — the inverse converts it back from °F to °C. Encrypt a message —
the inverse decrypts it. Put on your socks, then your shoes — the inverse takes off your
shoes, then your socks, undoing each step in reverse order. Whatever
f did, f^{-1} undoes it exactly. It is
the opposite idea to
composing functions,
where you chain steps forward: here we run the chain backward.
In fact, "undoes it exactly" has a tidy composite-function meaning:
f^{-1} \circ f is the do-nothing function. Go out, come home, and
you are standing where you began.
Undoing the steps
Suppose f(x) = 2x + 1. As a machine, it does two things to its
input, in order:
- double it,
- then add 1.
To undo the journey, reverse each step, in reverse order —
just like the shoes and socks:
- subtract 1 (undoing the "add 1"),
- then halve (undoing the "double").
f^{-1}(x) = \frac{x - 1}{2}.
Check it: f(3) = 2(3) + 1 = 7, and
f^{-1}(7) = \frac{7 - 1}{2} = 3. We are right back where we
started. Notice the order mattered: "halve, then subtract 1" would give
\tfrac{7}{2} - 1 = 2.5 — not home at all.
The swap-and-rearrange ritual
Reversing the steps in your head works for simple functions, but for anything gnarlier there
is a reliable ritual that always works:
- Write y = f(x).
- Swap x and y —
this captures the whole idea in one move: input and output trade places.
- Solve for y (this is just
rearranging the formula).
- That y is f^{-1}(x).
Worked example. Find the inverse of f(x) = 3x + 2.
y = 3x + 2 \quad\xrightarrow{\text{swap}}\quad x = 3y + 2
x - 2 = 3y \quad\Longrightarrow\quad y = \frac{x - 2}{3} \quad\Longrightarrow\quad f^{-1}(x) = \frac{x - 2}{3}.
Now verify it really is the journey home. Send 5
out and bring it back:
f(5) = 3(5) + 2 = 17, \qquad f^{-1}(17) = \frac{17 - 2}{3} = \frac{15}{3} = 5.
So f^{-1}\bigl(f(5)\bigr) = 5. Always do this check in an exam —
it takes ten seconds and catches almost every slip.
If f has an inverse f^{-1}, then:
- f^{-1}\bigl(f(x)\bigr) = x for every x in the domain of f;
- f\bigl(f^{-1}(x)\bigr) = x for every x in the domain of f^{-1};
- the domain of f^{-1} is the range of f, and its range is the domain of f;
- only one-to-one functions (each output produced by exactly one input) have an inverse.
A harder one: a fraction
The ritual shines when the steps are too tangled to reverse in your head. Find the inverse of
f(x) = \frac{2}{x - 3} \qquad (x \neq 3).
Write y = \frac{2}{x-3}, swap, and solve:
x = \frac{2}{y - 3} \quad\Longrightarrow\quad x(y - 3) = 2 \quad\Longrightarrow\quad y - 3 = \frac{2}{x} \quad\Longrightarrow\quad y = \frac{2}{x} + 3.
f^{-1}(x) = \frac{2}{x} + 3 \qquad (x \neq 0).
Verify: f(4) = \frac{2}{4-3} = 2, and
f^{-1}(2) = \frac{2}{2} + 3 = 4. Home again.
Notice how the forbidden values swapped along with everything else:
f can't accept x = 3 and never outputs
2 \cdot \frac{1}{x-3} = 0… so f^{-1}
can't accept 0 and never outputs 3.
The domain and range
of a function and its inverse always trade places — inputs and outputs have literally swapped
jobs.
This is the classic inverse-function error. The -1 in
f^{-1} is a piece of notation meaning "undo" — it
is not a power, and it does not mean the reciprocal
\frac{1}{f(x)}. Compare, for
f(x) = 2x + 1:
f^{-1}(7) = \frac{7-1}{2} = 3 \qquad\text{but}\qquad \frac{1}{f(7)} = \frac{1}{15}.
Completely different things! (Confusingly, for a plain number the superscript
{-1} does mean reciprocal:
5^{-1} = \tfrac{1}{5}. It's only on a function name that
it means "inverse function". Blame history for the double booking.)
A second trap: not every function has an inverse. Only
one-to-one functions do — functions where no two inputs share an output.
g(x) = x^2 fails, because g(2) and
g(-2) are both 4: the journey home from
4 has two possible destinations, so there is no function that can
make it. More on this (and the fix) below.
The graph: a mirror in the line y = x
Swapping x and y has a beautiful
picture. If f(1) = 3, the point (1, 3)
sits on the graph of f — and since
f^{-1}(3) = 1, the point (3, 1) sits on
the graph of f^{-1}. Every point (a, b)
on f becomes the point (b, a) on
f^{-1}, and swapping coordinates like that is exactly a
reflection in the line y = x: fold the page along
that dashed line and the two graphs land on top of each other.
Below, f(x) = 2x + 1 and its inverse
f^{-1}(x) = \frac{x - 1}{2} mirror each other across
y = x.
Read the mirror like a detective. Where f crosses the
y-axis at (0, 1), its inverse crosses
the x-axis at (1, 0) — input and output
have swapped. A steep stretch of f becomes a shallow stretch of
f^{-1} (gradient 2 flips to gradient
\tfrac{1}{2}). And the one place the two curves can meet
on the mirror is where f(x) = x — here at
(-1, -1), a point that the journey out doesn't move at all.
This picture is also an exam shortcut: asked to sketch an inverse, you don't need
its formula — just reflect the graph you have in y = x.
When there's no way home: x²
Try the ritual on g(x) = x^2 and something breaks. From
x = y^2 we get y = \pm\sqrt{x} — that
\pm means two answers for one input, and a function is
only allowed one. The picture shows why:
The horizontal line y = 4 cuts the parabola twice:
both 2 and -2 square to
4. So the "journey home from 4" has two possible destinations, and
no function can choose both. g is many-to-one,
and many-to-one functions have no inverse. (This is the horizontal line test:
if any horizontal line crosses the graph more than once, no inverse exists.)
The fix is surgery: cut the domain in half. Keep only
x \geq 0 — the right-hand arm of the parabola — and now every
output comes from exactly one input. The restricted function is one-to-one, and its
inverse is an old friend:
g(x) = x^2 \;\; (x \geq 0) \qquad\Longrightarrow\qquad g^{-1}(x) = \sqrt{x}.
The half-parabola and the square-root curve are perfect mirror images in
y = x. This is exactly why your calculator's
\sqrt{\phantom{x}} button only ever returns the
positive root — it is the inverse of the restricted square, so it must pick
one destination. The same trick powers the inverse trig functions you'll meet later:
\sin^{-1} only exists because someone cut sine's domain down to a
one-to-one slice.
Every time you buy something online, your card details are scrambled by a function before
they cross the internet. Anyone can run this function forwards — it's public. The
entire security of the web rests on one fact: running it backwards without the
secret key is monstrously hard.
The classic example: multiplying two huge prime numbers is easy —
f(p, q) = pq takes a computer microseconds even when
p and q are hundreds of digits long.
But the inverse journey — given the product, find the primes — would take the
world's best computers longer than the age of the universe. A function that is easy forwards
and hard backwards is called a one-way function, and it's the mathematical
padlock on your bank account: everyone can snap the padlock shut, but only the key-holder
(who knows the primes) can pop it open.
So the humble question on this page — "can I undo f, and how
hard is it?" — is quietly guarding trillions of pounds a day. Sometimes the most valuable
inverse function is the one you can't find.
Prefer to hear it in another voice? Khan Academy's introduction covers the same journey-home
idea: