Search the complete library

What do you want to learn or calculate?

Quick linksAll calculatorsMath subjectsPractice questionsFormula library
← Precalculus formulas

Function composition

Use the output of one function as the input of another.

Precalculus · Functions
$$(f\circ g)(x)=f(g(x))$$

Function composition is one of 2 functions formulas in the precalculus section of this library, and it is used at high school level.

Why function composition works

Composition wires two machines in a row: whatever g produces becomes the raw material for f. The parentheses show the wiring, since g sits inside and therefore runs first. The result is a brand new function whose rule is f's rule with g's whole expression written wherever x used to be.

What each symbol means

$g$ is applied first and $f$ second.

Function composition: when it holds

$x$ must lie in the domain of $g$ and $g(x)$ in the domain of $f$.

When it stops applying

The chain breaks if g produces something f cannot accept. With f(x) = √x and g(x) = x − 5, the composition f(g(3)) asks for the square root of −2, so 3 is excluded from the domain even though both functions handle it fine on their own.

Function composition: a worked example

If $f(x)=x^2$ and $g(x)=x+1$, then $(f\circ g)(x)=(x+1)^2$.

The mistake to avoid

What people do: Students run the functions in the order they are written and compute g(f(x)) by accident.

Why it goes wrong: Composition is read from the inside out, and the two orders usually disagree. With f(x) = x² and g(x) = x + 1 at x = 2, f(g(2)) is 9 while g(f(2)) is 5.

Do this instead: Evaluate the inner function first, then feed its output to the outer one. Writing the inner value down as its own number before the second step makes the order impossible to confuse.

Function composition: step by step

  1. Name the unknown, and the unit the answer has to come out in.
  2. Match the symbols to your values. $g$ is applied first and $f$ second.
  3. Check the conditions before substituting. $x$ must lie in the domain of $g$ and $g(x)$ in the domain of $f$.
  4. Substitute, keep exact values to the last line, then test the sign, size, and unit against a rough estimate — the check that catches most precalculus slips.

Where this formula fits

Subject
Precalculus formulas — 10 entries in this library
Topic
Functions
Level
High school

Formulas are easiest to keep when they sit inside a method rather than on a list. Use the links below to see where function composition comes from, to check a calculation against a tool, and to practise it until you can recall it without looking.

Questions about function composition

Is f∘g the same as f times g?

No, and the small circle is what keeps them apart. The product multiplies two outputs, while the composition feeds one output into the other function, and they rarely agree on anything.

Is composition ever commutative?

Occasionally, but do not count on it. It holds when one function is the other's inverse, or in a case like f(x) = x + 1 and g(x) = x + 2, where both orders give x + 3.

How do I find the domain of a composition?

Keep only the inputs g accepts, then throw out any whose output f cannot take. Both restrictions apply, so the domain of the composition is usually smaller than the domain of g.

Where does this show up in calculus?

In the chain rule, which is the derivative of a composition. Spotting the inner and outer functions is exactly the skill that makes differentiating something like sin(3x² + 1) routine.

Stuck on a problem?

Work a function composition problem step by step

Type your own problem, or upload a photo of it. You get the method, the answer, and a check you can repeat yourself.