Grade by Grade
D. Characteristics of Functions · Combining Functions and Modelling

Composition of Functions: Tables, Machines and Graphs

D2.4About 70 minutes
Learning goals
  • I can explain what f(g(x)) means and why the inside function g is applied first.
  • I can find values of a composition from function machines and tables of values.
  • I can find values of a composition from the graphs of the two functions and build a table for f(g(x)).
  • I can interpret a composition in a real context, including its units.

Words to know

composition
Applying one function to the output of another. (f ∘ g)(x) = f(g(x)): first g, then f.
composite function
The single function that results from a composition, such as h(x) = f(g(x)).
inner function
In f(g(x)), the function g, which acts first on x.
outer function
In f(g(x)), the function f, which acts on the output of g.
mapping diagram
A diagram that shows each input with an arrow to its output; for a composition, two sets of arrows in a row.

Output becomes input

You are driving to a hockey tournament. The distance you have driven depends on time. The fuel you have used depends on distance. The cost of that fuel depends on how many litres you used. So cost depends on time, through a chain of functions, each one feeding its output into the next.

Feeding the output of one function into another is called composition. It is different from adding or multiplying functions: instead of combining two outputs, you chain the functions.

Remember from Grade 11: in the unit Functions and Equivalent Expressions of Functions (MCR3U), you described functions as machines, used tables of values, and evaluated f(a) from a graph. Composition uses exactly those skills, twice in a row.

Notation

The composition of f with g is written

(f ∘ g)(x) = f(g(x))

and read "f composed with g of x" or "f of g of x". The small circle ∘ is not multiplication.

  • g acts first (it is the inner function), even though f is written first.
  • f acts second, on whatever g produced.
  • To find f(g(a)): find g(a), then put that number into f.
x = 1gg(x) = 3 − xg(1) = 2ff(x) = (x − 1)² − 2f(2) = −1f(g(1)) = f(2) = −1: the inside function g works first, then f works on its output.
A composition as two machines in a row. The input 1 goes into g and comes out as 2; that 2 goes into f and comes out as −1. So f(g(1)) = −1.

Composition from a table

When functions are given by tables, work from the inside out. If the output of g is not an input in the table of f, then f(g(x)) is undefined there (it is not in the domain of the composition).

x−2−10123
f(x)5310−14
g(x)31−1240
Tables for Example 1. Only these x-values are known.
Worked example

Example 1: Compositions from tables

Use the table to find (a) f(g(1)) (b) g(f(1)) (c) (g ∘ g)(0) (d) f(g(2)) (e) a table for f ∘ g.

  1. (a) g(1) = 2, then f(2) = −1. So f(g(1)) = −1.
  2. (b) f(1) = 0, then g(0) = −1. So g(f(1)) = −1. (The same answer here is a coincidence; in general f(g(x)) ≠ g(f(x)).)
  3. (c) g(0) = −1, then g(−1) = 1. So (g ∘ g)(0) = 1.
  4. (d) g(2) = 4, but 4 is not an input in the table of f. So f(g(2)) is undefined (from this table).
  5. (e) For each x, find g(x), then f of that: x = −2: f(3) = 4; x = −1: f(1) = 0; x = 0: f(−1) = 3; x = 1: f(2) = −1; x = 2: undefined; x = 3: f(0) = 1.

f ∘ g: (−2, 4), (−1, 0), (0, 3), (1, −1), (3, 1); x = 2 is not in its domain.

Composition from graphs

To find f(g(a)) from graphs:

  1. Go to x = a on the graph of g and read the height, g(a).
  2. Go to x = g(a) on the graph of f and read the height. That is f(g(a)).

To graph the whole composition, repeat for many x-values, make a table of (x, f(g(x))), and plot it. Graphing technology does the same thing very quickly.

-2-112345-3-2-112345xyg(1) = 2y = g(x)-2-112345-3-2-112345xyf(2) = −1y = f(x)Step 1: read g(1) from the graph of gStep 2: use 2 as the input of f
Reading f(g(1)) from two graphs: the graph of g gives g(1) = 2, and then the graph of f at x = 2 gives f(2) = −1. Here g(x) = 3 − x and f(x) = (x − 1)² − 2.
Worked example

Example 2: Reading and building a composition from graphs

Use the graphs above, g(x) = 3 − x and f(x) = (x − 1)² − 2. (a) Find f(g(4)) and g(f(3)). (b) Make a table of f(g(x)) for x = −1 to 3 and describe the graph of f ∘ g.

  1. (a) g(4) = −1 (on the line, x = 4 gives y = −1). On the parabola, f(−1) = (−2)² − 2 = 2. So f(g(4)) = 2.
  2. f(3) = 2² − 2 = 2. On the line, g(2) = 1. So g(f(3)) = 1.
  3. (b) g(−1) = 4, f(4) = 7; g(0) = 3, f(3) = 2; g(1) = 2, f(2) = −1; g(2) = 1, f(1) = −2; g(3) = 0, f(0) = −1.
  4. Plot (−1, 7), (0, 2), (1, −1), (2, −2), (3, −1). These points form a parabola opening up with vertex (2, −2).
  5. Compare with f, whose vertex is (1, −2): the composition is f's parabola shifted 1 unit right. (Algebra confirms it: f(3 − x) = (2 − x)² − 2 = (x − 2)² − 2. You will do this algebra in the next lesson.)

f(g(4)) = 2, g(f(3)) = 1, and f ∘ g is the parabola y = (x − 2)² − 2.

xg(x) = 3 − xf(g(x))−14703212−121−230−1
A mapping diagram for f ∘ g with g(x) = 3 − x and f(x) = (x − 1)² − 2. Each x travels through g (first set of arrows) and then through f (second set).

What does a composition mean?

In a real situation, a composition only makes sense if the output of the inner function is the kind of quantity the outer function takes as input. Check units:

  • d(t): time (h) → distance (km)
  • F(d): distance (km) → fuel (L)
  • C(F): fuel (L) → cost ($)

C(F(d(t))) takes time to cost. But d(F(t)) makes no sense: F expects a distance, not a time.

Worked example

Example 3: Interpreting compositions in context

A car travels at 90 km/h, so d(t) = 90t. It uses 8 L of gas per 100 km, so F(d) = 0.08d. Suppose gas costs $1.65 per litre, so C(F) = 1.65F. (a) Find C(F(d(3))) and explain what it means. (b) The outside temperature (°C) t hours after midnight is T(t), and K(T) = T + 273.15 converts °C to kelvins. What does K(T(6)) = 263.15 mean?

  1. (a) Work inside out: d(3) = 270 km; F(270) = 0.08 × 270 = 21.6 L; C(21.6) = 1.65 × 21.6 = $35.64.
  2. Meaning: driving for 3 hours uses $35.64 of gas.
  3. (b) K(T(6)) is a temperature in kelvins at t = 6 h. Since K = T + 273.15, T(6) = 263.15 − 273.15 = −10.
  4. Meaning: at 6 a.m. the temperature is −10°C, which is 263.15 K.

(a) $35.64 is the fuel cost of a 3-hour drive. (b) At 6:00 a.m. it is −10°C (263.15 K).

Inside first, and watch the order

f(g(x)) and g(f(x)) are usually different. Read f(g(x)) from the inside out: g first. A good habit is to write the middle value: "g(1) = 2, f(2) = −1".

Just for fun

Composition is like getting dressed: f(g(x)) with g = socks and f = boots gives a normal morning. g(f(x)), boots first and then socks, is technically a composition too, but your toes will have questions.

Hands-on activity

Be a function machine

You need: a partner (a parent, sibling or friend), paper, a pencil and 10 small slips of paper.

  1. You are machine g: double the number. Your partner is machine f: add 3.
  2. Write the numbers −2, −1, 0, 1, 2 on slips. For each slip, you apply g and pass your answer to your partner, who applies f and announces the final output. Record (x, f(g(x))).
  3. Swap order: your partner applies f first and passes to you. Record (x, g(f(x))).
  4. Compare the two tables. Graph both on one set of axes.
  5. Bonus: make one machine "square the number" and the other "subtract 1". Does order matter now?

What to look for: f(g(x)) = 2x + 3 gives −1, 1, 3, 5, 7. g(f(x)) = 2(x + 3) = 2x + 6 gives 2, 4, 6, 8, 10. Both are lines with slope 2, but different y-intercepts, so order matters. In the bonus, square-then-subtract gives x² − 1 (3, 0, −1, 0, 3) and subtract-then-square gives (x − 1)² (9, 4, 1, 0, 1): different again.

Your turn

1

Use the table in Example 1. Find f(g(−2)) and g(f(−2)).

2

Use the table in Example 1. Find (f ∘ f)(−1).

3

Using the graphs g(x) = 3 − x and f(x) = (x − 1)² − 2, find g(g(5)).

4

Using the same graphs, find f(g(0)) and g(f(0)).

5

h(t) is a balloon's height (m) after t seconds; P(h) is the air pressure (kPa) at height h. What does P(h(10)) represent? What are its units?

6

Machine g: subtract 4. Machine f: square. Find f(g(7)) and g(f(7)).

More practice: warm-up

1

In f(g(x)), which function acts first?

2

g(2) = 5 and f(5) = −3. Find f(g(2)).

3

f(x) = x + 10 and g(x) = 3x. Find f(g(1)).

4

Same f and g. Find g(f(1)).

5

Does the circle in (f ∘ g)(x) mean multiplication?

More practice: on your own

1

x: 0, 1, 2, 3 with f(x): 2, 3, 0, 1 and g(x): 1, 3, 2, 0. Make a table for f ∘ g and one for g ∘ f.

2

A store's price after a 25% discount is D(p) = 0.75p. Ontario's 13% HST gives T(p) = 1.13p. Find T(D(80)) and explain what it means.

3

The radius of a melting snowball is r(t) = 10 − 0.5t cm. Its volume is V(r) = (4/3)πr³. Find V(r(4)) and interpret it.

4

Explain why, for the snowball, the domain of V ∘ r is 0 ≤ t ≤ 20 in context.

5

Use the graphs g(x) = 3 − x and f(x) = (x − 1)² − 2. For which x is f(g(x)) = −2?

Challenge

1

Using only the table in Example 1, find every x for which f(g(x)) = 0.

2

A function k satisfies k(k(x)) = x for every x, like g(x) = 3 − x. Explain what this means about the graph of k, and give another example.

3

Machines: A adds 2, B triples, C squares. In which order should you use all three to turn 1 into the largest output? The smallest?

Check your understanding

Quiz

1.

What does (f ∘ g)(x) mean?

2.

g(4) = −2 and f(−2) = 9. What is f(g(4))?

3.

f(x) = x² and g(x) = x + 1. What is g(f(3))?

4.

A table gives g(5) = 8, but 8 is not an input in the table for f. What can you say about f(g(5))?

5.

s(t) is distance travelled (km) after t hours, and E(s) is the energy (kJ) used to travel s km. What are the units of E(s(2))?

6.

On the graph of g, the point (2, 6) appears. On the graph of f, the point (6, −1) appears. Which point must be on the graph of f ∘ g?

For parents and teachers

Big idea: D2.4 asks students to compose two functions numerically (with tables) and graphically, from function machines, graphs and equations, and to interpret compositions in context. The next lesson does the algebra.

How to help: play "function machine" with real rules (double it, add 3) and swap the order. When your teen evaluates f(g(a)), ask them to say the middle value out loud.

Common difficulties:

  • Applying f first because it is written first.
  • Treating ∘ as multiplication.
  • Forgetting that the input of the composition is still x (the point is (2, −1), not (6, −1)).
  • In context, chaining functions whose units do not match.

In Example 3, the gas price of $1.65 per litre is an assumption for the problem, not a current price.