Table of Contents
Function composition is a way to combine two (or more) functions into a new function by feeding the output of one function into the input of another. In this chapter we focus on:
- How to write and read compositions.
- How to compute compositions numerically and algebraically.
- Domain issues specific to compositions.
- Recognizing when functions “undo” each other through composition (preparing for inverse functions).
Throughout, we assume you already understand the basic idea of a function as an input–output rule and the notation $f(x)$ from earlier chapters.
Notation and Reading Compositions
Given two functions $f$ and $g$, the composition of $f$ with $g$ is written
$$
(f \circ g)(x)
$$
and is read as “$f$ of $g$ of $x$.”
By definition,
$$
(f \circ g)(x) = f(g(x)).
$$
This means:
- Start with $x$.
- First apply $g$ to $x$ to get $g(x)$.
- Then apply $f$ to that result, so you get $f(g(x))$.
Order matters: in $(f \circ g)(x)$, the function written on the right ($g$) is applied first.
Similarly,
$$
(g \circ f)(x) = g(f(x)).
$$
In general,
$$
(f \circ g)(x) \neq (g \circ f)(x),
$$
so you must pay close attention to the order.
Example of Different Orders
Let
$$
f(x) = x + 2, \quad g(x) = 3x.
$$
Compute:
- $(f \circ g)(x) = f(g(x)) = f(3x) = 3x + 2$.
- $(g \circ f)(x) = g(f(x)) = g(x+2) = 3(x+2) = 3x + 6$.
These two resulting functions are different, so $(f \circ g) \neq (g \circ f)$.
Step-by-Step Procedure for Computing $(f \circ g)(x)$
Suppose $f$ and $g$ are given by formulas.
- Identify the inner and outer functions.
In $(f \circ g)(x)$, $g$ is the inner function, and $f$ is the outer function. - Write $g(x)$.
This is the expression that will be substituted into $f$. - Take the formula for $f(x)$ and replace its input with $g(x)$.
Wherever $x$ appears in the formula for $f(x)$, replace it with the entire expression $g(x)$. - Simplify the resulting expression, if needed.
Example: Polynomial with a Square
Let
$$
f(x) = x^2 + 1, \quad g(x) = 2x - 3.
$$
Compute $(f \circ g)(x)$:
- Inner function: $g(x) = 2x - 3$.
- Outer function: $f(x) = x^2 + 1$.
- Substitute $g(x)$ into $f$:
$$
(f \circ g)(x) = f(g(x)) = f(2x - 3) = (2x - 3)^2 + 1.
$$ - Simplify:
$$
(2x - 3)^2 = 4x^2 - 12x + 9,
$$
so
$$
(f \circ g)(x) = 4x^2 - 12x + 9 + 1 = 4x^2 - 12x + 10.
$$
Compute $(g \circ f)(x)$ with the same functions:
- Inner: $f(x) = x^2 + 1$.
- Outer: $g(x) = 2x - 3$.
- Substitute:
$$
(g \circ f)(x) = g(f(x)) = g(x^2 + 1) = 2(x^2 + 1) - 3.
$$ - Simplify:
$$
2(x^2 + 1) - 3 = 2x^2 + 2 - 3 = 2x^2 - 1.
$$
Again, $(f \circ g)(x)$ and $(g \circ f)(x)$ differ.
Evaluating Compositions at Specific Numbers
Sometimes you are asked for a specific value like $(f \circ g)(2)$ rather than a formula.
Using the definition,
$$
(f \circ g)(2) = f(g(2)).
$$
Work from the inside out:
- Compute $g(2)$.
- Then plug that result into $f$.
Example
Let
$$
f(x) = x^2 + 4, \quad g(x) = x - 1.
$$
Compute $(f \circ g)(2)$:
- $g(2) = 2 - 1 = 1$.
- $f(g(2)) = f(1) = 1^2 + 4 = 5$.
So $(f \circ g)(2) = 5$.
Similarly, $(g \circ f)(2) = g(f(2))$:
- $f(2) = 2^2 + 4 = 8$.
- $g(8) = 8 - 1 = 7$.
So $(g \circ f)(2) = 7$.
Domain Issues in Composition
The domain of a composition is more restrictive than it might first appear. For $(f \circ g)(x) = f(g(x))$ to make sense at a particular $x$:
- $x$ must be in the domain of $g$ (so $g(x)$ is defined).
- $g(x)$ must lie in the domain of $f$.
So the domain of $f \circ g$ is:
- All $x$ for which $x$ is in the domain of $g$ and
- $g(x)$ is in the domain of $f$.
Example: Square Root After a Linear Function
Let
$$
f(x) = \sqrt{x}, \quad g(x) = 2x - 3.
$$
For $f(x) = \sqrt{x}$, the domain is $x \ge 0$ (real-valued square root). For $g(x) = 2x - 3$, the domain is all real numbers.
Now consider $(f \circ g)(x) = \sqrt{2x - 3}$.
To be defined, the expression under the square root must be non-negative:
$$
2x - 3 \ge 0 \quad \Rightarrow \quad x \ge \frac{3}{2}.
$$
So the domain of $f \circ g$ is $x \ge \dfrac{3}{2}$.
Note: $g$ alone is defined for all real $x$, but $f(g(x))$ is not, because $g(x)$ must also be non-negative to be used as input to $f$.
Example: Denominator After a Function
Let
$$
f(x) = \frac{1}{x - 1}, \quad g(x) = x^2.
$$
Domain of $f$: all real $x$ with $x \neq 1$.
Domain of $g$: all real $x$.
Consider $(f \circ g)(x)$:
$$
(f \circ g)(x) = f(g(x)) = f(x^2) = \frac{1}{x^2 - 1}.
$$
We must avoid values where the denominator is zero:
$$
x^2 - 1 \neq 0 \quad \Rightarrow \quad x^2 \neq 1 \quad \Rightarrow \quad x \neq \pm 1.
$$
Thus, the domain of $f \circ g$ is all real $x$ except $x = 1$ or $x = -1$.
Here the extra restriction $x \neq -1$ appears not from $f$ or $g$ alone, but from how $g(x)$ interacts with $f$ inside the composition.
Decomposing a Function into Simpler Functions
Sometimes you are given a complicated function $h(x)$ and asked to think of it as a composition of two simpler functions $f$ and $g$ such that $h = f \circ g$. This is called decomposing a function.
You look for an “inner” expression and an “outer” pattern.
Strategy
Given a function $h(x)$:
- Try to see $h(x)$ as “something” applied to a simpler expression.
- Let $g(x)$ be that simpler inner expression.
- Let $f(u)$ (use $u$ as a placeholder) be the rule that acts on the inner expression to produce $h(x)$ when $u = g(x)$.
Then $h(x) = f(g(x))$.
Example 1
Suppose
$$
h(x) = (3x - 5)^4.
$$
You might choose:
- Inner function: $g(x) = 3x - 5$.
- Outer function: $f(u) = u^4$.
Then
$$
(f \circ g)(x) = f(g(x)) = (3x - 5)^4 = h(x).
$$
Example 2
Suppose
$$
h(x) = \sqrt{1 + x^2}.
$$
One possible decomposition:
- Inner: $g(x) = 1 + x^2$.
- Outer: $f(u) = \sqrt{u}$.
Then $f(g(x)) = \sqrt{1 + x^2}$.
Note that decompositions are often not unique; there may be different valid choices of $f$ and $g$ whose composition gives the same $h$.
Composition and “Undoing” (Connection to Inverses)
Function composition is central to the idea of inverse functions (explored in the next chapter). Here we just highlight the basic connection without going into full detail.
If $f$ and $g$ are inverse functions of each other, then their compositions behave like doing and undoing an action:
- $(f \circ g)(x) = x$ (for all $x$ where this makes sense),
- $(g \circ f)(x) = x$ (on an appropriate domain).
This is similar to how adding 3 and then subtracting 3 brings you back to where you started.
Example (Informal)
Let
$$
f(x) = 3x + 1, \quad g(x) = \frac{x - 1}{3}.
$$
Then
$$
(f \circ g)(x) = f\!\left(\frac{x - 1}{3}\right)
= 3\left(\frac{x - 1}{3}\right) + 1
= x - 1 + 1
= x,
$$
and
$$
(g \circ f)(x) = g(3x + 1)
= \frac{(3x + 1) - 1}{3}
= \frac{3x}{3}
= x.
$$
So $f$ and $g$ undo each other via composition. This is the core behavior that inverse functions formalize.
Common Types of Composition Examples
Here are several standard patterns you will encounter when practicing composition.
Polynomial–Polynomial Composition
Let
$$
f(x) = x^2 - 1, \quad g(x) = 2x + 3.
$$
Then
$$
(f \circ g)(x) = f(2x + 3) = (2x + 3)^2 - 1 = 4x^2 + 12x + 9 - 1 = 4x^2 + 12x + 8.
$$
Trigonometric and Algebraic Composition
Let
$$
f(x) = \sin x, \quad g(x) = x^2.
$$
Then
$$
(f \circ g)(x) = f(x^2) = \sin(x^2),
$$
and
$$
(g \circ f)(x) = g(\sin x) = (\sin x)^2.
$$
These are different functions: $\sin(x^2)$ vs $(\sin x)^2$.
Exponential and Logarithmic Composition (Where Defined)
Let
$$
f(x) = e^x, \quad g(x) = \ln x,
$$
with $x > 0$ to make $\ln x$ defined.
Then
$$
(f \circ g)(x) = f(\ln x) = e^{\ln x} = x \quad \text{(for } x > 0\text{)},
$$
while
$$
(g \circ f)(x) = g(e^x) = \ln(e^x) = x,
$$
for all real $x$. These are classic examples of functions that act as inverses on appropriate domains.
Multiple Compositions
You can compose more than two functions by applying them in stages, always from the innermost outward.
For example, if
$$
h(x) = (f \circ g \circ k)(x),
$$
this means
$$
h(x) = f(g(k(x))).
$$
You apply $k$ first, then $g$, then $f$.
Example
Let
$$
k(x) = x - 2,\quad g(x) = x^2,\quad f(x) = \sqrt{x},
$$
with $\sqrt{\cdot}$ understood for non-negative inputs.
Compute $h(x) = (f \circ g \circ k)(x)$:
- $k(x) = x - 2$.
- $g(k(x)) = (x - 2)^2$.
- $f(g(k(x))) = \sqrt{(x - 2)^2}$.
So
$$
h(x) = \sqrt{(x - 2)^2}.
$$
If we restrict to $x \ge 2$, then $\sqrt{(x - 2)^2} = x - 2$; domain considerations again influence the final form.
Summary
- Composition combines functions: $(f \circ g)(x) = f(g(x))$.
- Order is crucial: $(f \circ g)(x)$ is usually different from $(g \circ f)(x)$.
- To compute $(f \circ g)(x)$:
- Identify inner and outer functions.
- Substitute $g(x)$ into the formula for $f$.
- Simplify and respect domain restrictions.
- The domain of $f \circ g$ consists of all $x$ for which $g(x)$ is defined and $g(x)$ lies in the domain of $f$.
- Functions can often be decomposed into simpler functions via composition.
- Composition is the algebraic setting in which “doing” and “undoing” (inverse functions) are expressed: inverses satisfy $f \circ g = g \circ f = \text{id}$ on appropriate domains.
These ideas prepare you to study inverse functions more deeply in the next chapter.