AP® Precalculus · Unit 2 · Topic 2.7

Composition of Functions

Composition builds a new function by feeding the entire output of one function into the input of another: f(g(x)) means plug g(x) in for every x in f. Order matters, so f(g(x)) and g(f(x)) are usually different functions.

Think of f and g as machines. g takes a number, does its work, and spits out a new number. If you feed that result straight into f, you've built one combined machine that goes directly from the original input to the final output. That combined machine is f(g(x)), read 'f of g of x.' Nothing mysterious is happening mathematically — you are just replacing every x in f's formula with the whole expression for g(x), and simplifying.

Mechanically: write down f's formula, find every spot where x appears, and drop in g(x) there, parentheses and all, then expand. For f(x) = x2 + 1 and g(x) = 3x - 2, f(g(x)) = (3x-2)2 + 1 = 9x2 - 12x + 4 + 1 = 9x2 - 12x + 5. Going the other way, g(f(x)) = 3(x2+1) - 2 = 3x2 + 1. Different formulas, different graphs — composition is not commutative, because squaring-then-scaling is not the same process as scaling-then-squaring.

Composition is the glue behind inverse functions, which is the next idea in this unit. Two functions are inverses exactly when composing them in either order gives back x, the identity function. Composing any function with the identity, f(x) = x, changes nothing: f(x) is already its own simplest input, so f(id(x)) = f(x) and id(f(x)) = f(x). That's why identity behaves like the number 1 does under multiplication — it's the do-nothing partner, and it sets up the test you'll use to check inverses.

Key terms

Composition
Combining two functions by using the output of one as the input of the other, written f(g(x)).
f(g(x))
The result of substituting g(x) for every x in the formula for f.
Identity function
The function f(x) = x, which returns whatever input it receives unchanged.
Commutative
A property where order doesn't change the result; composition generally lacks this property.

Watch it explained

  1. How it worksHow do you substitute g(x) into every x of f to get a formula for f(g(x))?
  2. Worked exampleFind f(g(x)) and g(f(x)) for f(x) = x² + 1 and g(x) = 3x - 2 and compare them.
  3. Common mistakeWhy isn't f(g(x)) the same as g(f(x))?
  4. Going furtherWhat happens when you compose any function with the identity function f(x) = x?

Check yourself

Your turn1 of 2
For f(x) = x2 + 7 and g(x) = 5x - 8, find f(g(x)) as a function of x.

End of topic.