1. The idea: running a function backwards
If $f$ converts US dollars to euros at the day's rate, what converts euros back to dollars? If $f$ encrypts a letter by shifting it three places, what decrypts it? If $f$ takes a Celsius temperature and returns Fahrenheit, what does the reverse? Each of these reversals is the same idea — an inverse function, written $f^{-1}$. It's the function that takes $f$'s outputs and returns the inputs they came from.
For a function $f$ with input domain $A$ and output range $B$, the inverse $f^{-1}$ is the function from $B$ back to $A$ satisfying
$$ f^{-1}(f(x)) = x \quad \text{and} \quad f(f^{-1}(y)) = y $$for every $x$ in $A$ and every $y$ in $B$. In words: $f^{-1}$ undoes $f$, and $f$ undoes $f^{-1}$.
The point of the inverse is to solve for the input. If you know that $f(x) = y$ and you want to recover $x$, applying $f^{-1}$ to both sides gives you $x = f^{-1}(y)$ directly. It's the cleanest possible way of "undoing" a function.
The "$-1$" in $f^{-1}$ is not an exponent. $f^{-1}(x)$ is the inverse function — the thing that satisfies the two identities above. It is not the same as $\tfrac{1}{f(x)}$, which is the reciprocal. We'll come back to this trap in the pitfalls section.
2. When does an inverse exist?
An inverse only makes sense when each output of $f$ comes from a single input. If two different inputs both produced the same output, you couldn't reverse the arrow — given that output, which input would you send it back to? You'd have a tie and no way to break it.
A function $f$ is one-to-one if distinct inputs always give distinct outputs:
$$ x_1 \neq x_2 \;\Longrightarrow\; f(x_1) \neq f(x_2) $$Equivalently (the contrapositive), if $f(x_1) = f(x_2)$ then $x_1 = x_2$.
Being one-to-one is the structural requirement. A function has an inverse exactly when it's one-to-one on its domain. The graphical version of this test is the most useful tool you'll reach for in practice:
A graph represents a one-to-one function if and only if no horizontal line meets it more than once.
This is the horizontal line test. The reasoning is direct — a horizontal line $y = c$ hits the graph at every $x$ where $f(x) = c$. If the line crosses twice, two inputs give the same output, and $f$ fails one-to-one.
Which familiar functions pass?
- $f(x) = 2x + 3$ — strictly increasing.
- $f(x) = x^3$ — strictly increasing.
- $f(x) = e^x$ — strictly increasing.
- $f(x) = 1/x$ on $x \neq 0$ — monotone on each branch.
- $f(x) = x^2$ — $f(2) = f(-2) = 4$.
- $f(x) = |x|$ — same failure as $x^2$.
- $f(x) = \sin x$ — periodic, every value in $(-1, 1)$ hit infinitely often.
- $f(x) = x^3 - x$ — has a local hump and dip.
Any function that is strictly monotonic (always increasing or always decreasing) is automatically one-to-one. The horizontal line test is just a graphical restatement of that. So whenever you can argue that a function is monotonic — e.g. by reading off its derivative's sign in calculus — you've already shown it has an inverse.
3. The swap-and-solve recipe
Once you know an inverse exists, finding it algebraically is mechanical. The procedure has three steps and works for any function you can solve explicitly.
- Write $y = f(x)$.
- Swap $x$ and $y$. The equation becomes $x = f(y)$.
- Solve the new equation for $y$. That solved-for-$y$ expression is $f^{-1}(x)$.
The "swap" step is where the inversion actually happens — you're rewriting the relationship from the output's point of view. Solving for $y$ then puts the new function in standard form.
A linear example, fully worked
Find the inverse of $f(x) = 2x + 3$.
Step 1. Write $y = 2x + 3$.
Step 2. Swap: $x = 2y + 3$.
Step 3. Solve for $y$:
$$ 2y = x - 3 \quad\Longrightarrow\quad y = \frac{x - 3}{2} $$So $f^{-1}(x) = \tfrac{x - 3}{2}$. Quick sanity check by composition:
$$ f\bigl(f^{-1}(x)\bigr) = 2 \cdot \frac{x - 3}{2} + 3 = (x - 3) + 3 = x \;\checkmark $$The graph of $f$ is the set of pairs $(x, y)$ with $y = f(x)$. The graph of $f^{-1}$ is the set of pairs $(y, x)$ — same pairs, axes relabeled. Swapping the letters in your equation is the algebraic version of that relabeling.
4. The geometry: reflection across $y = x$
The swap step has a beautiful visual: every point $(a, b)$ on the graph of $f$ corresponds to the point $(b, a)$ on the graph of $f^{-1}$, and the map $(a, b) \mapsto (b, a)$ is exactly reflection across the diagonal $y = x$.
So if you can sketch $f$, you can sketch $f^{-1}$ without doing any algebra: fold the picture along $y = x$ and trace what lands underneath. The diagonal acts as a mirror.
The orange line is $f(x) = 2x + 3$; the green line is its inverse $f^{-1}(x) = (x - 3)/2$. They mirror each other across the dashed diagonal $y = x$. The pair of dots illustrates the swap: the point $(1, 5)$ on $f$ becomes $(5, 1)$ on $f^{-1}$ — same numbers, coordinates traded.
Some functions equal their own inverse — applying them twice gives back the input. The graph of such a function is symmetric about $y = x$ all by itself. Examples: $f(x) = -x$, $f(x) = c - x$, and $f(x) = 1/x$. Check the last one: $f(f(x)) = 1/(1/x) = x$.
5. Composition: the defining identities
The cleanest way to state what $f^{-1}$ is isn't through the swap recipe — it's through composition. The inverse is whatever function makes both of these identities hold:
$$ f\bigl(f^{-1}(x)\bigr) = x \quad \text{for all } x \in \mathrm{dom}(f^{-1}) $$ $$ f^{-1}\bigl(f(x)\bigr) = x \quad \text{for all } x \in \mathrm{dom}(f) $$Both identities together say "$f$ and $f^{-1}$ undo each other." Either one alone isn't enough — you can have a one-sided inverse without the other holding — but together they pin down $f^{-1}$ uniquely.
This composition view turns "is $g$ the inverse of $f$?" into a finite calculation. You don't have to derive $g$ from $f$; you just check both compositions and see if they simplify to $x$.
Verifying an inverse by composition
Is $g(x) = \tfrac{x}{2} + 1$ the inverse of $f(x) = 2x - 2$? Check both directions:
$$ f(g(x)) = 2\!\left(\tfrac{x}{2} + 1\right) - 2 = x + 2 - 2 = x \;\checkmark $$ $$ g(f(x)) = \tfrac{2x - 2}{2} + 1 = (x - 1) + 1 = x \;\checkmark $$Both identities hold for every real $x$, so $g = f^{-1}$. No swap-and-solve required.
If $f$ and $g$ are both invertible, then $(f \circ g)^{-1} = g^{-1} \circ f^{-1}$. The order reverses. The mnemonic is "socks and shoes": to undo putting on socks then shoes, you first take off the shoes (outer operation), then the socks (inner one). Cryptography uses exactly this: encrypted layers are peeled in reverse order.
6. Domain and range swap
An inverse swaps inputs and outputs, which means it also swaps the sets they live in.
If $f : A \to B$ is a bijection, then $f^{-1} : B \to A$.
That is, the domain of $f^{-1}$ is the range of $f$, and the range of $f^{-1}$ is the domain of $f$. This is a small fact with big consequences — it means you can't just write down $f^{-1}$ as a formula and forget where it's allowed to take inputs.
| $f$ | Domain of $f$ | Range of $f$ | $f^{-1}$ | Domain of $f^{-1}$ | Range of $f^{-1}$ |
|---|---|---|---|---|---|
| $2x + 3$ | $\mathbb{R}$ | $\mathbb{R}$ | $(x - 3)/2$ | $\mathbb{R}$ | $\mathbb{R}$ |
| $x^2$ on $[0, \infty)$ | $[0, \infty)$ | $[0, \infty)$ | $\sqrt{x}$ | $[0, \infty)$ | $[0, \infty)$ |
| $e^x$ | $\mathbb{R}$ | $(0, \infty)$ | $\ln x$ | $(0, \infty)$ | $\mathbb{R}$ |
| $\sin x$ on $[-\tfrac{\pi}{2}, \tfrac{\pi}{2}]$ | $[-\tfrac{\pi}{2}, \tfrac{\pi}{2}]$ | $[-1, 1]$ | $\arcsin x$ | $[-1, 1]$ | $[-\tfrac{\pi}{2}, \tfrac{\pi}{2}]$ |
Read the rows literally: the domain column and the range column flip when you cross to the right half of the table.
7. Restricting the domain
What do you do with a function that isn't one-to-one? You don't have to give up — you can shrink the domain until what remains is one-to-one, then invert that restricted function. The classic example is $f(x) = x^2$.
On all of $\mathbb{R}$, $x^2$ fails badly: $f(2) = f(-2) = 4$, $f(3) = f(-3) = 9$, and so on. Every positive output comes from two inputs, one positive and one negative. So $x^2$ has no inverse on $\mathbb{R}$.
But on the restricted domain $[0, \infty)$ — only the non-negative reals — $x^2$ is strictly increasing and therefore one-to-one. Solve $y = x^2$ for $x \geq 0$ and you get $x = \sqrt{y}$. The inverse is
$$ f^{-1}(x) = \sqrt{x}, \quad x \geq 0 $$where $\sqrt{x}$ denotes the principal (non-negative) square root. If you'd restricted to $(-\infty, 0]$ instead, you'd get the other inverse, $f^{-1}(x) = -\sqrt{x}$. Both are legitimate; the principal-square-root convention just picks the positive branch.
When you restrict a domain to invert, the restriction becomes the range of the inverse. Drop it and you'll quietly extend $f^{-1}$'s codomain past what the construction actually justifies — which is exactly how you end up "proving" things like $\sqrt{(-3)^2} = -3$.
Trig functions get the same treatment, and the conventions are universal:
- $\sin x$ is restricted to $[-\tfrac{\pi}{2}, \tfrac{\pi}{2}]$ before inversion. The inverse is $\arcsin x$, with range $[-\tfrac{\pi}{2}, \tfrac{\pi}{2}]$.
- $\cos x$ is restricted to $[0, \pi]$. Its inverse is $\arccos x$, with range $[0, \pi]$.
- $\tan x$ is restricted to $(-\tfrac{\pi}{2}, \tfrac{\pi}{2})$. Its inverse is $\arctan x$, with range $(-\tfrac{\pi}{2}, \tfrac{\pi}{2})$.
These are not arbitrary: each restriction is the largest interval on which the trig function is strictly monotonic and still covers the full output range. The restriction is the price you pay for invertibility, and the chosen interval is everyone's convention so that $\arcsin$, $\arccos$, $\arctan$ unambiguously refer to particular functions.
8. Three canonical inverse pairs
Most "named" inverse functions you'll meet fall into three families. Recognizing the pattern makes them familiar instead of intimidating.
| Family | Forward $f(x)$ | Inverse $f^{-1}(x)$ | Domain quirk |
|---|---|---|---|
| Power / root | $x^n$ | $x^{1/n}$ | Even $n$: must restrict to $x \geq 0$. Odd $n$: works on all of $\mathbb{R}$. |
| Exponential / logarithm | $a^x$ (base $a > 0$, $a \neq 1$) | $\log_a x$ | Domain of $\log_a$ is $(0, \infty)$. |
| Trig / arctrig | $\sin x,\;\cos x,\;\tan x$ | $\arcsin x,\;\arccos x,\;\arctan x$ | Forward must be restricted to a principal interval first. |
The first row is why we even bother defining $\sqrt{\,}$, $\sqrt[3]{\,}$, etc. — they're inverses of powers. The second row is the entire reason logarithms exist: they're inverses of exponentials, defined precisely so that "$a$ to what power gives $y$?" has a name. Napier's original 1614 logarithms were exactly that — an exponent-lookup table, packaged as a function. The third row is more subtle because the forward functions aren't one-to-one on their natural domains; you have to restrict first, as in the previous section.
The composition identities specialize cleanly to each pair. For exponentials and logs:
$$ a^{\log_a x} = x \;(x > 0), \qquad \log_a(a^x) = x \;(x \in \mathbb{R}) $$For trig and arctrig (on the principal interval):
$$ \sin(\arcsin x) = x \;(-1 \leq x \leq 1), \qquad \arcsin(\sin x) = x \;(-\tfrac{\pi}{2} \leq x \leq \tfrac{\pi}{2}) $$Notice the asymmetry in the second identity: it only holds on the principal interval. Outside, $\arcsin(\sin x)$ projects back into $[-\tfrac{\pi}{2}, \tfrac{\pi}{2}]$ and stops equalling $x$. That's the price of the restriction.
9. Common pitfalls
The notation $f^{-1}$ means the inverse function. It does not mean the reciprocal $\tfrac{1}{f(x)}$. Concrete check with $f(x) = 2x$: the true inverse is $f^{-1}(x) = x/2$, whereas the reciprocal is $\tfrac{1}{2x}$. At $x = 4$: $f^{-1}(4) = 2$ but $\tfrac{1}{f(4)} = \tfrac{1}{8}$. These are completely different functions. The "$-1$" exponent is overloaded by tradition; context distinguishes inverse-function $f^{-1}$ from numerical reciprocal $x^{-1}$.
The swap-and-solve recipe will happily produce a formula even when $f$ has no inverse. Swap $y = x^2$ to get $x = y^2$ and "solve" $y = \pm\sqrt{x}$ — that's a relation, not a function (two outputs for each positive input). Always check one-to-one before — or restrict the domain before — inverting.
$\mathrm{dom}(f^{-1}) = \mathrm{range}(f)$, which is often a strict subset of $\mathbb{R}$. The formula for $f^{-1}$ may make sense for inputs $f^{-1}$ should never accept. Example: $f(x) = e^x$ has range $(0, \infty)$, so $f^{-1}(x) = \ln x$ is undefined at $x \leq 0$ even though "$\ln$" is a familiar symbol.
The inverse of a composition is $g^{-1} \circ f^{-1}$, with the order reversed. Writing $f^{-1} \circ g^{-1}$ is a near-universal mistake. The fix is the socks-and-shoes mnemonic: to undo $f \circ g$ (which does $g$ first, then $f$), you peel off $f$ first, then $g$.
10. Worked examples
Try each before opening the solution. The point is to see whether your steps match the canonical recipe, not just to land on the right answer.
Example 1 · Find the inverse of $f(x) = 3x - 4$
Step 1. $y = 3x - 4$.
Step 2. Swap: $x = 3y - 4$.
Step 3. Solve: $3y = x + 4$, so $y = \tfrac{x + 4}{3}$.
Check. $f(f^{-1}(x)) = 3 \cdot \tfrac{x + 4}{3} - 4 = (x + 4) - 4 = x$ ✓
Answer: $f^{-1}(x) = \tfrac{x + 4}{3}$.
Example 2 · Inverse of a rational function: $f(x) = \tfrac{1}{x + 2}$
Step 1. $y = \tfrac{1}{x + 2}$, with $x \neq -2$.
Step 2. Swap: $x = \tfrac{1}{y + 2}$.
Step 3. Solve for $y$: multiply both sides by $y + 2$, then divide by $x$:
$$ x(y + 2) = 1 \;\Longrightarrow\; y + 2 = \tfrac{1}{x} \;\Longrightarrow\; y = \tfrac{1}{x} - 2 $$Check. $f(f^{-1}(x)) = \tfrac{1}{(\tfrac{1}{x} - 2) + 2} = \tfrac{1}{1/x} = x$ ✓
Answer: $f^{-1}(x) = \tfrac{1}{x} - 2$, with $x \neq 0$.
Example 3 · Restrict $f(x) = x^2$ to make it invertible
On all of $\mathbb{R}$, $f(x) = x^2$ fails the horizontal line test: every horizontal line $y = c$ for $c > 0$ hits the graph twice. So $f$ has no inverse on $\mathbb{R}$.
Restrict to $[0, \infty)$. On this domain $f$ is strictly increasing, hence one-to-one. Its range is also $[0, \infty)$.
Solve $y = x^2$ for $x \geq 0$: $x = \sqrt{y}$ (principal square root). Swap letters:
$$ f^{-1}(x) = \sqrt{x}, \quad x \geq 0 $$Check. $f(f^{-1}(x)) = (\sqrt{x})^2 = x$ for $x \geq 0$ ✓
If you'd restricted to $(-\infty, 0]$ instead, you'd get $f^{-1}(x) = -\sqrt{x}$. By convention the non-negative branch is principal.
Example 4 · Logarithm as the inverse of an exponential
Find the inverse of $f(x) = \ln x$, where $x > 0$.
Step 1. $y = \ln x$.
Step 2. Exponentiate both sides with base $e$: $e^y = x$.
Step 3. Swap letters: $f^{-1}(x) = e^x$.
Check. $\ln(e^x) = x$ for all real $x$ ✓ and $e^{\ln x} = x$ for all $x > 0$ ✓
This is the canonical inverse pair: $\ln$ and $\exp$ undo each other. Domains and ranges swap: $\ln$ has domain $(0, \infty)$ and range $\mathbb{R}$, while $e^x$ has domain $\mathbb{R}$ and range $(0, \infty)$.
Example 5 · A Möbius-like rational: $f(x) = \tfrac{2x + 1}{x - 3}$
Step 1. $y = \tfrac{2x + 1}{x - 3}$.
Step 2. Swap: $x = \tfrac{2y + 1}{y - 3}$.
Step 3. Solve for $y$. Cross-multiply:
$$ x(y - 3) = 2y + 1 \;\Longrightarrow\; xy - 3x = 2y + 1 $$Collect the $y$-terms on one side:
$$ xy - 2y = 3x + 1 \;\Longrightarrow\; y(x - 2) = 3x + 1 \;\Longrightarrow\; y = \tfrac{3x + 1}{x - 2} $$Answer: $f^{-1}(x) = \tfrac{3x + 1}{x - 2}$, with $x \neq 2$.
Notice this inverse is also a Möbius-style function — rational, linear-over-linear. That's a general pattern: the inverse of $(ax + b)/(cx + d)$ is another expression of the same shape.
Example 6 · Inverse at a single point
A bijection $f$ satisfies $f(3) = 7$. Compute $f^{-1}(7)$.
By definition, $f^{-1}(y)$ is the unique $x$ with $f(x) = y$. Here $y = 7$ and the unique $x$ with $f(x) = 7$ is $x = 3$. So $f^{-1}(7) = 3$.
You don't need a formula — and most of the time you couldn't write one anyway. Pairs of input/output values are all you need for individual inverse-evaluations.
Example 7 · Self-inverse: $f(x) = \tfrac{1}{x}$
Check whether applying $f$ twice gives back the input:
$$ f(f(x)) = f\!\left(\tfrac{1}{x}\right) = \tfrac{1}{1/x} = x \quad (x \neq 0) $$Yes, $f \circ f$ is the identity, so $f$ is its own inverse. Such functions are called involutions. Their graphs are symmetric about the line $y = x$ all by themselves — the reflection of the graph is the graph again.
Other involutions: $f(x) = -x$, $f(x) = c - x$ for any constant $c$, and certain Möbius transforms.
Example 8 · Currency conversion (real-world inverse)
A currency app converts dollars to euros at $f(d) = 0.92 \, d$. Write the inverse that goes from euros back to dollars.
Solve $y = 0.92 d$ for $d$: $d = y / 0.92$.
So $f^{-1}(y) = y / 0.92 \approx 1.087 \, y$. Convert €92 back: $f^{-1}(92) = 92 / 0.92 = 100$ ✓ — exactly the dollars we started with.
In real exchanges there's a bid/ask spread, so the round trip in practice loses a few percent. Mathematically, though, $f \circ f^{-1}$ is the identity on the nose.