College Algebra taught you to build f(g(x)) from two given functions. Calculus needs the reverse skill just as often: look at a single messy expression like \sqrt{3x^2+1} and see, instantly, the two simpler machines chained inside it. That reverse skill is decomposition, and this section leans on it hardest. It is the move a key differentiation technique, coming up in a few chapters, asks you to make every time.
Think of a composite function as gift wrap on top of gift wrap. To build one, you wrap the inner box first, then wrap the outer paper around it. That's composing from the inside out. To decompose one, you unwrap from the outside in. Whatever paper you tear off first is the outer function, and whatever's left in your hands afterward is everything that was inner. The question "what's the very last operation this formula performs?" always answers "what's the outer function?" It names the layer you'd strip away first to see what's underneath.
Composing two functions means feeding the output of one straight into the input of the other, written (f\circ g)(x) = f(g(x)): first compute g(x), then hand that number to f, so composing always produces one brand-new function out of the two you started with. Decomposing functions means running that same process backwards on a single formula: given h(x), find an "outer" function f and an "inner" function g with h(x) = f(g(x)). The split is never unique (you could always let g(x) = x and f = h), but there's almost always one useful split. Let the inner function g be whatever's being operated on last, as you'd compute it by hand. For h(x) = \sqrt{3x^2+1}, you'd compute 3x^2+1 first and take the square root last. So the square root is outer, and g(x) = 3x^2+1 is inner.
Formula
Function Composition
also known as: (f ∘ g)(x)
Recalled from College Algebra · Composition and inverse functions — first taught there.
apply g first, then apply f to the result. Its domain is every x in the domain of g for which g(x) lies in the domain of f.
Run it forward
Click each input chip through f then g — watch the value change at each stage.
Loading interactive…
The composition, live
Drag a — this is (f \circ g)(x) for g(x) = ax+1 and f(x) = \sqrt{x}.
Loading interactive…
Worked example
Decomposing a composite function
-
1
Decompose h(x) = (2x - 5)^4 into f(g(x)).
-
2the outer function is whatever wraps everything else
Ask what the LAST operation performed is. Reading the formula left to right as a calculation: first compute 2x - 5, and only then raise the result to the 4th power. Raising to a power is last, so that's the outer function.
the outer function is whatever wraps everything else
-
3
Let the inner function be everything that operation is applied to: g(x) = 2x - 5.
-
4
Let the outer function be that same operation, applied to a placeholder input: f(x) = x^4.
-
5
Check it: f(g(x)) = f(2x-5) = (2x-5)^4 = h(x). ✓
Loading interactive…
Correct split, or swapped?
Each card claims an outer/inner split for h(x). Sort it as correct, or as having f and g swapped.
Loading interactive…
Where this goes next
Differentiating composed functions, three chapters ahead
Every problem about differentiating a composed function starts with this move: look at one formula, and split it into an outer function and an inner function. The rule for differentiating a composition is short to state. The real work of using it is almost always this decomposition step, done correctly, before any differentiating happens.
Check your understanding (counts toward your progress)
(Problem #205) Write h(x)=\left(2x+6\right)^{5} as a composition h(x)=f(g(x)). Which pair (f,g) is correct?
Right on try — credit. Right — the answer had already been shown, so no credit this time. Next try is worth Answer shown after three tries — this one no longer earns credit. You chose to see the answer — this one earns no credit.
Why
h(x)=f(g(x)) requires g to be the INNER function computed first, then f the OUTER function applied to that result -- here g(x)=2x+6 is computed first, then raised to the 5th power by f(u)=u^{5}.
A sensor's reading first passes through a calibration stage g(x)=x^2+3, then a scaling stage f(x)=2x-1. If the raw reading is -1, what value comes out of the scaling stage?
Right on try — credit. Right — the answer had already been shown, so no credit this time. Next try is worth Answer shown after three tries — this one no longer earns credit. You chose to see the answer — this one earns no credit.
Why
The calibration stage gives g(-1)=(-1)^2+3=4, and the scaling stage then gives f(4)=2(4)-1=7.
Correct answer
Also accepted:
Why
Practice: Composing and decomposing, one layer at a time (3 problems · doesn’t affect your progress)
Why does (f\circ g)(x) generally give a different result than (g\circ f)(x)?
Right on try — credit. Right — the answer had already been shown, so no credit this time. Next try is worth Answer shown after three tries — this one no longer earns credit. You chose to see the answer — this one earns no credit.
Composition is not generally commutative -- (f\circ g)(x)=f(g(x)) and (g\circ f)(x)=g(f(x)) apply the two functions in opposite orders, which usually produces different results.
Both orders are perfectly well-defined as long as the domains line up -- neither one is somehow invalid.
The two orders can differ for linear functions too, not just other shapes -- cdf-1 and cdf-2 above use linear g and still get different answers.
Why
f(g(x)) applies g first and feeds its output into f; g(f(x)) does the reverse -- swapping which function runs first almost always changes the final result, exactly as cdf-1 (17) and cdf-2 (13) show.
Compare cdf-1 and cdf-2 above -- both use the same f and g, but applying them in the opposite order gave a different final number.
Each order feeds a different value into the second function
For h(x) = \dfrac{1}{(x+6)^2}, which outer/inner split is correct?
Right on try — credit. Right — the answer had already been shown, so no credit this time. Next try is worth Answer shown after three tries — this one no longer earns credit. You chose to see the answer — this one earns no credit.
This has the outer and inner functions swapped -- the last operation performed on x+6 is squaring and reciprocating, which has to be the outer layer.
This buries the entire squaring step inside the inner function instead of leaving it in the outer layer, where the final "take the reciprocal of a square" operation belongs.
This doesn't correctly separate the squaring from the reciprocal -- check that f(g(x)) actually reproduces h(x) term by term.
Why
Computing by hand, you'd find x+6, square it, then take the reciprocal last -- so f(x)=1/x^2 is outer and g(x)=x+6 is inner.
Ask what the LAST operation performed is: computing x+6, then squaring it, then taking the reciprocal -- the last step is the outer function.
Outer f(x)=1/x^2, inner g(x)=x+6
If f is only defined for inputs \ge 0, and g(x)=x^2-9, for which x is (f\circ g)(x) defined?
Right on try — credit. Right — the answer had already been shown, so no credit this time. Next try is worth Answer shown after three tries — this one no longer earns credit. You chose to see the answer — this one earns no credit.
This is the interval where g(x)=x^2-9 is NEGATIVE, exactly the opposite of what f needs -- f only accepts nonnegative inputs.
The composition inherits g's own domain restriction on top of needing g(x) to land in f's domain -- it isn't unrestricted here.
g(x) equals 0 at those two points, which does satisfy g(x)\ge0, but plenty of other x-values do too -- this misses the whole outer region.
Why
(f\circ g)(x) is defined wherever g(x) lies in f's domain, [0,\infty): x^2-9\ge0 gives x\le-3 or x\ge3.
The composition needs g(x) itself to land in f's domain -- work out where x^2-9 is greater than or equal to 0.
x \le -3 or x \ge 3
Quick review
Practice from earlier coursework, pulled in for this topic.
From College Algebra
If f(x) = 2x + 1 and g(x) = x - 3, find (fg)(4).
Right on try — credit. Right — the answer had already been shown, so no credit this time. Next try is worth Answer shown after three tries — this one no longer earns credit. You chose to see the answer — this one earns no credit.
Why
Run 4 through both machines and multiply the outputs: f(4) = 9 and g(4) = 1, so (fg)(4) = 9 \cdot 1 = 9. Multiplying functions is just multiplying their outputs point by point.
Correct answer
Also accepted:
Why
Evaluate f(4) and g(4) separately, then multiply the two results together.
From College Algebra
If f(x) = x^2 and g(x) = x - 1, find a formula for (f \circ g)(x).
Right on try — credit. Right — the answer had already been shown, so no credit this time. Next try is worth Answer shown after three tries — this one no longer earns credit. You chose to see the answer — this one earns no credit.
Any equivalent form counts — 2x+3, 3 + 2·x, … Use the keypad below the field for fractions, roots, and other symbols.
Why
(f \circ g)(x) = f(g(x)): take g's entire output, x - 1, and drop it into f's input slot. f(x-1) = (x-1)^2, which expands to x^2 - 2x + 1. (The other order gives g(f(x)) = x^2 - 1 — a different function.)
Correct answer
Also accepted:
Why
Take g's entire output and substitute it into f's formula wherever x appears.