Resources
Functions inside functions
A function is a machine: a number goes in, a number comes out. Composition is what happens when two machines run in a row — the output of the first is fed directly into the second, no stops. We write the result as \(f(g(x))\), and it is worth reading that notation aloud the way it actually operates: \(x\) goes into \(g\) first, and whatever \(g\) produces goes into \(f\). The function written on the outside acts last.
The pipeline below runs live. Choose the two machines, slide the input, and watch the intermediate value pass from one to the other.
The upper band is the pipeline: x enters g, and g's output enters f. The graph below it draws the composite f(g(x)) in ink, with g dashed and f dotted for reference. Where the composite line breaks, the first machine has produced a value the second cannot accept. Swap the order and the composite changes shape — composition is not commutative, and the graph shows it immediately.
Order matters
Set the machines to \(g(x) = 2x + 1\) first and \(f(x) = x^2\) second, and read the pipeline at \(x = 3\): the 3 becomes 7, and the 7 becomes 49. That is \(f(g(3)) = (2 \cdot 3 + 1)^2 = 49\). Now press “swap f and g,” so the squaring happens first: 3 becomes 9, and 9 becomes 19. That is \(g(f(3)) = 2 \cdot 3^2 + 1 = 19\).
Same two machines, same input, different answers — because \((2x+1)^2\) and \(2x^2 + 1\) are different functions. Composition is not commutative, and this is the single most common composition error: treating \(f(g(x))\) and \(g(f(x))\) as interchangeable because both “use \(f\) and \(g\).” The graph makes the difference visible faster than the algebra does. Swap the order and the composite’s whole shape changes.
Reading a composite from the outside in
The harder skill, and the one exams reward, runs in reverse: you are handed the finished composite and asked to see the machines inside it. Take
\[h(x) = \sqrt{3x + 1}.\]Nobody hands you \(f\) and \(g\); you have to find them. The reliable method is to ask what the function does to its input, last. Here, the last thing that happens is a square root — so the outside function is \(f(u) = \sqrt{u}\), and everything under the root is the inside, \(g(x) = 3x + 1\). Check by running the pipeline forward: \(x = 5\) gives \(3(5) + 1 = 16\), and \(\sqrt{16} = 4\). The decomposition works when composing it back gives you the original function.
Two habits make this reliable. First, give the inside a name — writing \(u = 3x + 1\), so that \(h = \sqrt{u}\), turns a nested expression into two simple ones. Second, expect more than one right answer: \(h(x) = (x+2)^6\) decomposes naturally as \(u = x + 2\) inside the sixth power, but \(u = (x+2)^2\) inside a cube is also correct. Decompositions are not unique; useful ones put the messy part inside and leave the outside simple.
Domains travel through the pipeline
Set \(g(x) = 2x + 1\) first and \(f(x) = \sqrt{x}\) second, and slide the input left. The composite’s graph stops abruptly — to the left of \(x = -\tfrac{1}{2}\), the first machine produces negative outputs, and the second machine cannot accept them. The pipeline readout says so directly: \(g(x)\) has a value, and \(f(g(x))\) is undefined.
This is the general rule, and it is worth stating carefully: \(x\) is in the domain of \(f \circ g\) exactly when \(x\) is in the domain of \(g\) and \(g(x)\) is in the domain of \(f\). The domain of a composite is inherited from both machines, not read off the final simplified formula. Simplification can hide the restriction; the pipeline cannot.
Why this skill compounds
Nearly everything built later in precalculus is a composition wearing a disguise. A transformed graph like \(y = \sin(2x - \pi)\) is a composition; an exponential model like \(A(t) = 50e^{0.03t}\) is a composition; inverting a function is running a pipeline backward, machine by machine, last one first. And for those continuing on: calculus differentiates composite functions by exactly the outside-in reading practiced here — the students who struggle there are almost never confused about the new rule, only about seeing which function is inside which. Learn to see the seams now and that course gets noticeably easier.
A self-test at the pipeline: set \(g\) to \(\sqrt{x}\) and \(f\) to \(x^2\), then press swap and compare the two composites at \(x = -4\). One returns 4 and the other is undefined, though both simplify to formulas that look harmless, \(x\) and \(\vert x\vert\). The order decided which restriction survived, and neither finished formula records it.