Sub topic 13
The Domain of a Composite Function
This chapter assumes you can evaluate a function at a number, find the domain of a single function by excluding division by zero and negative numbers under even roots, and write answers in interval notation. It also assumes you can solve simple inequalities.
What a composite function is
A composite function feeds the output of one function into another. The notation (f ∘ g)(x) means f(g(x)). You read it as "f of g of x". The function g works first, and f works on g's result.
For example, let f(x) = x + 1 and g(x) = 2x. Then f(g(x)) = f(2x) = 2x + 1. In the other order, g(f(x)) = g(x + 1) = 2(x + 1) = 2x + 2. The two orders generally give different functions, so the order matters.
Two conditions for an input
An input x can be used in f(g(x)) only if both of these hold:
- x is in the domain of g, because g runs first.
- g(x) is in the domain of f, because f receives g's output.
The domain of f ∘ g is the set of all x that satisfy both conditions. Condition 1 limits the inputs directly. Condition 2 limits them indirectly, by limiting what g may produce.
A procedure that works every time
- Find the domain of the inner function g. Write down any restrictions on x.
- Take the restrictions on f's input, and replace f's input variable with the expression g(x). This gives a condition on x.
- Solve that condition for x.
- Intersect the results of steps 1 and 3. Write the answer in interval notation.
Do this before you simplify f(g(x)). Simplifying can hide a restriction, as the later sections show.
Worked example 1: an even root on the outside
Let f(x) = √x and g(x) = x − 3.
- Step 1: g is a polynomial, so its domain is all real numbers.
- Step 2: f needs a non-negative input, so g(x) ≥ 0. That means x − 3 ≥ 0.
- Step 3: x ≥ 3.
- Step 4: all reals intersected with x ≥ 3 gives [3, ∞).
So f(g(x)) = √(x − 3) has domain [3, ∞). Here the outside function adds a restriction that g alone does not have.
Now reverse the order. g(f(x)) = √x − 3. The inner function is f, so x must satisfy x ≥ 0. The output of f is any non-negative number, and g accepts all reals. The domain is [0, ∞). The two orders give different domains.
Worked example 2: a quadratic inside a root
Let f(x) = √x and g(x) = 4 − x².
- g accepts every real number.
- f needs 4 − x² ≥ 0, which means x² ≤ 4, so −2 ≤ x ≤ 2.
The domain of f(g(x)) = √(4 − x²) is [−2, 2].
A common mistake is to solve x² ≤ 4 and write x ≤ 2 only. The inequality x² ≤ 4 is not the same as x ≤ 2. For x = −5, x ≤ 2 is true, but x² = 25 is greater than 4. Check a test value from each region if you are unsure.
Worked example 3: a denominator on the outside
Let f(x) = 1/(x − 1) and g(x) = √x.
- Step 1: g needs x ≥ 0.
- Step 2: f cannot take the input 1, so g(x) ≠ 1. That means √x ≠ 1, so x ≠ 1.
- Step 4: x ≥ 0 and x ≠ 1 gives [0, 1) ∪ (1, ∞).
Both conditions matter here. If you check only condition 2, you would allow x = −4. The expression 1/(√x − 1) is undefined there because √(−4) is not a real number.
Worked example 4: restrictions on both functions
Let f(x) = √x and g(x) = 1/x.
- Step 1: g needs x ≠ 0.
- Step 2: f needs 1/x ≥ 0.
- Step 3: 1/x is positive exactly when x is positive. It is never zero. So x > 0.
- Step 4: x ≠ 0 and x > 0 gives (0, ∞).
In this example, condition 2 already implies condition 1. This is common, but you should still write both down so nothing is missed.
The simplification trap
The domain belongs to the composite as it is built, not to the simplified formula. Consider these two cases.
Case A. Let f(x) = 1/x and g(x) = 1/x. Then f(g(x)) = 1/(1/x) = x. The simplified formula x accepts every real number. But g(0) is undefined, so 0 is not in the domain. The true domain is (−∞, 0) ∪ (0, ∞).
Case B. Let f(x) = x² and g(x) = √x. Then f(g(x)) = (√x)² = x after simplifying. The simplified formula accepts negative numbers. But g needs x ≥ 0, so the true domain is [0, ∞).
Checking your answer in code
The Python functions below check each condition separately. They raise an error that names the stage that rejected the input. This mirrors the two conditions.
import math
def g(x):
if x == 0:
raise ValueError("x is not in the domain of g")
return 1 / x
def f(x):
if x < 0:
raise ValueError("g(x) is not in the domain of f")
return math.sqrt(x)
def composite(x):
return f(g(x))
for x in [4, 0.25, 0, -2]:
try:
print(x, "->", composite(x))
except ValueError as error:
print(x, "-> rejected:", error)The output is:
4 -> 0.5
0.25 -> 2.0
0 -> rejected: x is not in the domain of g
-2 -> rejected: g(x) is not in the domain of fThe input 0 fails condition 1. The input −2 passes condition 1 because g(−2) = −0.5 exists, but it fails condition 2 because f cannot take −0.5. Only positive inputs survive, which matches the domain (0, ∞) from example 4.
Summary of the main cases
| Outer function f | Inner function g | Extra condition on x |
|---|---|---|
| Even root, √u | any | g(x) ≥ 0 |
| Fraction, 1/(u − a) | any | g(x) ≠ a |
| Polynomial | has a restriction | only g's restriction |
| Polynomial | polynomial | none, the domain is all reals |
Here u stands for f's input. The first two rows add a condition that comes from f. The last two rows add nothing beyond g's own domain.
Composites built from a table or a graph
Sometimes f and g are given as tables or graphs instead of formulas. The same two conditions apply.
Suppose g has the table pairs (1, 4), (2, 6), (3, 8), and f has the table pairs (4, 10), (8, 20). The domain of g is {1, 2, 3}. Now check each input:
- x = 1: g(1) = 4, and 4 is in the domain of f. So f(g(1)) = 10.
- x = 2: g(2) = 6, but 6 is not in the domain of f. So 2 is rejected.
- x = 3: g(3) = 8, and 8 is in the domain of f. So f(g(3)) = 20.
The domain of f ∘ g is {1, 3}. With discrete data you check each element, with no inequalities needed.
Common errors
- Using only f's domain. The inputs to f ∘ g are values of x, which first go through g. Check g's domain too.
- Using only g's domain. The output of g must also be acceptable to f.
- Mixing up the order. In f(g(x)), g is the inner function. Writing f(x) = √x and g(x) = x − 3 does not make g(f(x)) the same as f(g(x)).
- Substituting into the wrong place. When f needs u ≥ 0, replace u with g(x), not with x. For f(x) = √x and g(x) = x − 3, the condition is x − 3 ≥ 0, not x ≥ 0.
- Forgetting an excluded point after simplifying. Keep the exclusions from g even when the final formula looks harmless.
Exercises
Exercise
Let f(x) = √(x + 1) and g(x) = x² − 5. Find the domain of f(g(x)) in interval notation.
Show answer
g accepts all reals. f needs its input to be at least −1, because x + 1 ≥ 0 means x ≥ −1. Substituting g(x) for the input gives x² − 5 ≥ −1, so x² ≥ 4. This means x ≤ −2 or x ≥ 2. The domain is (−∞, −2] ∪ [2, ∞). Check: f(g(x)) = √(x² − 4), and x = 0 gives √(−4), which is correctly excluded.
Exercise
Let f(x) = 1/(x − 3) and g(x) = √x. Find the domain of f(g(x)).
Show answer
g needs x ≥ 0. f cannot take the input 3, so √x ≠ 3, which means x ≠ 9. The domain is [0, 9) ∪ (9, ∞).
Exercise
Let f(x) = x² and g(x) = √(x − 1). Simplify f(g(x)), then state its true domain and explain why it differs from the domain of the simplified formula.
Show answer
f(g(x)) = (√(x − 1))² = x − 1. The simplified formula x − 1 accepts all real numbers. But g needs x − 1 ≥ 0, so x ≥ 1. The true domain is [1, ∞). The input x = 0, for example, is not allowed because √(−1) is not a real number, even though the simplified formula would give −1.
Exercise
Let g have the table pairs (0, 2), (1, 5), (2, 9), and let f have the table pairs (2, 7), (5, 8), (6, 1). List the domain of f ∘ g and the output values.
Show answer
Check each input of g. g(0) = 2 is in the domain of f, so f(g(0)) = 7. g(1) = 5 is in the domain of f, so f(g(1)) = 8. g(2) = 9 is not in the domain of f, so 2 is rejected. The domain of f ∘ g is {0, 1}, and the outputs are 7 and 8.