Discrete MathSets and Functions

Bijections and Inverse Functions

A function has an inverse exactly when it is one-to-one and onto, and (g ∘ f)⁻¹ = f⁻¹ ∘ g⁻¹.

Not started Jump to practice

In algebra you found inverse functions by swapping $x$ and $y$ and solving. Now we can say exactly when that works, using one-to-one and onto, and how inverses behave when functions are chained.

Key idea

A function $f : A \to B$ has an inverse $f^{-1} : B \to A$, with $f^{-1}(f(a)) = a$ and $f(f^{-1}(b)) = b$, exactly when $f$ is a bijection. For bijections $f : A \to B$ and $g : B \to C$, $(g \circ f)^{-1} = f^{-1} \circ g^{-1}$: undo the last step first.

Why it works

Reverse every arrow of $f$. For the reversed arrows to form a function from $B$, each element of $B$ needs exactly one arrow coming back. "At least one" is exactly onto; "at most one" is exactly one-to-one. So the inverse exists precisely for bijections. For the composition, $g \circ f$ means "apply $f$, then $g$." To get back you must peel off $g$ first, then $f$, just as you take off your shoes before your socks.
A bijection. Press "Reverse the arrows": every element of $B$ has exactly one arrow back, so the reversed arrows form the inverse function. Remove an arrow, or add one, and see the inverse break.

Worked examples

Worked example: Inverting a formula

Show that $f : \mathbb{R} \to \mathbb{R}$, $f(x) = 3x - 2$, is a bijection, and find $f^{-1}$.
  1. Solve $y = 3x - 2$ for $x$: $x = \frac{y + 2}{3}$. Every real $y$ gives exactly one real $x$, so $f$ is onto and one-to-one.
  2. So $f^{-1}(y) = \frac{y + 2}{3}$, or, renaming the variable, $f^{-1}(x) = \frac{x + 2}{3}$.
  3. Check: $f(f^{-1}(x)) = 3 \cdot \frac{x + 2}{3} - 2 = x$.

Answer: $f^{-1}(x) = \frac{x + 2}{3}$

Worked example: Undoing a composition

Let $f(x) = 2x + 1$ and $g(x) = x^{3}$ on $\mathbb{R}$. Find $(g \circ f)^{-1}(x)$.
  1. $(g \circ f)(x) = (2x + 1)^{3}$: first double and add $1$, then cube.
  2. Undo in reverse order: first undo the cube, $g^{-1}(x) = \sqrt[3]{x}$; then undo $f$, $f^{-1}(x) = \frac{x - 1}{2}$.
  3. So $(g \circ f)^{-1}(x) = f^{-1}(g^{-1}(x)) = \frac{\sqrt[3]{x} - 1}{2}$.
  4. Check at $x = 2$: $(2 \cdot 2 + 1)^{3} = 125$, and $\frac{\sqrt[3]{125} - 1}{2} = \frac{5 - 1}{2} = 2$.

Answer: $\frac{\sqrt[3]{x} - 1}{2}$

Worked example: A permutation and its inverse

The bijection $f$ on $\{1, 2, 3, 4\}$ has $f(1) = 3$, $f(2) = 1$, $f(3) = 4$, $f(4) = 2$. Find $f^{-1}(1)$ and $f^{-1}(4)$.
  1. $f^{-1}(1)$ is the input that $f$ sends to $1$: $f(2) = 1$, so $f^{-1}(1) = 2$.
  2. $f(3) = 4$, so $f^{-1}(4) = 3$.

Answer: $2$ and $3$

Common mistake

Undoing a composition in the original order. $(g \circ f)^{-1}$ is not $g^{-1} \circ f^{-1}$; that would try to undo $f$ while $g$'s effect is still on top. In the example, $g^{-1}(f^{-1}(125)) = \sqrt[3]{62}$, which is not $2$. Check by plugging one number through: apply $g \circ f$, then your inverse, and see whether you get the number back.

Practice

Pass with 3 right answers, the last 2 in a row. Each right answer earns 2 XP.

Loading practice…

Builds on

Leads to

Sources and further reading

  • Oscar Levin, Discrete Mathematics: An Open Introduction (3rd ed.), section "Functions" (inverse functions)
  • MIT OpenCourseWare 6.042J Mathematics for Computer Science (Lehman, Leighton and Meyer), chapter "Mathematical Data Types" (bijections)
@teddyrookbook GitHub