Sometimes the output of one function becomes the input of another. The distance you drive depends on time, the fuel you burn depends on distance, and the cost depends on the fuel. Chaining functions like this is called composition, and it gives you a single function that goes straight from the first input to the final output.
Read it from the inside out: first apply g to x, then apply f to the result. Picture two function machines in a row. The number x goes into machine g, and whatever comes out goes straight into machine f.
xgg(x)ff(g(x))
For example, if g(x)=x+1 and f(x)=x2, then f(g(3))=f(4)=16.
In general, f(g(x))=g(f(x)). With the same functions, g(f(3))=g(9)=10, not 16. “Add 1, then square” is a different process from “square, then add 1”. Occasionally the two orders do agree (for example, a function and its inverse), but you can never assume it.
From tables: find g(x) in the g table, then look up that number in the f table.
From graphs: read g(x) from the graph of g (go up or down from x to the graph). Then use that output as the new input on the graph of f.
From equations: substitute the whole expression for g(x) in place of every x in f(x). Use brackets.
Reading compositions from graphs: here f(x)=x2−2 and g(x)=−x+3.
To find f(g(1)) from the graphs above: the line gives g(1)=2, and then the parabola gives f(2)=2. So f(g(1))=2. In the other order, f(1)=−1, and then g(−1)=4, so g(f(1))=4.
x is in the domain of f∘g when both of these are true:
x is in the domain of g (so g(x) exists), and
g(x) is in the domain of f (so f can accept it).
Find the domain from these conditions, not just from the simplified formula, which can hide a restriction (Example 3 shows how). For the range, think about which values of g(x) actually get fed into f, and what f does to them.
Going backwards, you can often split a complicated function into an “inside” and an “outside” function. For h(x)=(5x−2)3, the inside is g(x)=5x−2 and the outside is f(x)=x3, so h(x)=f(g(x)). Decomposing is useful for seeing how a function was built, and you’ll use it constantly in calculus.
Let f(x)=x and g(x)=4−x2. Find f(g(x)) and g(f(x)), and state the domain and range of each.
Solution.
f(g(x)).
f(g(x))=4−x2
g accepts every real number, but f can only take inputs that are ≥0. So we need 4−x2≥0, which means x2≤4, or −2≤x≤2.
For these x-values, 4−x2 goes from 0 (at x=±2) up to 4 (at x=0). Taking square roots gives values from 0 to 2.
Domain: {x∈R∣−2≤x≤2}Range: {y∈R∣0≤y≤2}
(The graph is the top half of a circle with radius 2.)
g(f(x)).
g(f(x))=4−(x)2=4−x
It looks like a line, but the first step is x, which needs x≥0. So the domain is {x∈R∣x≥0}, and the graph is only the part of y=4−x starting at (0,4). As x grows from 0, 4−x falls from 4, so the range is {y∈R∣y≤4}.
A delivery van drives on the highway at 100 km/h, so after t hours it has gone d(t)=100t km. It uses 7.5 L of fuel per 100 km, so F(d)=0.075d litres for d kilometres. Fuel costs $1.60 per litre, so C(F)=1.60F dollars.
(a) Find C(F(d(t))) and explain what it means.
(b) How much does the fuel cost for a 4.5-hour drive?
C(F(d(t)))=12t is the fuel cost, in dollars, of driving for t hours: the van burns $12 of fuel per hour. Composition skipped the middle steps and went straight from time to cost.
(b) 12(4.5)=54, so the fuel costs $54.
Check step by step: 4.5 h gives 450 km, which uses 0.075(450)=33.75 L, which costs 1.60(33.75)=54.00, or $54.00. ✓
Working from the outside in.f(g(x)) means g first, then f, even though f is written first. Start with the innermost brackets.
Multiplying instead of composing.f(g(x)) is not f(x)⋅g(x). For f(x)=x2+1 and g(x)=3x−2, the product is 3x3−2x2+3x−2, but the composition is 9x2−12x+5.
Forgetting brackets when substituting.f(x)=x2+1 with x=3x−2 gives (3x−2)2+1, not 3x−22+1 or 3x2−2+1.
Reading the domain from the simplified formula. In Example 3, g(f(x)) simplifies to 4−x, but x=−5 isn’t allowed, because f(−5)=−5 doesn’t exist. Check the inside function first.
Reusing the x-value on a graph. After you find g(1)=2, the next input is 2, not 1. Move to x=2 on the graph of f.
Assuming f(g(x)) = g(f(x)). It’s usually false. Example 1 and Example 2 both show different answers in the two orders.
Check: f(g(1))=f(3)=9−9=0 and g(f(1))=g(−2)=0. ✓ So the two orders agree only at x=1.
5. (Core) Let f(x)=x−11 and g(x)=x2. Find f(g(x)) and g(f(x)), and state the domain of each.
Solutionf(g(x))=x2−11
f can’t accept 1, so we need x2=1: the domain is {x∈R∣x=±1}.
g(f(x))=(x−11)2=(x−1)21
f(x) needs x=1, and g accepts anything. The domain is {x∈R∣x=1}.
6. (Core) Find functions f and g so that h(x)=f(g(x)). (There’s more than one answer; give the most natural one.)
(a) h(x)=(5x−2)3
(b) h(x)=x2+9
(c) h(x)=23x+1
(d) h(x)=(x+4)21
Solution
Look for the “inside” expression and call it g(x).
(a) g(x)=5x−2 and f(x)=x3.
(b) g(x)=x2+9 and f(x)=x.
(c) g(x)=3x+1 and f(x)=2x.
(d) g(x)=x+4 and f(x)=x21. (Another answer: g(x)=(x+4)2 and f(x)=x1.)
7. (Core) Oil leaking from a tanker spreads in a circle on the water. The radius after t minutes is r(t)=4t metres, and the area of a circle is A(r)=πr2.
(a) Find A(r(t)) and explain what it represents.
(b) Find the area after 5 minutes.
(c) When does the area reach 2000 m²?
Solution
(a) A(r(t))=π(4t)2=16πt2. It’s the area of the slick, in square metres, t minutes after the leak starts.
(b) A(r(5))=16π(25)=400π≈1256.64 m².
(c) Solve 16πt2=2000 with t>0:
t2=16π2000≈39.79⇒t≈6.31
The area reaches 2000 m² after about 6.31 minutes.
8. (Challenge) Let f(x)=2x+3. Find g(x) if f(g(x))=6x2−1.
Solution
f doubles its input and adds 3, so f(g(x))=2g(x)+3. Set this equal to the given expression:
2g(x)+32g(x)g(x)=6x2−1=6x2−4=3x2−2
Check: f(3x2−2)=2(3x2−2)+3=6x2−1. ✓
9. (Challenge) Let f(x)=x−21. Find f(f(x)) in simplest form and state its domain.
Solutionf(f(x))=x−21−21
Multiply the top and bottom by (x−2):
f(f(x))=1−2(x−2)x−2=5−2xx−2
Domain: the inside f(x) needs x=2. The outside f can’t accept 2, so we also need x−21=2, which means x−2=21, or x=25. (That matches the denominator 5−2x=0.)
{x∈Rx=2,x=25}
Notice that x=2 is excluded even though the simplified formula gives 10=0 there.