AP Precalculus · Unit 2: Exponential and Logarithmic Functions · Lesson 2.7

Deep Dive: Composition of Functions

🔬 Deep Dive
This is your textbook for this topic. Take your time. Read it more than once.
2.7.A2.7.A.1Concept

The Composite Function

If f and g are functions, the composite function f∘g maps a set of input values to a set of output values such that the output values of g are used as input values of f. It can be written two ways:

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

Read f(g(x)) from the inside out: do g first, then f. Because f only accepts certain inputs, the domain of f∘g is restricted to those inputs of g whose output is in the domain of f.

Example. Let f(x) = √x and g(x) = x − 4. Then (f∘g)(13) = f(9) = 3. But (f∘g)(2) = f(−2), and √(−2) is not a real number, so (f∘g)(2) is undefined. Only x ≥ 4 works, because g(x) = x − 4 must be at least 0.

In (f∘g)(x) = f(g(x)), the output of g becomes the input of f. Pick a pair of functions and an input and follow the chain. Some inputs make the composition undefined.

input x7
-6-4-20246800.511.52xf(g(x))(7, 1.732)
f(x) = √x    g(x) = x − 4step 1 (inner): g(7) = 3step 2 (outer): f(3) = 1.732(f∘g)(7) = 1.732Domain of f∘g: x ≥ 4. It is limited to the inputs of g whose outputs are allowed as inputs of f.
🔑The inner function acts first. Its output has to be an allowed input of the outer function, or the composition is undefined at that value.
2.7.A2.7.A.2Math

Evaluating from Tables, Graphs, Formulas, and Words

Values of f∘g can be calculated or estimated from graphical, numerical, analytical, or verbal representations of f and g. The method never changes: use the output from g as the input for f.

RepresentationHow to find (f∘g)(a)
tablefind g(a) in g's table, then look that number up as an input in f's table
graphread g(a) from g's graph, then use it as an x-value on f's graph
formulacompute g(a), then substitute the result into f
wordstranslate each sentence into a function, then chain the steps

Example (words). A car goes g(t) = 45t miles in t hours and uses f(m) = m/30 gallons for m miles. Then (f∘g)(4) = f(180) = 6 gallons: the output of g (miles) is the input of f (miles).

With tables, use an output of the inner function as an input of the outer function. If that value is not in the outer function's table, the composition is undefined there.

x01234
f(x)41630
x12345
g(x)30427
x12345
g(x)30427
f(g(x))3406undefined
Switch between f∘g and g∘f. The two rows of results are different, and each has its own undefined spots.
⚠️Units are a check. In f(g(t)), the output units of g must match the input units of f. Miles out of g go into a function that expects miles.
2.7.A2.7.A.3⚠ Watch Out

Order Matters

Composition is not commutative. The functions f∘g and g∘f are typically different, so f(g(x)) and g(f(x)) are typically different values.

Example. Let f(x) = 2x + 3 and g(x) = x². Then (f∘g)(2) = f(4) = 11, but (g∘f)(2) = g(7) = 49. As formulas, f(g(x)) = 2x² + 3 and g(f(x)) = (2x + 3)² = 4x² + 12x + 9.

Compare f∘g with g∘f for the same pair. Blue is f(g(x)) and gold is g(f(x)). Composition is not commutative, so the two are typically different functions.

input x2
-4-3-2-10123402468101214xy
f(x) = 2x + 3    g(x) = x²f(g(x)) = 2x² + 3  (domain: all real numbers)g(f(x)) = (2x + 3)² = 4x² + 12x + 9  (domain: all real numbers)At x = 2:   f(g(2)) = 11,   g(f(2)) = 49The two orders give different values.
⚠️In real life, order changes results too. Putting on socks and then shoes is not the same as shoes and then socks. A 20% discount followed by a $5 coupon gives a different price than the coupon followed by the discount.
2.7.A2.7.A.4Concept

The Identity Function

The function I(x) = x is the identity function. Composing it with any function g changes nothing:

g(I(x)) = I(g(x)) = g(x)

The identity does for composition what 0 does for addition (a + 0 = a) and what 1 does for multiplication (a · 1 = a). This idea comes back in the next topic: a function and its inverse compose to give the identity.

The identity function I(x) = x returns its input. Composing any function with it changes nothing. Compare it with h(x) = x + 1, which is not the identity.

input x3
-3-2-10123-10-8-6-4-20xy
g(x) = 2x − 5    and    I(x) = xg(3) = 1g(inner(3)) = g(3) = 1inner(g(3)) = 1✓ Both compositions equal g(x) exactly. The identity function does for composition what 0 does for addition and 1 does for multiplication.x + 0 = x (0 is the additive identity). x · 1 = x (1 is the multiplicative identity). I(g(x)) = g(I(x)) = g(x).
💡A function like h(x) = x + 1 is not the identity, because composing with it shifts the graph.
2.7.B2.7.B.12.7.B.2Math

Building a Composition by Substitution

Function composition is useful for relating two quantities that are not directly related by an existing formula. If the radius of a circle depends on time and the area depends on radius, composition connects area and time.

When analytic forms of f and g are available, an analytic form of f∘g is built by substituting g(x) for every x in f.

f(x) = x² + 3x  and  g(x) = 2x − 1  →  f(g(x)) = (2x − 1)² + 3(2x − 1) = 4x² + 2x − 2

To build f(g(x)) analytically, substitute g(x) for every x in f. Then check: the number from the chain of two steps should match the number from the new formula.

input2
inner: r(t) = 3t (radius in cm after t seconds)outer: A(r) = πr² (area in cm²)substitute: A(r(t)) = π(3t)²simplify: A(r(t)) = 9πt²input = 2chain: inner gives 6, then outer gives 113.097new formula at 2: 113.097✓ The two methods agree.
🔑Put parentheses around g(x) when you substitute. Writing 2x − 1² instead of (2x − 1)² is a common error.
2.7.B2.7.B.3Concept

Tables and Graphs of f∘g

A numerical or graphical representation of f∘g can often be built by calculating or estimating values for (x, f(g(x))). A table with a column for x, a column for g(x), and a column for f(g(x)) keeps the order clear. The graph of f∘g has gaps wherever the composition is undefined.

Example.For f(x) = √x and g(x) = x − 4, the values at x = 4, 5, 6 are f(g(4)) = √0 = 0, f(g(5)) = √1 = 1, and f(g(6)) = √2 ≈ 1.414. For x < 4 the table says undefined.

A numerical or graphical representation of f∘g comes from calculating (x, g(x), f(g(x))) for many inputs. Orange dots are the table values and the curve shows the whole function.

-2-1012345600.20.40.60.811.21.4xf(g(x))
x-2-10123456
g(x)-6-5-4-3-2-1012
f(g(x))undefinedundefinedundefinedundefinedundefinedundefined011.414
f(x) = √x    g(x) = x − 4f(g(x)) = √(x − 4)   Domain: x ≥ 4Where the table says “undefined”, the graph has a gap or a break: g's output is not an allowed input of f.
💡A composition can have a hole, a break, or an asymptote that neither f nor g shows by itself. Check the domain.
2.7.C2.7.C.1Concept

Decomposing a Function

A function given analytically can often be decomposed into less complicated functions. Ask what is done to x first, then what is done to that result. When properly decomposed, the variable in the outer function replaces each instance of the inner function.

Example. h(x) = (3x − 4)⁵. First compute 3x − 4 (inner g), then raise to the fifth power (outer f(u) = u⁵). So h = f∘g. A function can have more than two layers: 5·3x−2 + 1 is three steps (subtract 2, raise 3 to it, then multiply by 5 and add 1).

A function given analytically can be decomposed into simpler functions. Work from the inside out: whatever you do to x first is the inner function. In the outer function, the variable replaces each instance of the inner function.

input x2
inner: 3x − 4:   2 → 2outer: u⁵:   2 → 32chain result: 32h(2) computed directly: 32✓ The pieces compose back to h.
⚠️A decomposition is not unique, but it must work. Always check that putting the pieces back together gives the original function.
2.7.C2.7.C.22.7.C.3Concept

Transformations Are Compositions

The transformations from earlier units are compositions in disguise. An additive transformation that translates a graph is the composition of g(x) = x + k with f. A multiplicative transformation that dilates a graph is the composition of g(x) = kx with f.

CompositionEffect on the graph of f
f(g(x)) = f(x + k)horizontal translation (left if k > 0)
g(f(x)) = f(x) + kvertical translation (up if k > 0)
f(g(x)) = f(kx)horizontal dilation by a factor of 1/k
g(f(x)) = k·f(x)vertical dilation by a factor of k

An additive transformation is a composition with g(x) = x + k, and a multiplicative transformation is a composition with g(x) = kx. Whether g goes inside or outside decides whether the change is horizontal or vertical. Blue is the new graph and gold is the original f.

shift k2
-4-2024024681012xy
f(x) = x²Inner function g(x) = x + 2. Then f(g(x)) = f(x + 2): a horizontal translation left by 2.Translations come from g(x) = x + k.Inside f the change is horizontal and works “backwards”. Outside f it is vertical.
🔑Inside means horizontal and outside means vertical. For the exponential function, f(x + 3) with f(x) = 2x gives 2x+3 = 8·2x, so a horizontal translation is also a vertical dilation. This is the idea from Lesson 2.4.
← Back to Lesson 2.7Try Guided Practice →Ready for 2.8? Inverse Functions: a function and its inverse compose to give the identity.