A composition puts one function's output into another function. In f(g(x)), evaluate g first, then use that result as the input to f. The order usually changes the answer.

Composition-of-functions PDFs: set 1, set 2, set 3, and additional practice. Use the examples below for substitution, order, and domain checks.

Read composition from the inside out

The notation \((f\circ g)(x)\) means \(f(g(x))\). It is not \(f(x)g(x)\), which multiplies two outputs. Draw a small input chain if helpful: x goes into g, then g's output goes into f. For an expression rather than a number, substitute the whole inner expression wherever the outer function uses its input.

Worked examples: values and formulas

Example 1: a numerical composition. Let \(f(x)=2x+1\) and \(g(x)=x^2\). Find \(f(g(3))\). First \(g(3)=9\). Then \(f(9)=2(9)+1=19\). Reversing the order gives \(g(f(3))=g(7)=49\), so the two results are different.

Example 2: an algebraic composition. With the same functions, \(f(g(x))=2x^2+1\). But \(g(f(x))=(2x+1)^2=4x^2+4x+1\). Keep parentheses around the entire input before expanding.

Example 3: composition with a square root. Let \(f(x)=1/(x-2)\) and \(g(x)=\sqrt{x}\). Then \(f(g(x))=1/(\sqrt{x}-2)\). Require \(x\ge0\) for the square root and \(x\ne4\) to keep the denominator nonzero. The domain is \([0,4)\cup(4,\infty)\).

Check both functions' restrictions

For \(f(g(x))\), x must be allowed by g, and g(x) must be allowed by f. Simplification must not silently restore an excluded input. If \(f(x)=1/x\) and \(g(x)=1/x\), the composition simplifies to x, but its original input still cannot be zero.

If the functions are given by tables, read the inner output first, then look for that value in the outer table's input column. If it is absent and no rule is supplied, do not invent its output.

Practice with worked answers

Use \(f(x)=3x-1\) and \(g(x)=x+4\) for the first three questions.

  1. Find \(f(g(2))\).
  2. Find \(g(f(2))\).
  3. Write \(f(g(x))\) as a simplified formula.
  4. If \(p(x)=\sqrt{x}\) and \(q(x)=x-5\), find \(p(q(x))\) and its real domain.
Show the steps
  1. \(g(2)=6\), then \(f(6)=18-1=\boxed{17}\).
  2. \(f(2)=5\), then \(g(5)=5+4=\boxed9\).
  3. Substitute \(x+4\) into f: \(3(x+4)-1=\boxed{3x+11}\).
  4. \(p(q(x))=\sqrt{x-5}\). Require \(x-5\ge0\), so the domain is \(\boxed{[5,\infty)}\).

Need a substitution refresher? Review function notation and evaluation first.