Sub topic 4
Finding the domain of a composite function
This chapter assumes you can read function notation such as f(x), state the domain and range of a basic function, solve simple equations and inequalities, and recognize the graphs of lines, parabolas and square roots. It also assumes you know how to evaluate (f∘g)(x) = f(g(x)). Here the focus is on which inputs are allowed.
The working model
A composite function runs two machines in a chain. The input x goes into g, and the output g(x) goes into f. Either machine can reject its input, so two conditions must hold:
- x must be in the domain of g, so that g(x) exists.
- g(x) must be in the domain of f, so that f can accept it.
The domain of f∘g is the set of all x that satisfy both conditions.
A step-by-step method
- Write down the domain of the inner function g.
- Write down the domain of the outer function f.
- Replace f's input with g(x) and solve for the x values that make g(x) legal for f. These are the values you must exclude.
- Intersect the result with the domain of g.
- Describe the answer in interval notation or inequalities.
Worked example 1: a square root outside
Let f(x) = √x and g(x) = x − 4.
- The domain of g is all real numbers.
- The domain of f is x ≥ 0, so g(x) must satisfy x − 4 ≥ 0.
- Solving gives x ≥ 4.
So the domain of f∘g is [4, ∞). Now reverse the order. In (g∘f)(x) = √x − 4, the inner function is √x, which needs x ≥ 0. The outer function g accepts anything. The domain of g∘f is [0, ∞).
The two orders give different domains as well as different formulas. This is the domain version of the order effect from the previous chapter.
Worked example 2: a fraction outside, a square root inside
Let f(x) = 1/(x − 2) and g(x) = √x.
- Condition 1: g needs x ≥ 0.
- Condition 2: f rejects only the input 2, so we need g(x) ≠ 2. That means √x ≠ 2, so x ≠ 4.
The domain of f∘g is x ≥ 0 with x ≠ 4, which is [0, 4) ∪ (4, ∞).
The excluded value 4 does not appear in the domain of g or in the domain of f. It appears only when the two are combined. This is why you must work through the chain and not just compare the two separate domains.
The following Python script tests this by trying each input and catching the errors a real function would raise.
import math
def f(x):
return 1 / (x - 2)
def g(x):
return math.sqrt(x)
def f_of_g(x):
return f(g(x))
def is_defined(func, x):
try:
func(x)
return True
except (ValueError, ZeroDivisionError):
return False
for x in [-1, 0, 4, 9]:
print(x, is_defined(f_of_g, x))
# -1 False (g fails: square root of a negative number)
# 0 True
# 4 False (g works and returns 2.0, then f divides by zero)
# 9 TrueThe input -1 fails at the first check, and 4 fails at the second. The values 0 and 9 pass both.
Worked example 3: when both functions restrict the input
Let f(x) = √(x − 1) and g(x) = 1/x.
- Condition 1: g needs x ≠ 0.
- Condition 2: f needs g(x) ≥ 1, so 1/x ≥ 1.
Solve 1/x ≥ 1 carefully. If x < 0, then 1/x is negative, which fails. If x > 0, multiplying by x keeps the inequality direction, so 1 ≥ x. Together the solution is 0 < x ≤ 1.
This already excludes x = 0, so condition 1 adds nothing new here. The domain is (0, 1].
Summary of the examples
| f | g | Domain of g | Extra restriction from f | Domain of f∘g |
|---|---|---|---|---|
| √x | x − 4 | all reals | x − 4 ≥ 0 | [4, ∞) |
| 1/(x − 2) | √x | x ≥ 0 | √x ≠ 2, so x ≠ 4 | [0, 4) ∪ (4, ∞) |
| √(x − 1) | 1/x | x ≠ 0 | 1/x ≥ 1 | (0, 1] |
The simplification trap
Sometimes the simplified composite looks like a function with a bigger domain. The true domain is still the one found from the chain.
Take f(x) = x² and g(x) = √x. Then f(g(x)) = (√x)², which simplifies to x. The simplified formula x accepts every real number. But g rejects negative inputs, so the composite's domain is only x ≥ 0.
import math
def f(x):
return x ** 2
def g(x):
return math.sqrt(x)
def composite(x):
return f(g(x))
def simplified(x):
return x
print(composite(9), simplified(9)) # 9.0 9
print(simplified(-4)) # -4, but this is not f(g(-4))
try:
composite(-4)
except ValueError as error:
print("composite fails at -4:", error)The composite and its simplification agree on x ≥ 0 and disagree everywhere else, because the composite is undefined for negative x.
A second case: f(x) = 1/x and g(x) = 1/x. The composite is f(g(x)) = 1/(1/x), which simplifies to x. But x = 0 is not in the domain of g, so 0 is excluded from the composite. The composite is "x, for x ≠ 0".
Common errors
- Intersecting the two separate domains. The domain of f∘g is not "domain of f ∩ domain of g." The condition on f applies to g(x), not to x. In example 2, the domains of f and g overlap on x ≥ 0 excluding 2, but the real exclusion is 4.
- Using the simplified formula. See the trap above. Always collect restrictions before simplifying.
- Forgetting the inner domain. If g(x) is always accepted by f, the domain is still limited by g itself. For f(x) = x + 1 and g(x) = √x, the composite is √x + 1 with domain x ≥ 0.
- Mixing up the order. In f∘g, g is applied first, so g is the function whose domain you check first.
- Wrong inequality handling. Squaring, reciprocals and multiplication by a variable can reverse or split an inequality. Test a value from each region you find.
A quick check using the range
A useful sanity test is to compare the range of g with the domain of f. The composite is defined at x exactly when g(x) lands in the domain of f. If the range of g sits entirely inside the domain of f, then f imposes no extra restriction, and the domain of f∘g equals the domain of g. For example, with f(x) = √x and g(x) = x² + 1, the range of g is [1, ∞), which lies inside [0, ∞). The domain of f∘g is therefore all real numbers.
Exercise
Let f(x) = √(x + 3) and g(x) = x². Find the domain of f∘g and the domain of g∘f.
Show answer
For f∘g = √(x² + 3), the inner function g accepts all reals, and f needs x² + 3 ≥ 0. This is always true, so the domain is all real numbers. For g∘f = (√(x + 3))² the inner function f needs x + 3 ≥ 0, so x ≥ -3. The outer function g accepts anything. The domain of g∘f is [-3, ∞), even though the formula simplifies to x + 3.
Exercise
Let f(x) = 1/(x − 1) and g(x) = 2/x. Find the domain of f∘g and write the simplified formula.
Show answer
Condition 1: g needs x ≠ 0. Condition 2: f rejects 1, so g(x) ≠ 1. That means 2/x ≠ 1, so x ≠ 2. The domain is all reals except 0 and 2. The formula is f(g(x)) = 1/(2/x − 1) = x/(2 − x), which is defined at x = 0 on its own. The composite still excludes 0, because g(0) is undefined.