Sub topic 11
Composite functions f(g(x))
Prerequisites
This chapter assumes you can evaluate a function such as f(x) = 2x + 3 at a given input. It also assumes you can find the domain of a function (the set of allowed inputs) and solve linear and quadratic equations. The notation and ideas come from the earlier chapters on function definition and domain and range.
What a composite function is
A composite function feeds the output of one function into another. The notation f(g(x)) means: compute g(x) first, then use that result as the input of f. It is also written (f ∘ g)(x), read "f of g of x" or "f composed with g".
Work from the inside out. The function written closest to x acts first.
Composing with formulas
To get a formula for f(g(x)), replace every x in f's formula with the whole expression g(x).
Take f(x) = 2x + 3 and g(x) = x².
- f(g(x)) = 2·(x²) + 3 = 2x² + 3
- g(f(x)) = (2x + 3)² = 4x² + 12x + 9
The two results differ. Composition is generally not commutative, so f(g(x)) ≠ g(f(x)) in most cases. At x = 1, f(g(1)) = 5 and g(f(1)) = 25. You can check this in code.
def f(x):
return 2 * x + 3
def g(x):
return x ** 2
print(f(g(1))) # f(g(x)) = 2x^2 + 3
print(g(f(1))) # g(f(x)) = (2x + 3)^2The output is 5 and then 25.
Composition is associative: f ∘ (g ∘ h) = (f ∘ g) ∘ h. So a chain such as f(g(h(x))) is unambiguous. Always start at the innermost function.
Composing with numbers
CAT questions often ask for a single value. Compute the inner value first, then pass it outward.
Let f(x) = 3x − 1 and g(x) = x² + 2. Find f(g(2)).
- g(2) = 4 + 2 = 6.
- f(6) = 18 − 1 = 17.
Do not build the full formula when one number is enough. It is slower and invites algebra mistakes.
Domain of a composite function
The domain of f(g(x)) has two requirements:
- x must be in the domain of g.
- g(x) must be in the domain of f.
Skipping the second requirement is a common error.
Take f(x) = √x and g(x) = x − 4.
- f(g(x)) = √(x − 4). We need x − 4 ≥ 0, so x ≥ 4.
- g(f(x)) = √x − 4. We need x ≥ 0.
The two composites have different domains, just as they have different formulas.
A second example: f(x) = 1/(x − 1) and g(x) = x + 1. Then f(g(x)) = 1/x, so x ≠ 0. Simplifying hides nothing here, but consider f(x) = 1/x and g(x) = x². Then f(g(x)) = 1/x², and x = 0 is excluded because g(0) = 0 is not allowed in f.
Repeated composition
Applying the same function repeatedly is written f(f(x)), or fⁿ(x) for n applications. Do not confuse fⁿ(x) with the power (f(x))ⁿ.
For f(x) = 2x + 1:
- f(f(x)) = 2(2x + 1) + 1 = 4x + 3
- f(f(f(x))) = 2(4x + 3) + 1 = 8x + 7
The pattern for this function is fⁿ(x) = 2ⁿx + (2ⁿ − 1). Spotting a pattern after two or three steps is faster than computing many steps, and CAT questions that ask for f applied 10 or 100 times are built for this.
For a linear function f(x) = ax + b, the composite f(f(x)) = a²x + b(a + 1).
Some functions cycle. Let f(x) = 1/(1 − x).
- f(2) = 1/(1 − 2) = −1
- f(−1) = 1/2
- f(1/2) = 2
The values repeat every three applications. So f³(x) = x for any allowed x, and f¹⁰⁰(2) is the same as f¹(2), because 100 = 3·33 + 1. The answer is −1.
Finding an unknown function from a composite
A common question gives f(g(x)) and g(x) and asks for f(x), or the reverse.
Find f when g is known. Let g(x) = x + 2 and f(g(x)) = x² + 4x + 7. Set u = x + 2, so x = u − 2. Then f(u) = (u − 2)² + 4(u − 2) + 7 = u² − 4u + 4 + 4u − 8 + 7 = u² + 3. So f(x) = x² + 3.
Find g when f is known. Let f(x) = 2x + 3 and f(g(x)) = 6x + 5. Then 2·g(x) + 3 = 6x + 5, so g(x) = 3x + 1.
The substitution method (let u equal the inner expression, then solve for x) works whenever the inner function is one-to-one, so that x can be written in terms of u.
Composition with piecewise and modulus functions
When an inner function is piecewise or uses a modulus, decide which piece applies to the inner output, then evaluate the outer function.
Let f(x) = |x − 2| and g(x) = 3x − 1. Find f(g(1)).
- g(1) = 2.
- f(2) = |2 − 2| = 0.
For a general formula, f(g(x)) = |3x − 1 − 2| = |3x − 3| = 3|x − 1|.
When the outer function is piecewise, test which condition g(x) satisfies, not x. For f(x) = x² when x ≥ 0 and f(x) = −x when x < 0, and g(x) = x − 5, evaluate f(g(3)): g(3) = −2, which is below 0, so f(−2) = 2.
Composition and graphs
Composition with simple linear pieces connects to graph transformations.
| Composite | Effect on the graph of f |
|---|---|
| f(x + c) | Shifts left by c (right if c is negative) |
| f(x) + c | Shifts up by c |
| f(−x) | Reflects across the y-axis |
| −f(x) | Reflects across the x-axis |
| f(kx) | Compresses horizontally by factor k (for k > 1) |
In each row, an inner change affects the x-values and an outer change affects the output. Inner changes act "backwards" on the horizontal direction, so f(x + 3) moves the graph left.
Composition and inverse functions
If g is the inverse of f, then f(g(x)) = x and g(f(x)) = x. This gives a quick check for an inverse you have computed.
Let f(x) = 2x + 3. Its inverse is g(x) = (x − 3)/2. Check: f(g(x)) = 2·(x − 3)/2 + 3 = x. The check passes.
If a candidate fails to return x, it is not the inverse.
Common errors
- Wrong order. Reading f(g(x)) left to right and applying f first. Apply g first.
- Partial substitution. Replacing x with g(x) only in one term of f.
- Forgetting parentheses. For f(x) = x², f(x + 1) is (x + 1)², not x² + 1.
- Ignoring the inner domain. The inner function's own restrictions still apply.
- Confusing fⁿ(x) with a power. f²(x) usually means f(f(x)).
Choosing a method in the exam
- If the question asks for a number, compute step by step from the inside.
- If it asks for a formula, substitute carefully with parentheses.
- If it repeats a function many times, compute two or three steps and look for a pattern or a cycle.
- If it gives a composite and asks for one component, use the substitution u = inner expression.
- For domain, list the restrictions of both functions before simplifying.
Exercise
Let f(x) = 1/(1 − x). Find f(f(f(x))) and then evaluate f applied 50 times to x = 3.
Show answer
Compute f(f(x)) = 1/(1 − 1/(1 − x)) = (1 − x)/(−x) = (x − 1)/x. Then f(f(f(x))) = 1/(1 − (x − 1)/x) = 1/((x − (x − 1))/x) = x. So three applications return x, and the sequence cycles with period 3. Since 50 = 3·16 + 2, f⁵⁰(3) = f²(3) = (3 − 1)/3 = 2/3.
Exercise
Let f(x) = √(x − 1) and g(x) = x² − 10. Find the domain of f(g(x)).
Show answer
We need g(x) in the domain of f, so x² − 10 ≥ 1, which gives x² ≥ 11. Hence x ≤ −√11 or x ≥ √11. The domain of g is all real numbers, so there is no further restriction.
Exercise
If g(x) = 2x − 1 and f(g(x)) = 4x² − 2x, find f(x).
Show answer
Let u = 2x − 1, so x = (u + 1)/2. Then 4x² = (u + 1)² and 2x = u + 1. So f(u) = (u + 1)² − (u + 1) = u² + 2u + 1 − u − 1 = u² + u. Therefore f(x) = x² + x. Check at x = 1: g(1) = 1 and f(1) = 2, while 4 − 2 = 2.