AP Precalculus · Study guide

Composition of Functions

AP® Precalculus · Unit 2 · Exponential and Logarithmic Functions

Composition of Functions

Composing functions means feeding the output of one function into another. This guide evaluates compositions from formulas, tables and graphs, builds composite formulas with their domains, and takes complicated functions apart into simple pieces.

The idea in one paragraph

The composite function \(f \circ g\), written \((f \circ g)(x) = f(g(x))\), applies \(g\) first and then applies \(f\) to the result. Its domain is the inputs of \(g\) whose outputs are in the domain of \(f\). Composition is not commutative: \(f(g(x))\) and \(g(f(x))\) are usually different. The identity function \(x \mapsto x\) changes nothing when composed with any function, the way 0 changes nothing in addition and 1 changes nothing in multiplication.

1What composition means

Read \(f(g(x))\) from the inside out: start with \(x\), apply \(g\), then apply \(f\) to whatever \(g\) produced. The function written closest to \(x\) acts first. If \(g\) produces a value that \(f\) cannot accept, that \(x\) is left out of the composite’s domain.

2Evaluating compositions

Whatever form the functions are given in, the routine is the same: find the inner output, then use it as the outer input.

Worked Example 1 From tables

Use the tables to find \(f(g(2))\), \(g(f(2))\), \(f(f(0))\) and \(g(g(3))\).

\(x\)01234
\(f(x)\)43012
\(g(x)\)24301
  1. 1
    \(g(2) = 3\), then \(f(3) = 1\). \(f(2) = 0\), then \(g(0) = 2\).
  2. 2
    \(f(0) = 4\), then \(f(4) = 2\). \(g(3) = 0\), then \(g(0) = 2\).
Answer: \(f(g(2)) = 1\), \(g(f(2)) = 2\), \(f(f(0)) = 2\), \(g(g(3)) = 2\).
Figure 1. To find f(g(−1)), read g at −1 on the left graph (2), then carry that output to the right graph as an input: f(2) = 1.
Worked Example 2 From graphs

Use Figure 1 to find \(f(g(-1))\), \(g(f(0))\) and \(f(g(1))\).

  1. 1
    \(g(-1) = 2\), and \(f(2) = 1\). So \(f(g(-1)) = 1\).
  2. 2
    \(f(0) = -1\), and \(g(-1) = 2\). So \(g(f(0)) = 2\).
  3. 3
    \(g(1) = 0\), and \(f(0) = -1\). So \(f(g(1)) = -1\).
Answer: 1, 2, and \(-1\).
Common Mistake 1 · Multiplying instead of composing

\(f(g(x))\) is not \(f(x) \cdot g(x)\). With \(f(x) = x^2 - 1\) and \(g(x) = 3x + 2\), the product at \(x = 1\) is \(0 \cdot 5 = 0\), but \(f(g(1)) = 24\).

3Building the formula

To write \(f(g(x))\), replace every \(x\) in the formula for \(f\) with the entire expression \(g(x)\), in parentheses. Then work out the domain: start from the domain of \(g\) and remove any inputs whose outputs \(f\) cannot take.

Worked Example 3 From formulas, both orders

\(f(x) = x^2 - 1\) and \(g(x) = 3x + 2\). Find \(f(g(1))\), \(g(f(1))\), and formulas for \(f(g(x))\) and \(g(f(x))\).

  1. 1
    \(g(1) = 5\), so \(f(g(1)) = f(5) = 24\). \(f(1) = 0\), so \(g(f(1)) = g(0) = 2\).
  2. 2
    \(f(g(x)) = (3x + 2)^2 - 1 = 9x^2 + 12x + 3\). Replace every \(x\) in \(f\) with the whole expression \(3x + 2\).
  3. 3
    \(g(f(x)) = 3(x^2 - 1) + 2 = 3x^2 - 1\).
Answer: \(f(g(1)) = 24\), \(g(f(1)) = 2\); \(f(g(x)) = 9x^2 + 12x + 3\), \(g(f(x)) = 3x^2 - 1\). Different orders, different functions.
Worked Example 4 The domain of a composition

\(f(x) = \sqrt{x - 4}\) and \(g(x) = x^2\). Find \(f(g(x))\) and \(g(f(x))\) with their domains.

  1. 1
    \(f(g(x)) = \sqrt{x^2 - 4}\). An input works when \(g(x) = x^2\) is in the domain of \(f\), meaning \(x^2 \ge 4\): \(x \le -2\) or \(x \ge 2\).
  2. 2
    \(g(f(x)) = \left(\sqrt{x - 4}\right)^2 = x - 4\), but only for inputs where \(f(x)\) exists: \(x \ge 4\).
  3. 3
    The simplified formula \(x - 4\) hides that restriction, so state it.
Answer: \(f(g(x)) = \sqrt{x^2 - 4}\) for \(|x| \ge 2\); \(g(f(x)) = x - 4\) for \(x \ge 4\).
Write it like this

“\(g(f(x)) = x - 4\), with domain \(x \ge 4\), because \(f(x) = \sqrt{x - 4}\) is defined only for \(x \ge 4\).”

Common Mistake 2 · Dropping parentheses when substituting

\(f(g(x))\) with \(f(x) = x^2 - 1\) is \((3x + 2)^2 - 1\), not \(3x + 2^2 - 1\). The whole inner expression gets squared.

Worked Example 5 A composition in context

An oil spill is a circle whose radius, in meters, is \(r(t) = 3t + 1\) after \(t\) hours. Its area is \(A(r) = \pi r^2\). Find the area after 2 hours.

  1. 1
    Chain the units: hours go into \(r\) and come out as meters; meters go into \(A\) and come out as square meters.
  2. 2
    \(A(r(t)) = \pi(3t + 1)^2\). At \(t = 2\): \(r = 7\), so \(A = 49\pi \approx 153.94\).
Answer: About 153.94 m² after 2 hours.

4Order and the identity function

Changing the order usually changes the result, as Worked Example 3 shows: \(9x^2 + 12x + 3\) against \(3x^2 - 1\). One function always commutes with everything: the identity \(i(x) = x\). For any \(g\), \(g(i(x)) = i(g(x)) = g(x)\).

Common Mistake 3 · Assuming f(g(x)) = g(f(x))

The order is part of the instruction. “Socks, then shoes” and “shoes, then socks” use the same two steps with very different results. In Worked Example 3, swapping the order turned 24 into 2.

5Taking a function apart

A complicated function can often be split into an inner function and an outer function. Ask: what is computed first, and what is done to that result? Transformations are compositions too: \(f(x + k)\) is \(f\) composed after \(x \mapsto x + k\), and \(k \cdot f(x)\) is \(x \mapsto kx\) composed after \(f\).

Worked Example 6 Taking a function apart

Write \(h(x) = (2x + 5)^3\) and \(k(x) = \dfrac{1}{x^2 + 1}\) as compositions of simpler functions.

  1. 1
    \(h\): first double and add 5, then cube. \(g(x) = 2x + 5\) and \(f(x) = x^3\), so \(h(x) = f(g(x))\).
  2. 2
    \(k\): first square and add 1, then take the reciprocal. \(g(x) = x^2 + 1\) and \(f(x) = \frac1x\), so \(k(x) = f(g(x))\).
  3. 3
    Check: substituting \(g(x)\) into \(f\) replaces each \(x\) in \(f\) and gives back the original.
Answer: \(h = f \circ g\) with \(f(x) = x^3\), \(g(x) = 2x + 5\); \(k = f \circ g\) with \(f(x) = \frac1x\), \(g(x) = x^2 + 1\).

Quick reference

IdeaIn symbols
Composite\((f \circ g)(x) = f(g(x))\): g first, then f
DomainInputs of \(g\) with \(g(x)\) in the domain of \(f\)
Order matters\(f(g(x)) \ne g(f(x))\) in general
Identity\(i(x) = x\); \(g(i(x)) = i(g(x)) = g(x)\)
Shift as composition\(f(x + k) = f(s(x))\), \(s(x) = x + k\)
Stretch as composition\(k f(x) = m(f(x))\), \(m(x) = kx\)