MISSION · Algebra

Composing Functions

Feeding one machine's output into the next, and why swapping them changes the answer

Explorer level
Grades 10-12
Quest time
6 minutes
Mission skill
Evaluating and building f(g(x)), and knowing why the order matters

LEVEL 1 · EXPLORE

Make the idea move

Change the controls and watch what happens. Follow your curiosity and see what you notice.

Loading the activity…

LEVEL 2 · LEARN

Unlock the explanation

Open the chapters in any order. Try the examples as you go.

The idea in one sentence

Composing two functions means wiring them in series — the output of one becomes the input of the next — and the wiring order changes the answer.

Two machines in a row

Think of each function as a machine. Put 5 into \(g(x) = 2x\) and 10 comes out. Put that 10 into \(f(x) = x + 3\) and 13 comes out.

That two-step journey is the composition, written \(f(g(5)) = 13\) or \((f \circ g)(5)\).

Read \(f \circ g\) as “f after g”. The notation is annoying: \(g\) is written second but runs first. Brackets tell the truth — in \(f(g(x))\), \(g\) is nested innermost, and innermost happens first, the same as anywhere else in order of operations.

Order matters

Swap the machines and follow 5 again. Now \(f\) goes first: \(5 + 3 = 8\), then \(g\) doubles it to 16.

\[f(g(5)) = 13 \qquad g(f(5)) = 16\]

Doubling then adding 3 is not the same as adding 3 then doubling. Composition is not commutative, and unlike with \(+\) or \(\times\), that is the normal case rather than the exception. Getting the same answer both ways is the thing worth noticing.

Composing with algebra, not numbers

To get a formula rather than a value, substitute the whole inner function wherever the outer one says \(x\).

With \(f(x) = x^2\) and \(g(x) = x - 1\):

\((f \circ g)(x) = f(x - 1) = (x - 1)^2\) \((g \circ f)(x) = g(x^2) = x^2 - 1\)

Two genuinely different functions. The first is a parabola shifted right; the second is a parabola shifted down.

The reliable method is to write the outer function with an empty box where \(x\) was — \(f(\square) = \square^2\) — and then drop the entire inner function into the box, brackets and all. Most errors on this topic are a missing bracket, and the box makes the bracket automatic.

The domain question

\(f \circ g\) can only accept an \(x\) that \(g\) accepts and whose output \(f\) accepts. Both gates, in that order.

Let \(g(x) = x - 4\) and \(f(x) = \sqrt{x}\). Then \((f \circ g)(x) = \sqrt{x - 4}\), and although \(g\) is happy with any number, \(f\) refuses negatives — so the domain is \(x \ge 4\).

The other direction is worse. \((g \circ f)(x) = \sqrt{x} - 4\) needs \(x \ge 0\), and here the restriction comes from the inner function instead. Check both stages every time.

Where it turns up

  • Inverse functions. \(f\) and \(f^{-1}\) are inverses exactly when \(f(f^{-1}(x)) = x\) and \(f^{-1}(f(x)) = x\). Composition is the test.
  • Transformations. Every shift, stretch and reflection is a composition with a simple function, which is why \(f(x - 3)\) moves the graph right.
  • The chain rule. \(\frac{d}{dx}f(g(x)) = f'(g(x)) \cdot g'(x)\) exists solely to differentiate compositions, so spotting the inner function is the first step of every chain rule problem.
  • Unit conversions, spreadsheets, code. Any pipeline where one result feeds the next.

Common mix-ups

  • Running them in the wrong order. \(f \circ g\) does \(g\) first. Always.
  • Multiplying instead of composing. \(f(g(x))\) is not \(f(x) \cdot g(x)\).
  • Dropping brackets. \(f(x) = x^2\) with \(g(x) = x - 1\) gives \((x-1)^2\), not \(x^2 - 1\).
  • Checking the domain of the final formula only. \(\sqrt{x}\) hidden inside can rule out values the simplified answer looks happy with.

Check yourself

With \(f(x) = x + 3\) and \(g(x) = 2x\), find \(f(g(5))\) and \(g(f(5))\). Then with \(f(x) = x^2\) and \(g(x) = x - 1\), find \((f \circ g)(x)\).

\(g(5) = 10\), then \(10 + 3 = 13\). The other way, \(f(5) = 8\), then \(2 \times 8 = 16\). And \(f(x-1) = (x-1)^2\) — brackets and all.

LEVEL 3 · REFLECT

Add this quest to your trail

When you feel ready, mark this idea as explored. You can always come back and try it again.

EXPLORER STRATEGIES

More ways to see it

Loading shared methods…
Share how you learned it