AP Precalculus · Topic 2.7 · Reading guide, about 5 min

Combining functions by composition

Learn to compose functions from formulas, tables and graphs, find domains, and break a function into simpler pieces.

In one minute

Composition feeds the output of one function into another, like a two-step machine. You write it f(g(x))f(g(x)) and read it as "f of g of x". The inner function gg works first, and ff works on whatever gg produces.

Composition matters because many real situations chain together (a temperature changes the price, the price changes the profit), and because inverses, logarithms and transformations are all built on it.

Key terms

Composition
Applying one function to the output of another. (f∘g)(x)(f\circ g)(x) means f(g(x))f(g(x)).
Inner function
The function closest to xx in f(g(x))f(g(x)). Here it is gg, and it is evaluated first.
Outer function
The function applied last in f(g(x))f(g(x)). Here it is ff, and its input is the output of gg.
Domain of a composition
Inputs xx that are allowed in gg and whose outputs g(x)g(x) are allowed in ff.
Decomposition
Writing a function as a composition of two simpler functions, such as x−4\sqrt{x-4} from x−4x-4 and then a square root.
Identity function
The function I(x)=xI(x)=x. Composing any function with it, in either order, changes nothing: f(I(x))=I(f(x))=f(x)f(I(x))=I(f(x))=f(x).
Order of composition
Which function goes first. In general f(g(x))f(g(x)) and g(f(x))g(f(x)) are different functions.

Composing from formulas

To compose from formulas, replace every xx in the outer function with the entire inner expression. Put parentheses around the inner expression so signs and exponents stay correct.

Let f(x)=2x+3f(x)=2x+3 and g(x)=x2−1g(x)=x^2-1. For f(g(x))f(g(x)), replace xx in ff with x2−1x^2-1: f(g(x))=2(x2−1)+3=2x2−2+3=2x2+1f(g(x))=2(x^2-1)+3=2x^2-2+3=2x^2+1. For g(f(x))g(f(x)), replace xx in gg with 2x+32x+3: g(f(x))=(2x+3)2−1=4x2+12x+9−1=4x2+12x+8g(f(x))=(2x+3)^2-1=4x^2+12x+9-1=4x^2+12x+8.

Test with x=2x=2. First g(2)=4−1=3g(2)=4-1=3, then f(3)=9f(3)=9, and the formula 2(2)2+1=92(2)^2+1=9 agrees. In the other order, f(2)=7f(2)=7, then g(7)=48g(7)=48, and 4(4)+12(2)+8=484(4)+12(2)+8=48 agrees. The two orders gave 9 and 48, so order matters.

A good habit is to name the pieces before you substitute. Say out loud which function is inner and which is outer, then write the outer rule with an empty pair of parentheses and drop the inner expression into it. This keeps you from distributing a coefficient to the wrong terms or dropping a negative sign. It also makes longer chains, such as f(g(h(x)))f(g(h(x))), manageable: start from hh and work outward one layer at a time.

Composing from tables and graphs

With a table, work in two lookups. To find f(g(3))f(g(3)), find g(3)g(3) in the table for gg, then look that number up as an input in the table for ff. If the second lookup is missing from the table, the composed value is not defined by the table.

With graphs, do the same trip by eye. Start at x=3x=3 on the graph of gg, read the height, then move to that value on the horizontal axis of ff and read its height. Always write the intermediate value down so you do not lose track of which function you are on.

Composition from two tables (hypothetical values)
xg(x)f(x)f(g(x))
1357
2195
3279

Domain of a composition

A composition needs two things to work. The input must be allowed in the inner function, and the inner output must be allowed in the outer function. The domain is every xx that passes both tests.

Take f(x)=xf(x)=\sqrt{x} and g(x)=x−4g(x)=x-4. Then f(g(x))=x−4f(g(x))=\sqrt{x-4}, which needs x−4≥0x-4\ge 0, so the domain is x≥4x\ge 4. In the other order, g(f(x))=x−4g(f(x))=\sqrt{x}-4, and the only restriction is x≥0x\ge 0. Same two functions, different domains.

Here is the same idea with a denominator. Let f(x)=1xf(x)=\dfrac{1}{x} and g(x)=x−2g(x)=x-2. Then f(g(x))=1x−2f(g(x))=\dfrac{1}{x-2}, and the input x=2x=2 makes g(2)=0g(2)=0, which ff cannot accept. So the domain excludes 2. Notice that this exclusion is visible in the final formula, but in other cases a cancellation can hide it, which is why you check the inner function first.

Decomposing and transformations

To decompose, look for the last operation you would do when evaluating. For h(x)=(5x−1)3h(x)=(5x-1)^3, you would cube last, so let g(x)=5x−1g(x)=5x-1 and f(x)=x3f(x)=x^3. Then h(x)=f(g(x))h(x)=f(g(x)). Decompositions are not unique, but pick pieces that are simple.

Transformations are compositions. If ff is the base function, then f(x)+kf(x)+k composes ff with the function x+kx+k on the outside, and f(x−h)f(x-h) composes ff with x−hx-h on the inside. Outside changes move or stretch the output; inside changes move or stretch the input. This is why f(2x)f(2x) and 2f(x)2f(x) behave differently. In the same way, 2f(x)2f(x) composes ff with the function 2x2x on the outside (a vertical dilation), and f(2x)f(2x) composes ff with 2x2x on the inside (a horizontal dilation). The simplest function of all is the identity function I(x)=xI(x)=x, which returns its input unchanged. Composing with it in either order changes nothing: f(I(x))=f(x)f(I(x))=f(x) and I(f(x))=f(x)I(f(x))=f(x). It matters because it is the target for inverses: two functions undo each other exactly when their composition is the identity.

Try k(x)=x+1−2k(x)=\sqrt{x+1}-2 as a chain of three simple steps: add 1, take the square root, subtract 2. Reading a formula as a chain tells you the order in which a graph is built, and it tells you how to evaluate it without mistakes.

How it connects

  • Back to 1.12: shifting, stretching and reflecting graphs are compositions with simple linear functions.
  • Forward to 2.8: an inverse is the function whose composition with the original returns the identity.
  • Forward to 2.10: the logarithm and exponential of the same base undo each other, which you check by composing them.

Common mistakes

  • Reading the order backwards. In f(g(x))f(g(x)) the inner function gg acts first. Evaluate from the inside out.
  • Multiplying instead of composing. f(g(x))f(g(x)) is not f(x)⋅g(x)f(x)\cdot g(x). Substitute, do not multiply.
  • Forgetting parentheses. Replacing xx in x2x^2 with x+1x+1 gives (x+1)2(x+1)^2, not x+12x+1^2.
  • Using only the simplified formula for the domain. The domain must also respect the inner function, even if a restriction seems to disappear after simplifying.

How it shows up on the exam

  • Evaluating f(g(a))f(g(a)) from two tables or two graphs, sometimes with a value that does not appear in the table.
  • Writing a composed formula, then asking for its domain or a value, or deciding which of two orders gives a stated result.
  • Identifying a pair of functions whose composition equals a given function.

Check yourself

  1. For f(x)=x+5f(x)=x+5 and g(x)=3xg(x)=3x, what are f(g(x))f(g(x)) and g(f(x))g(f(x)), and why are they different?
  2. What is the domain of x+2\sqrt{x+2} viewed as a composition?
  3. How would you split 1x2+1\dfrac{1}{x^2+1} into an inner and an outer function?
  4. If g(4)=7g(4)=7 and f(7)=−1f(7)=-1, what is f(g(4))f(g(4)) and what do you know about g(f(4))g(f(4))?

Practice this topic. AP Practice questions on exactly what this lesson covers, with an explanation for every answer.