Table of Contents
Function Composition
In earlier chapters you have seen what a function is and how to work with function notation. Here we focus on combining functions to build new ones, and on “undoing” functions using inverses.
Function composition is a way of feeding the output of one function into another. The result is a new function.
Suppose you have two functions $f$ and $g$.
- $f$ takes an input $x$ and produces $f(x)$.
- $g$ takes an input $x$ and produces $g(x)$.
To compose them, you let the output of $g$ become the input of $f$.
The composition of $f$ with $g$ is written as:
$$
(f \circ g)(x) = f(g(x))
$$
Read this as “$f$ of $g$ of $x$.”
The order matters:
- $(f \circ g)(x) = f(g(x))$ means “do $g$ first, then $f$.”
- $(g \circ f)(x) = g(f(x))$ means “do $f$ first, then $g$.”
In general:
$$
f \circ g \neq g \circ f
$$
so composition is usually not commutative.
How to Compute a Composition
To compute $(f \circ g)(x)$:
- Start with $g(x)$.
- Take the formula for $f(x)$.
- Wherever $f$ has its input variable, replace it with the entire expression $g(x)$.
- Simplify if needed.
Example: Let $f(x) = 2x + 3$ and $g(x) = x^2$.
- $(f \circ g)(x) = f(g(x)) = f(x^2)$.
Now use $f$’s rule, replacing $x$ by $x^2$:
$$
f(x^2) = 2(x^2) + 3 = 2x^2 + 3.
$$
So $(f \circ g)(x) = 2x^2 + 3$.
- $(g \circ f)(x) = g(f(x)) = g(2x + 3)$.
Use $g$’s rule, replacing $x$ by $2x + 3$:
$$
g(2x + 3) = (2x + 3)^2.
$$
So $(g \circ f)(x) = (2x + 3)^2$, which is different from $2x^2 + 3$.
Composition and Domain
The composition $(f \circ g)(x)$ makes sense only when:
- $x$ is in the domain of $g$, and
- $g(x)$ is in the domain of $f$.
So the domain of $f \circ g$ is all $x$ for which $x$ can be safely plugged into $g$, and then $g(x)$ can be safely plugged into $f$.
Example: Let
- $g(x) = \sqrt{x}$ (so $x \ge 0$),
- $f(x) = \dfrac{1}{x - 1}$ (so $x \neq 1$).
For $(f \circ g)(x) = f(g(x)) = \dfrac{1}{\sqrt{x} - 1}$:
- We need $x \ge 0$ so that $\sqrt{x}$ is defined.
- We also need $\sqrt{x} \ne 1$ so that the denominator is not $0$.
$\sqrt{x} \ne 1$ means $x \ne 1$.
So the domain of $f \circ g$ is:
$$
x \ge 0,\quad x \ne 1.
$$
For $(g \circ f)(x) = g(f(x)) = \sqrt{\dfrac{1}{x - 1}}$:
- We need $x \ne 1$ so $f(x)$ is defined.
- We also need $\dfrac{1}{x - 1} \ge 0$ for the square root to be defined.
Analyzing when $\dfrac{1}{x-1} \ge 0$ shows that $x > 1$.
So the domain of $g \circ f$ is:
$$
x > 1.
$$
The domains of $f \circ g$ and $g \circ f$ can be very different.
Composition as “Do This, Then That”
Sometimes functions model steps in a process.
Example: Temperature conversion.
- Let $C(F)$ convert Fahrenheit $F$ to Celsius:
$$
C(F) = \frac{5}{9}(F - 32).
$$ - Let $K(C)$ convert Celsius $C$ to Kelvin:
$$
K(C) = C + 273.15.
$$
The composition $K \circ C$ converts directly from Fahrenheit to Kelvin:
$$
(K \circ C)(F) = K(C(F)) = C(F) + 273.15
= \frac{5}{9}(F - 32) + 273.15.
$$
Now $(K \circ C)(F)$ is one function that does both conversions in one step.
This idea—breaking a complicated process into simpler function steps, or combining steps into a composition—is frequently used in modeling problems.
Inverse Functions
An inverse function, if it exists, “undoes” the action of the original function.
If $f$ sends $x$ to $y$, an inverse function $f^{-1}$ sends $y$ back to $x$.
Symbolically, if $f$ has an inverse:
- $f(x) = y \implies f^{-1}(y) = x$.
Composed, this means:
- $f^{-1}(f(x)) = x$ (start with $x$, do $f$, then $f^{-1}$),
- $f(f^{-1}(x)) = x$ (start with $x$, do $f^{-1}$, then $f$),
whenever these expressions are defined.
Both of these are examples of composition:
$$
f^{-1} \circ f = \text{identity on the domain of } f, \\
f \circ f^{-1} = \text{identity on the domain of } f^{-1}.
$$
The “identity” function on some set is the function that returns its input:
$$
\text{id}(x) = x.
$$
When Does an Inverse Function Exist?
A function $f$ has an inverse function (on its domain) exactly when:
- It never takes two different inputs to the same output.
In more formal terms:
- $f$ must be one-to-one (also called injective):
If $f(a) = f(b)$, then $a = b$.
If $f$ is one-to-one, we can reverse the process: each output came from exactly one input, so we can solve backward and define $f^{-1}$.
If $f$ is not one-to-one, you can often restrict its domain to a smaller interval where it becomes one-to-one, and then define an inverse on that restricted domain.
Example idea (without full trigonometry details): $\sin x$ is not one-to-one on all real numbers, but if you restrict to $[-\frac{\pi}{2}, \frac{\pi}{2}]$, it becomes one-to-one there, and an inverse $\arcsin x$ can be defined on that interval.
How to Find an Inverse Function (Algebraically)
To find $f^{-1}$ from a formula for $f$:
- Write $y = f(x)$.
- Solve this equation for $x$ in terms of $y$.
- Swap the roles of $x$ and $y$: replace the $y$ with $x$ and the solved-for $x$ with $f^{-1}(x)$.
This gives the formula $y = f^{-1}(x)$.
Example: Let $f(x) = 3x - 5$.
- Write:
$$
y = 3x - 5.
$$ - Solve for $x$:
$$
y = 3x - 5 \quad \Rightarrow \quad y + 5 = 3x \quad \Rightarrow \quad x = \frac{y + 5}{3}.
$$ - Swap $x$ and $y$:
$$
y = \frac{x + 5}{3}.
$$
So:
$$
f^{-1}(x) = \frac{x + 5}{3}.
$$
You can check using composition:
- $f(f^{-1}(x)) = 3\cdot \dfrac{x + 5}{3} - 5 = x + 5 - 5 = x$.
- $f^{-1}(f(x)) = \dfrac{3x - 5 + 5}{3} = \dfrac{3x}{3} = x$.
Both compositions give the identity, confirming that this is truly the inverse.
Nonlinear Example
Let $f(x) = (x - 2)^3$.
- Write:
$$
y = (x - 2)^3.
$$ - Solve for $x$:
$$
\sqrt[3]{y} = x - 2 \quad \Rightarrow \quad x = \sqrt[3]{y} + 2.
$$ - Swap $x$ and $y$:
$$
y = \sqrt[3]{x} + 2.
$$
So:
$$
f^{-1}(x) = \sqrt[3]{x} + 2.
$$
Again, you can verify by composition if desired.
Domain and Range Switching
If $f$ has an inverse $f^{-1}$, then:
- The domain of $f$ is the range of $f^{-1}$.
- The range of $f$ is the domain of $f^{-1}$.
So $f$ and $f^{-1}$ swap domain and range with each other.
Example: Let $f(x) = x^3$, with domain all real numbers.
- As $x$ runs over all real numbers, $x^3$ also runs over all real numbers.
So the range of $f$ is all real numbers.
The inverse is $f^{-1}(x) = \sqrt[3]{x}$.
- Its domain and range are also all real numbers.
Here, domain and range of $f$ and $f^{-1}$ are both $\mathbb{R}$, so swapping doesn’t visibly change anything, but the principle still holds.
If a function’s range is more limited, that restriction becomes the inverse’s domain.
Example: Suppose $f(x) = \sqrt{x}$ with domain $[0, \infty)$.
- Its range is also $[0, \infty)$.
- Its inverse is $f^{-1}(x) = x^2$ with domain $[0, \infty)$ (corresponding to the range of $f$).
If instead you restrict $f(x) = e^x$ to domain $\mathbb{R}$, its range is $(0, \infty)$, so the inverse $\ln x$ has domain $(0, \infty)$.
Graphs of Inverse Functions
Graphically, the graphs of $f$ and $f^{-1}$ are mirror images of each other across the line $y = x$.
Each point $(a, b)$ on the graph of $f$ corresponds to the point $(b, a)$ on the graph of $f^{-1}$.
This matches the idea that:
- $f(a) = b \iff f^{-1}(b) = a$.
A common visual test for whether a function has an inverse (without restricting the domain) is the “horizontal line test”:
- If every horizontal line intersects the graph of $f$ in at most one point, then $f$ is one-to-one and has an inverse function (on that domain).
- If some horizontal line hits the graph more than once, $f$ is not one-to-one on that domain, so it has no inverse function defined on that whole domain.
(You can still often restrict the domain to make it one-to-one.)
Composition and Inverses Together
Composition and inverse functions are closely connected:
- If $f$ has an inverse $f^{-1}$, then:
$$
(f^{-1} \circ f)(x) = x \quad \text{for all } x \text{ in the domain of } f
$$
and
$$
(f \circ f^{-1})(x) = x \quad \text{for all } x \text{ in the domain of } f^{-1}.
$$
These equations say: composing a function with its inverse (in either order) gives the identity function on the appropriate set.
This property is what you check when you want to confirm you have found the correct inverse.
Conversely, if you can find a function $g$ such that:
- $(g \circ f)(x) = x$ for all $x$ in the domain of $f$,
- and $(f \circ g)(x) = x$ for all $x$ in some set,
then $g$ is the inverse of $f$ on that set, and you can write $g = f^{-1}$.
Practical Skills from This Chapter
From this chapter, you should be able to:
- Form and simplify compositions like $(f \circ g)(x) = f(g(x))$ and $(g \circ f)(x)$.
- Determine domains of compositions, taking into account both functions.
- Recognize that composition is generally not commutative: $f \circ g$ typically differs from $g \circ f$.
- Understand the idea of an inverse function as “undoing” a function.
- Use the algebraic “swap and solve” method to find $f^{-1}$ when possible.
- Check a proposed inverse by computing compositions and seeing if they simplify to $x$.
- Relate the graphs of a function and its inverse by reflection across the line $y = x$.
- Recognize when a function fails to have an inverse on its full domain and how restricting the domain can fix this.
These ideas will be used heavily in later topics, including logarithms, trigonometric functions, and calculus.