Sub topic 13
The Domain of a Composite Function
Prerequisites and the composition rule
Assume you can work with function notation, domains, inequalities, square roots, and rational expressions. You should also know that a domain is the set of allowed inputs.
A composite function applies one function and then applies another function to the result. If the first function is \(g\) and the second is \(f\), the composition is written
\[ (f \circ g)(x)=f(g(x)). \]
Read this as “\(f\) composed with \(g\).” The function \(g\) acts first because it is inside the parentheses.
The domain of \(f \circ g\) has two requirements:
- \(x\) must be in the domain of \(g\).
- The output \(g(x)\) must be in the domain of \(f\).
Therefore,
\[ \operatorname{Dom}(f\circ g) = \{x\in\operatorname{Dom}(g):g(x)\in\operatorname{Dom}(f)\}. \]
The second requirement is the one that is easy to miss.
A step-by-step example
Let
\[ f(x)=\sqrt{x-2} \quad\text{and}\quad g(x)=x^2+1. \]
The domain of \(f\) is \(x\ge 2\), because the expression under an even root cannot be negative. The domain of \(g\) is all real numbers because a polynomial has no denominator or even-root restriction.
Now compose the functions:
\[ (f\circ g)(x)=f(g(x)) =\sqrt{(x^2+1)-2} =\sqrt{x^2-1}. \]
The expression is defined only when
\[ x^2-1\ge 0. \]
Factoring gives
\[ (x-1)(x+1)\ge 0, \]
so
\[ x\le -1\quad\text{or}\quad x\ge 1. \]
Thus,
\[ \operatorname{Dom}(f\circ g)=(-\infty,-1]\cup[1,\infty). \]
Although \(g\) accepts every real input, some of its outputs are less than 2. Those outputs cannot be used as inputs for \(f\).
A hidden restriction
Suppose
\[ f(x)=\frac{1}{x-3} \quad\text{and}\quad g(x)=x+3. \]
Then
\[ (f\circ g)(x)=\frac{1}{(x+3)-3}=\frac{1}{x}. \]
The domain excludes \(x=0\). The original function \(f\) excludes input 3, and \(g(0)=3\), so \(x=0\) cannot be used.
Do not cancel or simplify an expression and then forget restrictions inherited from the original functions.
| Function | Domain condition |
|---|---|
| \(f(x)=\sqrt{x-2}\) | \(x\ge 2\) |
| \(g(x)=1/(x+3)\) | \(x\ne -3\) |
| \(f(g(x))\) | \(x\in\operatorname{Dom}(g)\) and \(g(x)\ge 2\) |
Composition order matters
Usually,
\[ (f\circ g)(x)\ne(g\circ f)(x). \]
For the first example,
\[ (g\circ f)(x)=g(\sqrt{x-2}) =(\sqrt{x-2})^2+1=x-1. \]
Here the domain is \(x\ge 2\), inherited from \(f\). The two compositions have different formulas and different domains.
import math
def f(value):
if value < 2:
raise ValueError("f requires an input of at least 2")
return math.sqrt(value - 2)
def g(x):
return x ** 2 + 1
def composition(x):
return f(g(x))
for x in (-2, 0, 2):
try:
print(x, composition(x))
except ValueError as error:
print(x, error)Exercise
Let f(x) = 1/(x - 4) and g(x) = 2x. Find the domain of (f ◦ g)(x).
Show answer
(f ◦ g)(x) = 1/(2x - 4), so 2x - 4 ≠ 0. The domain is (-∞, 2) ∪ (2, ∞).