Combining two functions into one, finding f∘g and g∘f with their domains, and working backwards to find a missing function.
If $g$ turns $x$ into $g(x)$ and $f$ then turns that into $f(g(x))$, the combined machine is the composite function $f \circ g$: $$(f \circ g)(x) = f(g(x)).$$ Read it from the right: $g$ acts first, $f$ second.
Example: Let $f(x) = 2x + 1$ and $g(x) = x^2$. Find $f \circ g$ and $g \circ f$.
$(f \circ g)(x) = f(x^2) = 2x^2 + 1$.
$(g \circ f)(x) = g(2x + 1) = (2x + 1)^2 = 4x^2 + 4x + 1$.
Answer: $fg(x) = 2x^2 + 1$ and $gf(x) = 4x^2 + 4x + 1$. They are different, so the order matters.
$(f \circ g)(x)$ exists only if $x$ is in the domain of $g$ and $g(x)$ is in the domain of $f$. Always find the domain from the original functions, then simplify the formula. Do not read it from the simplified formula, because simplifying can hide a restriction.
Example: $f(x) = \sqrt{x}$ and $g(x) = x - 4$, both with their natural domains. Find $f \circ g$ and $g \circ f$ with their domains.
$(f \circ g)(x) = \sqrt{x - 4}$. $g$ accepts every real $x$, but $f$ needs its input $\ge 0$: $x - 4 \ge 0$. Domain $[4, \infty)$.
$(g \circ f)(x) = \sqrt{x} - 4$. $f$ needs $x \ge 0$, and $g$ accepts any output. Domain $[0, \infty)$.
Answer: $fg(x) = \sqrt{x-4}$ on $[4, \infty)$; $gf(x) = \sqrt{x} - 4$ on $[0, \infty)$.
Example: Let $f(x) = \dfrac{x}{x + 1}$ for $x \ne -1$. Find $f \circ f$ and its domain.
$f(f(x)) = \dfrac{\frac{x}{x+1}}{\frac{x}{x+1} + 1} = \dfrac{\frac{x}{x+1}}{\frac{2x+1}{x+1}} = \dfrac{x}{2x + 1}$.
For the domain, $x \ne -1$ (for the inner $f$), and the inner value $\dfrac{x}{x+1}$ must not be $-1$: $\dfrac{x}{x+1} = -1 \Rightarrow x = -x - 1 \Rightarrow x = -\tfrac{1}{2}$.
Answer: $(f \circ f)(x) = \dfrac{x}{2x + 1}$, domain $\mathbb{R} \setminus {-1, -\tfrac{1}{2}}$. The simplified formula alone would hide the missing point $x = -1$.
Finding $f$ when $g$ and $f \circ g$ are known. Put $u = g(x)$, solve for $x$ in terms of $u$, and rewrite $f(g(x))$ in terms of $u$.
Finding $g$ when $f$ and $f \circ g$ are known. Write $f(g(x))$ using the rule of $f$ and solve for $g(x)$.
Example: $g(x) = 2x + 1$ and $f(g(x)) = 4x^2 + 4x + 3$. Find $f(x)$.
Notice $4x^2 + 4x = (2x+1)^2 - 1$, so $f(g(x)) = (2x + 1)^2 - 1 + 3 = (2x+1)^2 + 2$. With $u = 2x + 1$ this says $f(u) = u^2 + 2$.
Answer: $f(x) = x^2 + 2$.
Exam tip: Papers often give $f \circ g$ and ask for the domain, or ask you to solve $fg(x) = gf(x)$. Write out $f(g(x))$ in full before simplifying, and state the domain separately. Check that each solution of an equation lies in the domain.