Composite Functions
Chain two functions together — feed the output of one straight into the other — and a brand new rule falls out, one that depends entirely on which function you apply first.
Composite functions
With the language of domain, range and mapping types now in place, it's time to combine two functions into one. The composite function $fg(x)$ (also written $f(g(x))$ or $(f\circ g)(x)$) means: apply $g$ first, then apply $f$ to the result. Order matters enormously — $fg(x)$ and $gf(x)$ are generally different functions.
In $fg(x)$, the function written closest to $x$ acts first. So to evaluate $fg(3)$: first compute $g(3)$, then feed that result into $f$. This "inside-out" reading order is the single most common source of composite-function errors — always identify which function is innermost before substituting.
For $fg(x)$ to be defined at a given $x$, that $x$ must lie in the domain of $g$, and the output $g(x)$ must lie in the domain of $f$. The domain of the composite is therefore the set of $x$ in the domain of $g$ for which $g(x)$ also lies in the domain of $f$.
Chaining functions together is only half the picture. The next lesson looks at running a single function backwards — its inverse — which raises a natural question: does composing $f$ with its own inverse just hand you $x$ back again? (It does — that's exactly what makes it an inverse.)
Worked example 1
$fg(x)=2x^2-5$ while $gf(x) = g(2x+1) = (2x+1)^2-3 = 4x^2+4x-2$ — clearly a different function. This confirms composition is not commutative: $fg \neq gf$ in general.
Worked example 2
The domain of a composite is never assumed — it must be derived by checking which inputs to the first function produce outputs that the second function can accept. Here, even though $g(x)=x-4$ is defined for all real $x$, only $x\ge4$ produces an output that $f$ (which needs a non-negative input) can handle.
Worked example 3
Once $fg(x)$ has been simplified into a single expression in $x$, an equation like $fg(x)=23$ is solved exactly like any other equation — the "composite" structure only matters while you're building the expression, not while you're solving it.
Writing $fg(x)$ but actually substituting $f$ into $g$ (i.e. computing $gf(x)$ by accident). Always identify the innermost function first — in $fg(x)$, that's $g$ — and work outward. A quick check: $fg$ is read "f of g", so g is applied first, closest to x.
Check yourself
$f(x)=2x-3$ and $g(x)=x^2+1$. Find $gf(x)$, and hence solve $gf(x)=10$.
(Hint: substitute f into g first, since f is the inner function in gf(x).)