Unit 2 Topic 2.7

Composition of Functions

see every function move

4 min readfreeNot practiced

Many processes happen in stages. A store takes a discount and then adds tax. A thermostat reads a temperature in Celsius and a display converts it to Fahrenheit. Each stage is a function, and running one stage after another is called composition. This page shows how to evaluate a composite from a table, a graph or a formula, why order matters, which inputs a composite can take, and how to split a function into stages.

What a composite function does

The composite function f(g(x))f(g(x)) takes an input xx, applies gg, and then uses that output as the input of ff. It is also written (f∘g)(x)(f \circ g)(x), read "f of g of x". The function written closest to xx acts first. Think of an assembly line: gg is the first machine and ff is the second.

Because the output of gg becomes an input of ff, the work always goes from the inside out. On the exam, show the inner value: graders look for it.

Worked example 1 (from a table). A table gives g(2)=0g(2) = 0 and f(0)=4f(0) = 4. Find f(g(2))f(g(2)).

Inner value first: g(2)=0g(2) = 0.

Then the outer function at that value: f(g(2))=f(0)=4f(g(2)) = f(0) = 4.

Order matters

Back at the store, take d(p)=p−15d(p) = p - 15 (the discount) and t(p)=1.08pt(p) = 1.08p (the tax). Discount first gives t(d(p))t(d(p))=1.08(p−15)= 1.08(p - 15)=1.08p−16.2= 1.08p - 16.2. Tax first gives d(t(p))=1.08p−15d(t(p)) = 1.08p - 15. They differ by 1.21.2 dollars, whatever the price. Composition is not commutative: f(g(x))f(g(x)) and g(f(x))g(f(x)) are usually different functions. There are exceptions, but never assume one.

Composites from formulas

To write f(g(x))f(g(x)) as a formula, replace every xx in the formula of ff by the whole expression g(x)g(x), in parentheses.

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

f(g(x))=(2x−1)2+3f(g(x)) = (2x - 1)^2 + 3. The parentheses matter: the whole of 2x−12x - 1 is squared.

g(f(x))g(f(x))=2(x2+3)−1= 2(x^2 + 3) - 1=2x2+5= 2x^2 + 5.

At x=1x = 1: f(g(1))=1+3=4f(g(1)) = 1 + 3 = 4, but g(f(1))=2⋅4−1=7g(f(1)) = 2 \cdot 4 - 1 = 7. Different functions.

Composition also explains transformations. With g(x)=x−2g(x) = x - 2, f(g(x))=f(x−2)f(g(x)) = f(x - 2) is the graph of ff moved 22 units right. With f(x)=5⋅2xf(x) = 5 \cdot 2^x and g(x)=x+3g(x) = x + 3, f(g(x))f(g(x))=5⋅2x+3= 5 \cdot 2^{x + 3}=40⋅2x= 40 \cdot 2^x: for an exponential function, a horizontal shift is the same as a vertical dilation.

Composites from graphs

A graph works like a table: read the inner function at xx, then read the outer function at that output. To solve an equation such as g(f(x))=2g(f(x)) = 2, work from the outside in: first find every input of gg that gives 22, then every xx with f(x)f(x) equal to one of those inputs. Several inputs can share an output, so check for more than one.

Worked example 3. The parabola gg reaches 22 at the inputs −1-1 and 33. The line ff has f(0)=−1f(0) = -1 and f(2)=3f(2) = 3. Solve g(f(x))=2g(f(x)) = 2.

Outer step: g(u)=2g(u) = 2 for u=−1u = -1 or u=3u = 3.

Inner step: f(x)=−1f(x) = -1 gives x=0x = 0; f(x)=3f(x) = 3 gives x=2x = 2.

So x=0x = 0 and x=2x = 2. Stopping at −1-1 and 33 gives the values of f(x)f(x), not of xx.

The domain of a composite

An input xx belongs to the domain of f(g(x))f(g(x)) when two things hold: xx is in the domain of gg, and the output g(x)g(x) is in the domain of ff.

Worked example 4. Let f(x)=xf(x) = \sqrt{x} and g(x)=6−2xg(x) = 6 - 2x. Find the domain of f(g(x))=6−2xf(g(x)) = \sqrt{6 - 2x}.

ff needs a non-negative input, so 6−2x≥06 - 2x \ge 0.

Then −2x≥−6-2x \ge -6, and dividing by −2-2 flips the inequality: x≤3x \le 3.

The identity function

The identity function I(x)=xI(x) = x returns every input unchanged. Composing with it does nothing: f(I(x))=f(x)f(I(x)) = f(x) and I(f(x))=f(x)I(f(x)) = f(x). It plays the role for composition that 00 plays for addition and 11 plays for multiplication. You will need it in the next topic.

Taking a function apart

Reading a formula as stages helps you evaluate it, graph it and later undo it. Ask what is done to xx first (the inner function) and what is done to that result (the outer function).

FunctionInner g(x)g(x)Outer f(x)f(x)
h(x)=(3x+1)4h(x) = (3x + 1)^43x+13x + 1x4x^4
h(x)=x2+9h(x) = \sqrt{x^2 + 9}x2+9x^2 + 9x\sqrt{x}
h(x)=2x−5h(x) = 2^{x - 5}x−5x - 52x2^x

A decomposition is not unique, but the order of the stages is fixed by the formula. Check a pair by composing it: f(g(x))f(g(x)) must give back h(x)h(x).

Spot a mistake on this page?