In short

A function f: A \to B has an inverse f^{-1}: B \to A if and only if f is bijective (one-one and onto). The inverse satisfies f^{-1}(f(x)) = x for all x \in A and f(f^{-1}(y)) = y for all y \in B. To find it algebraically, swap x and y in the equation y = f(x) and solve for y. Graphically, the graph of f^{-1} is the reflection of the graph of f in the line y = x.

A vending machine takes a code and gives you a snack. Code A3 gives you chips, B2 gives you a samosa, C1 gives you biscuits. If you know the code, you know the snack. But can you go backwards — if someone hands you a samosa, can you figure out which code was pressed?

You can, but only under two conditions. First, no two codes should give the same snack (otherwise, given a samosa, you would not know if it was B2 or D4). Second, every snack in the machine should have a code (otherwise, some snacks have no code to trace back to). The first condition is injectivity. The second is surjectivity. Together, they make the function bijective — and that is exactly when reversal works.

The reversed function — the one that takes a snack and returns the code — is called the inverse.

When does an inverse exist?

Inverse function

Let f: A \to B be a bijection. The inverse function f^{-1}: B \to A is the function satisfying:

f^{-1}(b) = a \quad \text{if and only if} \quad f(a) = b

Equivalently: f^{-1} \circ f = \text{id}_A and f \circ f^{-1} = \text{id}_B, where \text{id} is the identity function.

Both conditions — one-one and onto — are essential. Here is what goes wrong if either fails.

Without one-one: Take f(x) = x^2 on \mathbb{R}. Then f(3) = 9 and f(-3) = 9. If you try to define f^{-1}(9), you get two answers: 3 and -3. A function must give exactly one output, so f^{-1} is not well-defined.

Without onto: Take f: \mathbb{R} \to \mathbb{R} with f(x) = e^x. The range is (0, \infty), not all of \mathbb{R}. If you try f^{-1}(-5), there is no input whose exponential is -5. The inverse has no value to assign to -5.

Two failure modes for inversesLeft: arrow diagram showing x squared mapping both 3 and negative 3 to 9, with a question mark for the inverse at 9. Right: arrow diagram showing e to the x mapping reals to positive reals only, with negative 5 having no preimage. not one-one: f(x) = x² 3 −3 9 f⁻¹(9) = 3 or −3 ? not onto: f(x) = eˣ range = (0, ∞) −5 f⁻¹(−5) = ? (no preimage)
Left: $f(x) = x^2$ sends both $3$ and $-3$ to $9$, so $f^{-1}(9)$ would have two values — not a valid function. Right: $f(x) = e^x$ never outputs $-5$, so $f^{-1}(-5)$ has no value to take.

A bijective function avoids both problems. One-one ensures each output has at most one preimage. Onto ensures each output has at least one preimage. Together: each output has exactly one preimage, so the reversal is a well-defined function.

Finding the inverse algebraically

The recipe has three steps:

  1. Write y = f(x).
  2. Swap x and y to get x = f(y).
  3. Solve for y. The result is f^{-1}(x).

The swap makes sense: if the original function converts input x into output y, the inverse converts input y back into x. Relabelling y as the new input and x as the new output is exactly this reversal.

Three-step recipe for finding the inverseThree boxes in a row connected by arrows. Box 1: write y equals f of x. Box 2: swap x and y. Box 3: solve for y to get f inverse of x. Write y = f(x) Swap x = f(y) Solve for y y = f⁻¹(x)
The three-step recipe. The swap in step 2 is the conceptual heart — it reverses the roles of input and output.

The graph of the inverse: reflection in y = x

If the point (a, b) lies on the graph of f, then f(a) = b, which means f^{-1}(b) = a, so (b, a) lies on the graph of f^{-1}. Every point (a, b) gets swapped to (b, a).

Geometrically, swapping coordinates is a reflection in the line y = x. The point (a, b) and the point (b, a) are mirror images across this diagonal. So the graph of f^{-1} is the reflection of the graph of f in the line y = x.

Graph of f and f inverse as reflections in y equals xA coordinate plane with the line y equals x drawn as a dashed diagonal. A curve labelled f of x equals x cubed is drawn, along with its reflection labelled f inverse of x equals cube root of x. Two points, (2, 8) on f and (8, 2) on f inverse, are shown as mirror images. x y 1 2 1 2 y = x f(x) = x³ f⁻¹(x) = ∛x (2, 8) (8, 2)
The graph of $f(x) = x^3$ (dark curve) and its inverse $f^{-1}(x) = \sqrt[3]{x}$ (red curve). Each is the mirror image of the other across the dashed line $y = x$. The point $(2, 8)$ on $f$ corresponds to $(8, 2)$ on $f^{-1}$.

This reflection property gives you a quick way to sketch the inverse: draw the line y = x, then "fold" the original graph across it.

Properties of inverse functions

1. Composing with the inverse gives the identity.

f^{-1}(f(x)) = x \quad \text{for all } x \in A
f(f^{-1}(y)) = y \quad \text{for all } y \in B

These are the defining equations. They say that f and f^{-1} undo each other, in either order.

2. The inverse of the inverse is the original.

(f^{-1})^{-1} = f

If you reverse the reversal, you get back to where you started.

3. The inverse of a composite reverses the order.

(f \circ g)^{-1} = g^{-1} \circ f^{-1}

Think of putting on socks and shoes. You put on socks first, then shoes. To undo this, you take off shoes first, then socks. The last operation you did is the first one you undo. This is the same pattern: the inverse of "first g, then f" is "first undo f, then undo g."

Inverse of a composite reverses the orderTwo rows. Top row shows the forward direction: A maps to B via g, then B maps to C via f. Bottom row shows the inverse: C maps to B via f inverse, then B maps to A via g inverse. The order is reversed. forward: first g, then f A B C g f inverse: first f⁻¹, then g⁻¹ A B C g⁻¹ f⁻¹ (f ∘ g)⁻¹ = g⁻¹ ∘ f⁻¹
To reverse "first $g$, then $f$," you undo $f$ first, then undo $g$. The order flips.

4. The domain of f^{-1} is the range of f, and the range of f^{-1} is the domain of f.

This follows directly from the swap: f maps A to B; f^{-1} maps B to A.

5. The graph of f^{-1} is the reflection of the graph of f in the line y = x.

This was shown above. It is the graphical consequence of swapping coordinates.

Two worked examples

Example 1: Finding the inverse of a linear function

Let f: \mathbb{R} \to \mathbb{R} be f(x) = \dfrac{3x - 7}{2}.

Step 1. Write y = f(x):

y = \frac{3x - 7}{2}

Why: set up the equation relating input x and output y.

Step 2. Swap x and y:

x = \frac{3y - 7}{2}

Why: in the inverse, the old output becomes the new input.

Step 3. Solve for y:

2x = 3y - 7 \implies 3y = 2x + 7 \implies y = \frac{2x + 7}{3}

Why: isolate y to express the inverse as a function of x.

Step 4. Verify: f^{-1}(f(x)) = f^{-1}\!\left(\frac{3x-7}{2}\right) = \frac{2 \cdot \frac{3x-7}{2} + 7}{3} = \frac{3x - 7 + 7}{3} = \frac{3x}{3} = x. Checks out.

Why: the round-trip f^{-1} \circ f must return every input unchanged. This confirms the algebra.

Result: f^{-1}(x) = \dfrac{2x + 7}{3}.

Graph of f(x) = (3x-7)/2 and its inverse f inverse(x) = (2x+7)/3, reflected in y = xA coordinate plane with the line y equals x as a dashed diagonal. Two straight lines are drawn: f with slope 3/2 passing through (0, negative 3.5), and f inverse with slope 2/3 passing through (0, 7/3). They are mirror images across y equals x. x y 2 4 −2 2 4 y = x f(x) f⁻¹(x) (4, 2.5) (2.5, 4)
The line $f(x) = (3x - 7)/2$ (dark) and its inverse $f^{-1}(x) = (2x + 7)/3$ (red) are reflections across $y = x$. The point $(4, 2.5)$ on $f$ mirrors to $(2.5, 4)$ on $f^{-1}$.

Both lines have different slopes (3/2 and 2/3), and each is the other's reflection. The slopes are reciprocals — this always happens for linear functions, because reflecting a line across y = x flips the rise-over-run.

Example 2: Finding the inverse of a restricted quadratic

Let f: [0, \infty) \to [0, \infty) be f(x) = x^2.

On all of \mathbb{R}, f(x) = x^2 is not one-one (since f(3) = f(-3)). But restricted to [0, \infty), it is: if x_1, x_2 \ge 0 and x_1^2 = x_2^2, then x_1 = x_2 (both are non-negative, so the negative root is excluded). And the range of x^2 on [0, \infty) is [0, \infty) — matching the codomain. So f is bijective on this restricted domain.

Step 1. Write y = x^2, with x \ge 0 and y \ge 0.

Why: the domain restriction x \ge 0 is essential — it is what makes the function one-one.

Step 2. Swap: x = y^2, with y \ge 0.

Why: the new variable y inherits the non-negativity constraint from the original domain.

Step 3. Solve for y: y = \sqrt{x}.

Why: since y \ge 0, take the positive square root only.

Step 4. Verify: f^{-1}(f(x)) = \sqrt{x^2} = |x| = x (since x \ge 0). And f(f^{-1}(x)) = (\sqrt{x})^2 = x (since x \ge 0).

Result: f^{-1}(x) = \sqrt{x}, with domain [0, \infty) and range [0, \infty).

Graph of f(x) = x squared restricted to non-negative reals and its inverse f inverse(x) = square root of xA coordinate plane with the line y equals x as a dashed diagonal. The right half of the parabola y equals x squared is drawn from the origin upward. Its reflection, the curve y equals square root of x, is drawn from the origin to the right. They meet at the origin and at (1, 1). x y 1 2 3 1 2 3 y = x f(x) = x² f⁻¹(x) = √x (1, 1)
The right half of $y = x^2$ (dark curve) and its inverse $y = \sqrt{x}$ (red curve), reflected across $y = x$. The curves meet on the mirror line at $(0, 0)$ and $(1, 1)$ — the points where $f(x) = x$.

The restriction to [0, \infty) is what makes the inverse possible. Without it, the parabola curves back on itself, and the horizontal line test fails. Restricting the domain "cuts" the parabola to a piece that is strictly increasing — and strictly increasing functions are always one-one.

Common confusions

Going deeper

If you can find the inverse of a given bijection algebraically, sketch its graph by reflection, and apply the composition-reversal rule, you are ready for graph transformations and for using inverses to solve equations. The remainder of this section addresses subtleties.

Left inverses and right inverses

Even when a function is not bijective, partial inverses can exist.

A function h: B \to A is a left inverse of f: A \to B if h \circ f = \text{id}_A. This undoes f from the left. A left inverse exists if and only if f is injective.

A function h: B \to A is a right inverse of f: A \to B if f \circ h = \text{id}_B. This undoes f from the right. A right inverse exists if and only if f is surjective.

When f is bijective, the left inverse and the right inverse coincide, and they are both equal to f^{-1}.

Self-inverse functions

Some functions are their own inverse: f^{-1} = f. These are called involutions. The function f(x) = -x is an involution: applying it twice returns the original input. So is f(x) = \frac{1}{x} (on \mathbb{R} \setminus \{0\}). Graphically, an involution is symmetric about the line y = x — its graph is its own reflection.

Interactive: reflection in y = x

Drag the red point along the curve f(x) = 2x + 1 below. A mirror point on the inverse curve tracks its reflection across y = x. The dashed line connecting them is always perpendicular to y = x and bisected by it.

Interactive reflection of a point across y equals xThe line f of x equals 2x plus 1 is drawn in dark ink. Its inverse, f inverse of x equals (x minus 1) over 2, is drawn in red. A draggable red point on f is connected by a dashed line to its mirror point on f inverse, showing the reflection across y equals x. x y y = x drag the red point
Drag the point on $f(x) = 2x + 1$. Its mirror image on $f^{-1}(x) = (x-1)/2$ moves in lockstep, always equidistant from the line $y = x$.

Where this leads next

You now know what an inverse function is, when it exists, how to find it, and what its graph looks like. The next articles build on this.