The inverse function
Learning Objectives
- Define the inverse function via the composition identities \(f^{-1} \circ f = \mathrm{id}_A\) and \(f \circ f^{-1} = \mathrm{id}_B\).
- Prove that a function admits an inverse if and only if it is bijective.
- Compute the inverse of a simple invertible function.
- Describe the graphical relationship between \(f\) and \(f^{-1}\).
- State and apply the rule \((g \circ f)^{-1} = f^{-1} \circ g^{-1}\).
Motivation
If a function \(f\) takes \(3\) to \(7\), can we always "go back" — find another function that takes \(7\) to \(3\), and similarly for every output of \(f\)?
Sometimes yes, sometimes no. The squaring function on the reals sends both \(2\) and \(-2\) to \(4\); there is no unambiguous way to undo it. The constant function \(f(x) = 5\) sends everything to \(5\); there is no way to undo it at all. But a function like \(f(x) = 2x + 1\) sends each real number to a distinct real number, and every real number is the image of exactly one input — so its reversal is a sensible question with a unique answer.
The previous lesson named exactly when this works: bijectivity. We now construct the reversing function and study its properties. This new function is called the inverse of \(f\).
Inverse function
A function \(f \colon A \to B\) is invertible if there exists a function \(g \colon B \to A\) such that
\[g \circ f = \mathrm{id}_A \quad \text{and} \quad f \circ g = \mathrm{id}_B.\]
Such a \(g\) is called the inverse of \(f\) and is denoted \(f^{-1}\). Spelled out element by element, the two conditions say:
\(f^{-1}(f(a)) = a\) for every \(a \in A\) — applying \(f\) then \(f^{-1}\) returns the original input.
\(f(f^{-1}(b)) = b\) for every \(b \in B\) — applying \(f^{-1}\) then \(f\) returns the original input.
Together: \(f\) and \(f^{-1}\) undo each other, in either order. Note the notation: \(f^{-1}\) is a function, not a reciprocal. The "\(-1\)" is part of the name, not an exponent.
Inverses exist precisely for bijections
A function \(f \colon A \to B\) is invertible if and only if \(f\) is bijective.
When the inverse exists, it is unique.
(⇒) Suppose \(f\) has an inverse \(g\). We show \(f\) is bijective.
Injective. If \(f(a_1) = f(a_2)\), apply \(g\): \(g(f(a_1)) = g(f(a_2))\), so \(a_1 = a_2\) by \(g \circ f = \mathrm{id}_A\).
Surjective. Take any \(b \in B\) and set \(a = g(b)\). Then \(f(a) = f(g(b)) = b\) by \(f \circ g = \mathrm{id}_B\).
(⇐) Suppose \(f\) is bijective. We construct its inverse. For each \(b \in B\), surjectivity gives some \(a \in A\) with \(f(a) = b\), and injectivity says this \(a\) is unique. Define \(g(b) = a\). This is a well-defined function \(g \colon B \to A\).
By construction \(f(g(b)) = b\), so \(f \circ g = \mathrm{id}_B\). Conversely, for any \(a \in A\), let \(b = f(a)\). Then \(g(b)\) is the unique preimage of \(b\), which is \(a\). So \(g(f(a)) = a\), giving \(g \circ f = \mathrm{id}_A\).
(Uniqueness.) Suppose \(g\) and \(h\) both satisfy the inverse conditions. Then
\[g = g \circ \mathrm{id}_B = g \circ (f \circ h) = (g \circ f) \circ h = \mathrm{id}_A \circ h = h,\]
using associativity (Lesson 1) and the inverse identities for both \(g\) and \(h\). So the inverse is unique.
Computing an inverse
When \(f\) is given by an explicit rule \(y = f(x)\), we can often find \(f^{-1}\) by solving for \(x\) in terms of \(y\). The recipe:
Write the equation \(y = f(x)\).
Solve algebraically for \(x\), expressing \(x\) as a function of \(y\).
The resulting expression \(x = g(y)\) gives the inverse; we write \(f^{-1}(y) = g(y)\), and conventionally rename the variable back to \(x\): \(f^{-1}(x) = g(x)\).
The recipe only works for invertible (i.e., bijective) functions: if the equation \(y = f(x)\) cannot be solved uniquely for \(x\), the function is not bijective and has no inverse.
Inverse of \(f(x) = 2x + 1\)
Let \(f \colon \mathbb{R} \to \mathbb{R},\; f(x) = 2x + 1\). Following the recipe:
\[y = 2x + 1 \;\Longleftrightarrow\; 2x = y - 1 \;\Longleftrightarrow\; x = \frac{y - 1}{2}.\]
So \(f^{-1} \colon \mathbb{R} \to \mathbb{R},\; f^{-1}(y) = \dfrac{y - 1}{2}\), or after renaming, \(f^{-1}(x) = \dfrac{x - 1}{2}\).
Verification. Check both composition identities.
\[(f^{-1} \circ f)(x) = f^{-1}(2x + 1) = \frac{(2x + 1) - 1}{2} = \frac{2x}{2} = x.\]
\[(f \circ f^{-1})(x) = f\!\left(\frac{x - 1}{2}\right) = 2 \cdot \frac{x - 1}{2} + 1 = (x - 1) + 1 = x.\]
Both compositions give the identity, confirming the inverse is correct.
A function with no inverse — and a restriction that fixes it
The function \(g \colon \mathbb{R} \to \mathbb{R},\; g(x) = x^2\) is not bijective (Lesson 2). It is not injective (\(g(2) = g(-2) = 4\)) and not surjective (no negative number is a square). So \(g\) has no inverse.
Restricting changes the situation. The same rule, viewed as \(\tilde{g} \colon [0, +\infty) \to [0, +\infty),\; \tilde{g}(x) = x^2\), is bijective (Lesson 2), and its inverse is the square-root function
\[\tilde{g}^{-1} \colon [0, +\infty) \to [0, +\infty), \quad \tilde{g}^{-1}(x) = \sqrt{x}.\]
The lesson here is that invertibility is sensitive to both domain and codomain. The same formula \(x \mapsto x^2\) can be invertible or not depending on which sets we declare as the domain and codomain.
The graph of \(f^{-1}\): reflection across \(y = x\)
There is a striking geometric relationship between the graphs of \(f\) and \(f^{-1}\). If \((a, b)\) is on the graph of \(f\) — that is, \(b = f(a)\) — then \(a = f^{-1}(b)\), so the pair \((b, a)\) is on the graph of \(f^{-1}\). The point \((b, a)\) is the reflection of \((a, b)\) across the line \(y = x\).
Applying this to every point of the graph: the graph of \(f^{-1}\) is the reflection of the graph of \(f\) across the line \(y = x\). The mirror line itself is the graph of the identity function.
In the picture, \(f(x) = 2x + 1\) passes through \((1, 3)\); its inverse passes through \((3, 1)\). The two points are mirror images across the dashed line \(y = x\), and so is every other corresponding pair.
Inverse of a composition
If \(f \colon A \to B\) and \(g \colon B \to C\) are both bijective, then \(g \circ f\) is bijective (Lesson 2), so it has an inverse. That inverse is
\[(g \circ f)^{-1} = f^{-1} \circ g^{-1}.\]
Note the reversal: to undo "first \(f\), then \(g\)", you first undo \(g\), then undo \(f\).
It suffices to verify the two composition identities for \(f^{-1} \circ g^{-1}\) as a candidate inverse of \(g \circ f\):
\[(f^{-1} \circ g^{-1}) \circ (g \circ f) = f^{-1} \circ (g^{-1} \circ g) \circ f = f^{-1} \circ \mathrm{id}_B \circ f = f^{-1} \circ f = \mathrm{id}_A.\]
\[(g \circ f) \circ (f^{-1} \circ g^{-1}) = g \circ (f \circ f^{-1}) \circ g^{-1} = g \circ \mathrm{id}_B \circ g^{-1} = g \circ g^{-1} = \mathrm{id}_C.\]
Both reduce to identities (associativity is used freely). Since inverses are unique, \((g \circ f)^{-1} = f^{-1} \circ g^{-1}\).
The everyday analogue: to undo "put on socks, then put on shoes", you "take off shoes, then take off socks". The order reverses.
Connection to Computer Science
An invertible function is essentially a lossless encoding — given the output, you can recover the input. Encoding-decoding pairs are inverse functions: a hash function (deliberately non-invertible), in contrast, throws away information so that recovering the input from the output is hard. The inverse-of-composition rule \((g \circ f)^{-1} = f^{-1} \circ g^{-1}\) is the reason pipelines of encodings must be undone in reverse order — a string that was first compressed and then encrypted must be decrypted first and only then decompressed.
Why both composition identities are needed
It might seem like a single identity \(g \circ f = \mathrm{id}_A\) should be enough to call \(g\) the inverse of \(f\). For functions on infinite sets, it is not. A function \(g\) satisfying \(g \circ f = \mathrm{id}_A\) is called a left inverse; a function satisfying \(f \circ g = \mathrm{id}_B\) is called a right inverse. These can exist separately when only one of injectivity or surjectivity holds.
For \(f \colon \mathbb{N} \to \mathbb{N},\; f(n) = 2n\) (which is injective but not surjective), the function \(g(n) = \lfloor n/2 \rfloor\) satisfies \(g \circ f = \mathrm{id}_{\mathbb{N}}\) (a left inverse) but \(f(g(3)) = f(1) = 2 \neq 3\), so \(f \circ g \neq \mathrm{id}_{\mathbb{N}}\). It is the requirement that both identities hold that pins down a genuine two-sided inverse — and forces \(f\) to be bijective.
Exercises
Exercise 1
For each function, decide whether it has an inverse (equivalently, whether it is bijective).
Exercise 2
For each invertible function, choose its inverse.
Exercise 3
Let \(f \colon \mathbb{R} \to \mathbb{R},\; f(x) = 2x + 1\), with inverse \(f^{-1}(x) = (x-1)/2\). Compute the following values.
Exercise 4
Let \(f, g \colon \mathbb{R} \to \mathbb{R}\) be bijective. Use \((g \circ f)^{-1} = f^{-1} \circ g^{-1}\) to answer.
Exercise 5
Let \(f \colon A \to B\) be a bijection with inverse \(f^{-1}\).
Summary
A function \(f \colon A \to B\) is invertible if there is \(g \colon B \to A\) with \(g \circ f = \mathrm{id}_A\) and \(f \circ g = \mathrm{id}_B\). Such a \(g\) is unique, denoted \(f^{-1}\).
Theorem. \(f\) is invertible \(\iff\) \(f\) is bijective.
To compute \(f^{-1}\), solve the equation \(y = f(x)\) for \(x\) in terms of \(y\).
The graph of \(f^{-1}\) is the reflection of the graph of \(f\) across the line \(y = x\).
Inverse of a composition. \((g \circ f)^{-1} = f^{-1} \circ g^{-1}\) — order reverses.