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

Composition Algebraically: Equations, Domain and Range

D2.5About 75 minutes
Learning goals
  • I can find f(g(x)) and g(f(x)) algebraically by substituting one expression into another.
  • I can show with an example that f(g(x)) is usually not equal to g(f(x)).
  • I can find the domain of a composition: the x-values in the domain of g whose outputs g(x) are in the domain of f.
  • I can find the range of a composition by tracking the values that pass through each function.

Words to know

substitution
Replacing every x in the outer function with the whole inner expression, in brackets.
domain of f ∘ g
All x in the domain of g for which g(x) is in the domain of f.
range of f ∘ g
All outputs f(u), where u runs through the values g actually produces (the range of g, cut down to the domain of f).
commute
Two functions commute under composition if f(g(x)) = g(f(x)) for every x. Most pairs do not.

Add one, then double?

Let f(x) = x + 1 ("add 1") and g(x) = 2x ("double").

  • f(g(x)): double first, then add 1: f(2x) = 2x + 1.
  • g(f(x)): add 1 first, then double: g(x + 1) = 2(x + 1) = 2x + 2.

Two different functions. Check with x = 1: f(g(1)) = f(2) = 3, but g(f(1)) = g(2) = 4. The order of composition matters, and this one example is enough to prove that f(g(x)) is not always equal to g(f(x)).

In the last lesson you composed functions one number at a time. Now you will find the equation of a composition, and its domain and range, all at once.

-3-2-1123-4-3-2-112345678xy34f(g(x)) = 2x + 1g(f(x)) = 2x + 2f(x) = x + 1 (add 1)g(x) = 2x (double)At x = 1:double, then add 1 → 3add 1, then double → 4
The two compositions of f(x) = x + 1 and g(x) = 2x are parallel lines, one unit apart vertically. At x = 1 they give 3 and 4.

How to find f(g(x))

  1. Write the outer function f with empty brackets in place of x. For f(x) = x² − 3x: f( ) = ( )² − 3( ).
  2. Put the whole inner expression g(x) into every bracket.
  3. Simplify.
  4. Find the domain from the original functions (see below), then the range.
Worked example

Example 1: Both orders

Let f(x) = x² − 3x and g(x) = 2x + 1. Find f(g(x)) and g(f(x)), and check each with x = 1.

  1. f(g(x)) = (2x + 1)² − 3(2x + 1)
  2. = 4x² + 4x + 1 − 6x − 3 = 4x² − 2x − 2.
  3. g(f(x)) = 2(x² − 3x) + 1 = 2x² − 6x + 1.
  4. Check x = 1: g(1) = 3 and f(3) = 9 − 9 = 0; the formula gives 4 − 2 − 2 = 0 ✓. f(1) = −2 and g(−2) = −3; the formula gives 2 − 6 + 1 = −3 ✓.

f(g(x)) = 4x² − 2x − 2 and g(f(x)) = 2x² − 6x + 1. Different functions, as expected.

The domain of a composition

For f(g(x)) to exist, two things must happen:

  1. x must be in the domain of g (so g can act), and
  2. g(x) must be in the domain of f (so f can act on it).

Domain of f ∘ g = { x ∈ domain of g | g(x) ∈ domain of f }.

Find it from the original functions, before simplifying, because simplifying can hide a restriction.

Worked example

Example 2: Domain and range with a square root

Let f(x) = √x and g(x) = x − 3. Find f(g(x)) and g(f(x)), with the domain and range of each.

  1. f(g(x)) = √(x − 3). g accepts every x, but f needs its input g(x) = x − 3 to be ≥ 0, so x ≥ 3. Domain x ≥ 3. The square root gives every value ≥ 0: range y ≥ 0.
  2. g(f(x)) = √x − 3. f needs x ≥ 0, and g accepts any output of f. Domain x ≥ 0. √x takes every value ≥ 0, and subtracting 3 gives every value ≥ −3: range y ≥ −3.
  3. Notice the transformations: √(x − 3) is √x shifted right 3, and √x − 3 is √x shifted down 3.

f(g(x)) = √(x − 3): domain x ≥ 3, range y ≥ 0. g(f(x)) = √x − 3: domain x ≥ 0, range y ≥ −3.

f(g(x)) = √(x − 3)g(f(x)) = √x − 3-1123456789-4-3-2-11234xydomain x ≥ 3-1123456789-4-3-2-11234xydomain x ≥ 0(0, −3)
The thick segment on each x-axis shows the domain. √(x − 3) starts at (3, 0); √x − 3 starts at (0, −3). Same two functions, different order, different domain and range.
Worked example

Example 3: Domain and range with a rational function

Let f(x) = 1/x and g(x) = x² − 4. Find the domain and range of f(g(x)) and of g(f(x)).

  1. f(g(x)) = 1/(x² − 4). f cannot take 0, so g(x) ≠ 0: x² − 4 ≠ 0, x ≠ ±2. Domain {x ∈ ℝ | x ≠ ±2}.
  2. Range: g produces every value ≥ −4. Remove 0 (f cannot use it), leaving −4 ≤ u < 0 or u > 0. Then 1/u gives: for −4 ≤ u < 0, 1/u ≤ −1/4; for u > 0, 1/u > 0. Range y ≤ −1/4 or y > 0.
  3. g(f(x)) = (1/x)² − 4 = 1/x² − 4. f needs x ≠ 0, and g accepts anything. Domain x ≠ 0.
  4. Range: 1/x² takes every value > 0, so 1/x² − 4 takes every value > −4. Range y > −4.

1/(x² − 4): domain x ≠ ±2, range y ≤ −1/4 or y > 0. 1/x² − 4: domain x ≠ 0, range y > −4.

When simplifying hides a restriction

Let f(x) = x² and g(x) = √x.

  • f(g(x)) = (√x)² = x, but only for x ≥ 0, because g needs x ≥ 0. Its graph is half of the line y = x.
  • g(f(x)) = √(x²) = |x| for every real x, because the square root gives the non-negative root. Its graph is a V.

Neither one is the plain line y = x for all real numbers.

(√x)² = x, only for x ≥ 0√(x²) = |x|, for all x-4-3-2-11234-11234xy-4-3-2-11234-11234xy
Left: (√x)² equals x only on x ≥ 0, so its graph is a half-line starting at the origin. Right: √(x²) is defined for all x and equals |x|, a V shape.
Worked example

Example 4: Mixing function families

(a) Let f(x) = 2ˣ and g(x) = sin x. Find f(g(x)) and g(f(x)) with their ranges. (b) Let f(x) = log x and g(x) = x². Find f(g(x)) and its domain, and compare it with 2 log x.

  1. (a) f(g(x)) = 2^(sin x). Domain ℝ. sin x runs from −1 to 1, so 2^(sin x) runs from 2⁻¹ = 1/2 to 2¹ = 2. Range 1/2 ≤ y ≤ 2. It repeats every 2π, like sin x.
  2. g(f(x)) = sin(2ˣ). Domain ℝ. 2ˣ takes every positive value, and sin of all positive numbers covers every value from −1 to 1. Range −1 ≤ y ≤ 1. It is not periodic: as x grows, 2ˣ grows faster and faster, so the waves get squeezed together.
  3. (b) f(g(x)) = log(x²). log needs x² > 0, so x ≠ 0. Domain {x ∈ ℝ | x ≠ 0}.
  4. The power law of logarithms (from the sibling unit Exponential and Logarithmic Functions) says log(x²) = 2 log x, but 2 log x needs x > 0. So log(x²) = 2 log x only for x > 0. For x < 0, log(x²) = 2 log|x|.

(a) 2^(sin x): range 1/2 ≤ y ≤ 2, period 2π; sin(2ˣ): range −1 ≤ y ≤ 1, not periodic. (b) log(x²) has domain x ≠ 0; it equals 2 log|x|, which matches 2 log x only for x > 0.

y = 2^(sin x): range 1/2 ≤ y ≤ 2y = sin(2ˣ): range −1 ≤ y ≤ 1π/2π3π/22π−112xy-2-11234−112xy
Left: 2^(sin x) wobbles between 1/2 and 2 and repeats every 2π. Right: sin(2ˣ) wobbles between −1 and 1, and its waves crowd closer together as x increases.

A quick check for any composition

Pick a simple number, like x = 1 or x = 2. Work it out the long way (inside, then outside) and with your formula. If the answers differ, find the error before going on. This catches most bracket and sign mistakes.

Just for fun

Mathematicians often read f ∘ g as "f after g". It is the only place in mathematics where the function written first politely waits its turn.

Hands-on activity

Composition card game

You need: 8 index cards (or paper squares), a pencil and a calculator.

  1. Write one function on each card: x + 4, x − 4, 3x, x/3, x², √x, 1/x, 2ˣ.
  2. Shuffle and draw two cards. Call the first f and the second g.
  3. Find f(g(x)) and g(f(x)) algebraically, and state the domain of each.
  4. Check both with x = 4 on the calculator, working inside out.
  5. Keep a list of pairs where f(g(x)) = g(f(x)) for every x in the domain. Play at least 6 rounds.

What to look for: most pairs give different compositions (for example x² with x + 4 gives (x + 4)² = x² + 8x + 16 and x² + 4). Pairs that do commute include x + 4 with x − 4 (both give x), 3x with x/3 (both give x), x + 4 with itself, and x² with √x only on x ≥ 0. Pairs that undo each other always commute; the next lessons explain why.

Your turn

1

f(x) = 3x − 2 and g(x) = x². Find f(g(x)) and g(f(x)).

2

Show with x = 2 that your answers in the previous question are different functions.

3

f(x) = √(x + 5) and g(x) = x − 1. Find f(g(x)) with its domain and range.

4

f(x) = 1/(x − 2) and g(x) = x + 3. Find f(g(x)) and g(f(x)), with domains.

5

f(x) = 10ˣ and g(x) = log x. Find f(g(x)) and state its domain.

6

f(x) = cos x and g(x) = 2x. Find f(g(x)) and g(f(x)) and the range of each.

7

f(x) = x² + 1. Find f(f(x)).

More practice: warm-up

1

f(x) = x + 5, g(x) = 4x. Find f(g(x)).

2

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

3

f(x) = x², g(x) = x − 1. Find f(g(x)).

4

f(x) = √x. For f(g(x)) to exist, what must be true of g(x)?

5

f(x) = 1/x. For f(g(x)) to exist, what must be true of g(x)?

More practice: on your own

1

f(x) = √(9 − x) and g(x) = x². Find the domain and range of f(g(x)).

2

f(x) = log(x − 1) and g(x) = x² + 1. Find f(g(x)) and its domain.

3

f(x) = 2/(x + 1) and g(x) = 1/x. Find f(g(x)) in simplest form and its domain.

4

f(x) = sin x and g(x) = x². Is f(g(x)) even, odd or neither? Is g(f(x))?

5

Find two linear functions f and g, neither equal to x, that commute.

Challenge

1

Let f(x) = 1/(1 − x). Find f(f(x)) and f(f(f(x))), with the domain of each.

2

f(x) = ax + b and g(x) = cx + d. Find a condition on a, b, c, d that makes f(g(x)) = g(f(x)) for all x.

3

f(x) = √x and g(x) = sin x. State the domain of f(g(x)) for 0 ≤ x ≤ 4π, and the range.

Check your understanding

Quiz

1.

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

2.

What is the domain of f(g(x)) if f(x) = √x and g(x) = x + 6?

3.

f(x) = x² and g(x) = x − 4. What is f(g(x))?

4.

f(x) = 1/x and g(x) = x − 5. Which value is NOT in the domain of f(g(x))?

5.

What is the range of y = 2^(sin x)?

6.

For which x does √(x²) = x?

For parents and teachers

Big idea: D2.5 asks students to compose two functions algebraically, to verify that f(g(x)) is not always equal to g(f(x)) (the curriculum's own example is f(x) = x + 1 and g(x) = 2x), and to state the domain and range of the composition.

How to help: insist on brackets: write f( ) with an empty bracket and drop the whole inner expression in. After every answer, check with a number such as x = 1. For the domain, ask two questions: "Can g take this x?" and "Can f take what g gives?"

Common difficulties:

  • Composing in the wrong order.
  • Dropping brackets: 3(2x + 1) written as 6x + 1.
  • Finding the domain from the simplified formula only, and missing restrictions such as x ≥ 0 in (√x)².
  • Thinking log(x²) and 2 log x are the same function.

The Challenge questions are first-year university style; they are optional for most students.