Skip to content
Family Table Math
Auto

Composition of Functions

Sometimes the output of one function becomes the input of another. The distance you cycle depends on time, the energy you burn depends on distance, and the snacks you need depend on the energy. 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.

The composition of ff and gg is

(f∘g)(x)=f(g(x))(f \circ g)(x) = f\big(g(x)\big)

Read it from the inside out: first apply gg to xx, then apply ff to the result. Picture two function machines in a row. The number xx goes into machine gg, and whatever comes out goes straight into machine ff.

x  →  g    g(x)  →  f    f(g(x))x \;\xrightarrow{\;g\;}\; g(x) \;\xrightarrow{\;f\;}\; f\big(g(x)\big)

For example, if g(x)=x+1g(x) = x + 1 and f(x)=x2f(x) = x^2, then f(g(3))=f(4)=16f(g(3)) = f(4) = 16.

In general, f(g(x))≠g(f(x))f(g(x)) \ne g(f(x)). With the same functions, g(f(3))=g(9)=10g(f(3)) = g(9) = 10, not 1616. “Add 11, then square” is a different process from “square, then add 11”. Occasionally the two orders do agree (for example, a function and its inverse), but you can never assume it.

  • From tables: find g(x)g(x) in the gg table, then look up that number in the ff table.
  • From graphs: read g(x)g(x) from the graph of gg (go up or down from xx to the graph). Then use that output as the new input on the graph of ff.
  • From equations: substitute the whole expression for g(x)g(x) in place of every xx in f(x)f(x). Use brackets.
Graphs of y = f(x), a parabola with vertex (0, -2) through (1, -1), (2, 2) and (-2, 2), and y = g(x), a line with slope -1 through (0, 3) and (3, 0). −3 −2 1 2 4 −1 1 2 4 5 6 3 −1 3 −2 y = f(x) y = g(x)
Reading compositions from graphs: here f(x)=x2−2f(x) = x^2 - 2 and g(x)=−x+3g(x) = -x + 3.

To find f(g(1))f(g(1)) from the graphs above: the line gives g(1)=2g(1) = 2, and then the parabola gives f(2)=2f(2) = 2. So f(g(1))=2f(g(1)) = 2. In the other order, f(1)=−1f(1) = -1, and then g(−1)=4g(-1) = 4, so g(f(1))=4g(f(1)) = 4.

xx is in the domain of f∘gf \circ g when both of these are true:

  1. xx is in the domain of gg (so g(x)g(x) exists), and
  2. g(x)g(x) is in the domain of ff (so ff 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)g(x) actually get fed into ff, and what ff does to them.

Going backwards, you can often split a complicated function into an “inside” and an “outside” function. For h(x)=(5x−2)3h(x) = (5x - 2)^3, the inside is g(x)=5x−2g(x) = 5x - 2 and the outside is f(x)=x3f(x) = x^3, so h(x)=f(g(x))h(x) = f(g(x)). Decomposing is useful for seeing how a function was built, and you’ll use it constantly in calculus.

Use the tables to evaluate f(g(0))f(g(0)), g(f(0))g(f(0)), f(g(3))f(g(3)), g(f(3))g(f(3)) and f(f(4))f(f(4)).

xx0011223344
f(x)f(x)3344002211
g(x)g(x)1133440022

Solution. Work from the inside out each time.

  • f(g(0))f(g(0)): g(0)=1g(0) = 1, then f(1)=4f(1) = 4. So f(g(0))=4f(g(0)) = 4.
  • g(f(0))g(f(0)): f(0)=3f(0) = 3, then g(3)=0g(3) = 0. So g(f(0))=0g(f(0)) = 0.
  • f(g(3))f(g(3)): g(3)=0g(3) = 0, then f(0)=3f(0) = 3. So f(g(3))=3f(g(3)) = 3.
  • g(f(3))g(f(3)): f(3)=2f(3) = 2, then g(2)=4g(2) = 4. So g(f(3))=4g(f(3)) = 4.
  • f(f(4))f(f(4)): f(4)=1f(4) = 1, then f(1)=4f(1) = 4. So f(f(4))=4f(f(4)) = 4.

The first two show that changing the order changes the answer: f(g(0))=4f(g(0)) = 4 but g(f(0))=0g(f(0)) = 0.

Let f(x)=x2+1f(x) = x^2 + 1 and g(x)=3x−2g(x) = 3x - 2. Find f(g(x))f(g(x)) and g(f(x))g(f(x)).

Solution. For f(g(x))f(g(x)), replace the xx in ff with the whole expression (3x−2)(3x - 2):

f(g(x))=(3x−2)2+1=9x2−12x+4+1=9x2−12x+5\begin{aligned} f\big(g(x)\big) &= (3x - 2)^2 + 1 \\ &= 9x^2 - 12x + 4 + 1 \\ &= 9x^2 - 12x + 5 \end{aligned}

For g(f(x))g(f(x)), replace the xx in gg with (x2+1)(x^2 + 1):

g(f(x))=3(x2+1)−2=3x2+1g\big(f(x)\big) = 3(x^2 + 1) - 2 = 3x^2 + 1

The results are different functions.

Check with x=1x = 1: g(1)=1g(1) = 1 and f(1)=2f(1) = 2, and the formula gives 9−12+5=29 - 12 + 5 = 2. ✓ Also f(1)=2f(1) = 2 and g(2)=4g(2) = 4, and the formula gives 3+1=43 + 1 = 4. ✓

Let f(x)=xf(x) = \sqrt{x} and g(x)=4−x2g(x) = 4 - x^2. Find f(g(x))f(g(x)) and g(f(x))g(f(x)), and state the domain and range of each.

Solution.

f(g(x))f(g(x)).

f(g(x))=4−x2f\big(g(x)\big) = \sqrt{4 - x^2}

gg accepts every real number, but ff can only take inputs that are ≥0\ge 0. So we need 4−x2≥04 - x^2 \ge 0, which means x2≤4x^2 \le 4, or −2≤x≤2-2 \le x \le 2.

For these xx-values, 4−x24 - x^2 goes from 00 (at x=±2x = \pm 2) up to 44 (at x=0x = 0). Taking square roots gives values from 00 to 22.

Domain: {x∈R∣−2≤x≤2}Range: {y∈R∣0≤y≤2}\text{Domain: } \{x \in \mathbb{R} \mid -2 \le x \le 2\} \qquad \text{Range: } \{y \in \mathbb{R} \mid 0 \le y \le 2\}

(The graph is the top half of a circle with radius 22.)

g(f(x))g(f(x)).

g(f(x))=4−(x)2=4−xg\big(f(x)\big) = 4 - \left(\sqrt{x}\right)^2 = 4 - x

It looks like a line, but the first step is x\sqrt{x}, which needs x≥0x \ge 0. So the domain is {x∈R∣x≥0}\{x \in \mathbb{R} \mid x \ge 0\}, and the graph is only the part of y=4−xy = 4 - x starting at (0,4)(0, 4). As xx grows from 00, 4−x4 - x falls from 44, so the range is {y∈R∣y≤4}\{y \in \mathbb{R} \mid y \le 4\}.

A cyclist rides at a steady 2424 km/h, so after tt hours she has gone d(t)=24td(t) = 24t km. At that pace she burns about 3030 kilocalories (kcal) per kilometre, so E(d)=30dE(d) = 30d kcal for dd kilometres. Each granola bar she packs has 180180 kcal, so replacing EE kcal takes B(E)=E180B(E) = \dfrac{E}{180} bars.

  • (a) Find B(E(d(t)))B(E(d(t))) and explain what it means.
  • (b) How many granola bars does she need to replace the energy from a 2.52.5-hour ride?

Solution.

(a) Work from the inside out:

E(d(t))=30(24t)=720tB(E(d(t)))=720t180=4t\begin{aligned} E\big(d(t)\big) &= 30(24t) = 720t \\ B\big(E(d(t))\big) &= \frac{720t}{180} = 4t \end{aligned}

B(E(d(t)))=4tB(E(d(t))) = 4t is the number of granola bars needed to replace the energy burned in tt hours of riding: 44 bars for every hour. Composition skipped the middle steps and went straight from time to bars.

(b) 4(2.5)=104(2.5) = 10, so she needs 1010 granola bars.

Check step by step: 2.52.5 h gives 24(2.5)=6024(2.5) = 60 km, which burns 30(60)=180030(60) = 1800 kcal, which is 1800180=10\tfrac{1800}{180} = 10 bars. ✓

Working from the outside in. f(g(x))f(g(x)) means gg first, then ff, even though ff is written first. Start with the innermost brackets.

Multiplying instead of composing. f(g(x))f(g(x)) is not f(x)⋅g(x)f(x) \cdot g(x). For f(x)=x2+1f(x) = x^2 + 1 and g(x)=3x−2g(x) = 3x - 2, the product is 3x3−2x2+3x−23x^3 - 2x^2 + 3x - 2, but the composition is 9x2−12x+59x^2 - 12x + 5.

Forgetting brackets when substituting. f(x)=x2+1f(x) = x^2 + 1 with x=3x−2x = 3x - 2 gives (3x−2)2+1(3x - 2)^2 + 1, not 3x−22+13x - 2^2 + 1 or 3x2−2+13x^2 - 2 + 1.

Reading the domain from the simplified formula. In Example 3, g(f(x))g(f(x)) simplifies to 4−x4 - x, but x=−5x = -5 isn’t allowed, because f(−5)=−5f(-5) = \sqrt{-5} doesn’t exist. Check the inside function first.

Reusing the x-value on a graph. After you find g(1)=2g(1) = 2, the next input is 22, not 11. Move to x=2x = 2 on the graph of ff.

Assuming f(g(x)) = g(f(x)). It’s usually false. Example 1 and Example 2 both show different answers in the two orders.

1. (Warm-up) Use the tables to find f(g(1))f(g(1)), g(f(1))g(f(1)) and g(g(2))g(g(2)).

xx11223344
f(x)f(x)33114422
g(x)g(x)22441133
Solution

f(g(1))f(g(1)): g(1)=2g(1) = 2, then f(2)=1f(2) = 1. So f(g(1))=1f(g(1)) = 1.

g(f(1))g(f(1)): f(1)=3f(1) = 3, then g(3)=1g(3) = 1. So g(f(1))=1g(f(1)) = 1.

g(g(2))g(g(2)): g(2)=4g(2) = 4, then g(4)=3g(4) = 3. So g(g(2))=3g(g(2)) = 3.

2. (Warm-up) Let f(x)=2x+1f(x) = 2x + 1 and g(x)=x2g(x) = x^2. Find f(g(3))f(g(3)) and g(f(3))g(f(3)).

Solution

f(g(3))f(g(3)): g(3)=9g(3) = 9, then f(9)=19f(9) = 19.

g(f(3))g(f(3)): f(3)=7f(3) = 7, then g(7)=49g(7) = 49.

3. (Warm-up) Use the graphs of ff and gg in Key ideas to find g(f(0))g(f(0)), f(g(2))f(g(2)) and f(f(1))f(f(1)).

Solution

g(f(0))g(f(0)): the parabola gives f(0)=−2f(0) = -2, then the line gives g(−2)=5g(-2) = 5. So g(f(0))=5g(f(0)) = 5.

f(g(2))f(g(2)): the line gives g(2)=1g(2) = 1, then the parabola gives f(1)=−1f(1) = -1. So f(g(2))=−1f(g(2)) = -1.

f(f(1))f(f(1)): f(1)=−1f(1) = -1, then f(−1)=−1f(-1) = -1. So f(f(1))=−1f(f(1)) = -1.

4. (Core) Let f(x)=x2−3xf(x) = x^2 - 3x and g(x)=x+2g(x) = x + 2.

  • (a) Find f(g(x))f(g(x)) and g(f(x))g(f(x)).
  • (b) Solve f(g(x))=g(f(x))f(g(x)) = g(f(x)).
Solution

(a)

f(g(x))=(x+2)2−3(x+2)=x2+4x+4−3x−6=x2+x−2\begin{aligned} f\big(g(x)\big) &= (x + 2)^2 - 3(x + 2) \\ &= x^2 + 4x + 4 - 3x - 6 \\ &= x^2 + x - 2 \end{aligned}g(f(x))=(x2−3x)+2=x2−3x+2g\big(f(x)\big) = (x^2 - 3x) + 2 = x^2 - 3x + 2

(b)

x2+x−2=x2−3x+2⇒4x=4⇒x=1x^2 + x - 2 = x^2 - 3x + 2 \quad\Rightarrow\quad 4x = 4 \quad\Rightarrow\quad x = 1

Check: f(g(1))=f(3)=9−9=0f(g(1)) = f(3) = 9 - 9 = 0 and g(f(1))=g(−2)=0g(f(1)) = g(-2) = 0. ✓ So the two orders agree only at x=1x = 1.

5. (Core) Let f(x)=1x−1f(x) = \dfrac{1}{x - 1} and g(x)=x2g(x) = x^2. Find f(g(x))f(g(x)) and g(f(x))g(f(x)), and state the domain of each.

Solutionf(g(x))=1x2−1f\big(g(x)\big) = \frac{1}{x^2 - 1}

ff can’t accept 11, so we need x2≠1x^2 \ne 1: the domain is {x∈R∣x≠±1}\{x \in \mathbb{R} \mid x \ne \pm 1\}.

g(f(x))=(1x−1)2=1(x−1)2g\big(f(x)\big) = \left(\frac{1}{x - 1}\right)^2 = \frac{1}{(x - 1)^2}

f(x)f(x) needs x≠1x \ne 1, and gg accepts anything. The domain is {x∈R∣x≠1}\{x \in \mathbb{R} \mid x \ne 1\}.

6. (Core) Find functions ff and gg so that h(x)=f(g(x))h(x) = f(g(x)). (There’s more than one answer; give the most natural one.)

  • (a) h(x)=(5x−2)3h(x) = (5x - 2)^3
  • (b) h(x)=x2+9h(x) = \sqrt{x^2 + 9}
  • (c) h(x)=23x+1h(x) = 2^{3x + 1}
  • (d) h(x)=1(x+4)2h(x) = \dfrac{1}{(x + 4)^2}
Solution

Look for the “inside” expression and call it g(x)g(x).

(a) g(x)=5x−2g(x) = 5x - 2 and f(x)=x3f(x) = x^3.

(b) g(x)=x2+9g(x) = x^2 + 9 and f(x)=xf(x) = \sqrt{x}.

(c) g(x)=3x+1g(x) = 3x + 1 and f(x)=2xf(x) = 2^x.

(d) g(x)=x+4g(x) = x + 4 and f(x)=1x2f(x) = \dfrac{1}{x^2}. (Another answer: g(x)=(x+4)2g(x) = (x + 4)^2 and f(x)=1xf(x) = \dfrac{1}{x}.)

7. (Core) Oil leaking from a tanker spreads in a circle on the water. The radius after tt minutes is r(t)=4tr(t) = 4t metres, and the area of a circle is A(r)=πr2A(r) = \pi r^2.

  • (a) Find A(r(t))A(r(t)) and explain what it represents.
  • (b) Find the area after 55 minutes.
  • (c) When does the area reach 20002000 m²?
Solution

(a) A(r(t))=π(4t)2=16πt2A(r(t)) = \pi(4t)^2 = 16\pi t^2. It’s the area of the slick, in square metres, tt minutes after the leak starts.

(b) A(r(5))=16π(25)=400π≈1256.64A(r(5)) = 16\pi(25) = 400\pi \approx 1256.64 m².

(c) Solve 16πt2=200016\pi t^2 = 2000 with t>0t \gt 0:

t2=200016π≈39.79⇒t≈6.31t^2 = \frac{2000}{16\pi} \approx 39.79 \quad\Rightarrow\quad t \approx 6.31

The area reaches 20002000 m² after about 6.316.31 minutes.

8. (Challenge) Let f(x)=2x+3f(x) = 2x + 3. Find g(x)g(x) if f(g(x))=6x2−1f(g(x)) = 6x^2 - 1.

Solution

ff doubles its input and adds 33, so f(g(x))=2g(x)+3f(g(x)) = 2g(x) + 3. Set this equal to the given expression:

2g(x)+3=6x2−12g(x)=6x2−4g(x)=3x2−2\begin{aligned} 2g(x) + 3 &= 6x^2 - 1 \\ 2g(x) &= 6x^2 - 4 \\ g(x) &= 3x^2 - 2 \end{aligned}

Check: f(3x2−2)=2(3x2−2)+3=6x2−1f(3x^2 - 2) = 2(3x^2 - 2) + 3 = 6x^2 - 1. ✓

9. (Challenge) Let f(x)=1x−2f(x) = \dfrac{1}{x - 2}. Find f(f(x))f(f(x)) in simplest form and state its domain.

Solutionf(f(x))=11x−2−2f\big(f(x)\big) = \frac{1}{\dfrac{1}{x - 2} - 2}

Multiply the top and bottom by (x−2)(x - 2):

f(f(x))=x−21−2(x−2)=x−25−2xf\big(f(x)\big) = \frac{x - 2}{1 - 2(x - 2)} = \frac{x - 2}{5 - 2x}

Domain: the inside f(x)f(x) needs x≠2x \ne 2. The outside ff can’t accept 22, so we also need 1x−2≠2\dfrac{1}{x - 2} \ne 2, which means x−2≠12x - 2 \ne \tfrac{1}{2}, or x≠52x \ne \tfrac{5}{2}. (That matches the denominator 5−2x≠05 - 2x \ne 0.)

{x∈R  |  x≠2, x≠52}\left\{x \in \mathbb{R} \;\middle|\; x \ne 2,\ x \ne \tfrac{5}{2}\right\}

Notice that x=2x = 2 is excluded even though the simplified formula gives 01=0\tfrac{0}{1} = 0 there.

Try these independently after the practice questions. Show your setup and explain your reasoning. Use exact answers where possible, and check that your answers fit the question. Homework solutions are not provided on the published site.

H1. (Foundations) Use the tables to evaluate each expression. If a value can’t be found from the tables, say so and explain why.

xx001122334455
f(x)f(x)225533004411
g(x)g(x)443300551166
  • (a) f(g(2))f(g(2))
  • (b) g(f(2))g(f(2))
  • (c) f(f(1))f(f(1))
  • (d) g(g(0))g(g(0))
  • (e) f(g(5))f(g(5))

H2. (Foundations) Let f(x)=4−xf(x) = 4 - x and g(x)=2x2−1g(x) = 2x^2 - 1. Evaluate each expression, working from the inside out.

  • (a) f(g(−2))f(g(-2))
  • (b) g(f(−2))g(f(-2))
  • (c) g(g(0))g(g(0))

H3. (Core) Let f(x)=x2−4xf(x) = x^2 - 4x and g(x)=2x+1g(x) = 2x + 1.

  • (a) Find (f∘g)(x)(f \circ g)(x) in simplified form.
  • (b) Find (g∘f)(x)(g \circ f)(x) in simplified form. Are f∘gf \circ g and g∘fg \circ f the same function?
  • (c) Check both answers at x=−1x = -1 by evaluating step by step from the original functions.

H4. (Core) Let f(x)=xf(x) = \sqrt{x} and g(x)=3−xg(x) = 3 - x.

  • (a) Find f(g(x))f(g(x)) and state its domain and range in set notation.
  • (b) Find g(f(x))g(f(x)) and state its domain and range in set notation.
  • (c) Explain why f(g(−4))f(g(-4)) exists but g(f(−4))g(f(-4)) does not.

H5. (Core) Each function can be written as h(x)=f(g(x))h(x) = f(g(x)). For (a) and (b), give two different pairs of functions ff and gg (neither one simply xx), and check one pair by composing.

  • (a) h(x)=(2x+1)3h(x) = (2x + 1)^3
  • (b) h(x)=x2+4h(x) = \sqrt{x^2 + 4}

H6. (Core) You order a hoodie from a US website. Use a hypothetical exchange rate where 11 US dollar is worth 1.381.38 Canadian dollars, so c(u)=1.38uc(u) = 1.38u converts uu US dollars to Canadian dollars. Then a hypothetical 13%13\% sales tax is added, so T(c)=1.13cT(c) = 1.13c gives the total after tax on cc Canadian dollars.

  • (a) Find T(c(u))T(c(u)) and explain what it represents.
  • (b) Find the total cost in Canadian dollars of an $80 (US) hoodie, to the nearest cent.
  • (c) The site also adds a $15 (Canadian) shipping charge after converting and before tax: s(c)=c+15s(c) = c + 15. Write the total cost as a composition of cc, ss and TT, and find it for the $80 (US) hoodie.
  • (d) A friend says the shipping should be added after tax instead. Find s(T(c(80)))s(T(c(80))) and explain why it differs from (c).

H7. (Challenge) Let f(x)=x+5f(x) = x + 5 and g(x)=x2−2g(x) = x^2 - 2. A student writes:

f(g(x))=(x+5)(x2−2)=x3+5x2−2x−10f\big(g(x)\big) = (x + 5)(x^2 - 2) = x^3 + 5x^2 - 2x - 10
  • (a) Use x=1x = 1 to show that the student’s answer is wrong. Describe the mistake.
  • (b) Find f(g(x))f(g(x)) correctly.
  • (c) Find g(f(x))g(f(x)), and explain how you know it isn’t the same as your answer to (b).

H8. (Challenge) Find all real values of xx for which f(g(x))=g(f(x))f(g(x)) = g(f(x)), or explain why there are none.

  • (a) f(x)=x2+1f(x) = x^2 + 1 and g(x)=2x−1g(x) = 2x - 1
  • (b) f(x)=x2+1f(x) = x^2 + 1 and g(x)=1xg(x) = \dfrac{1}{x}

H9. (Challenge) Work backwards to find the missing function.

  • (a) Let f(x)=x2f(x) = x^2. Find two different linear functions gg such that f(g(x))=9x2−12x+4f(g(x)) = 9x^2 - 12x + 4.
  • (b) Let f(x)=x+2f(x) = x + 2. Find g(x)g(x) such that g(f(x))=x2+4x+7g(f(x)) = x^2 + 4x + 7.

H10. (Challenge) (IB style) A stone is dropped into a still pond, making a circular ripple. The radius of the ripple tt seconds later is r(t)=0.3tr(t) = 0.3t metres, and the area of a circle with radius rr is A(r)=πr2A(r) = \pi r^2.

  • (a) Find (A∘r)(t)(A \circ r)(t) and explain what it represents.
  • (b) Find the area enclosed by the ripple after 55 seconds. Give an exact answer and a decimal to two decimal places.
  • (c) Find the time at which the enclosed area is 1010 m², to the nearest hundredth of a second.
  • (d) The ripple stops when it reaches the edge of the pond, 66 m from where the stone landed. State a suitable domain and the range of A∘rA \circ r for this model, in set notation.