6.7 Composite Functions

Definition 6.25. Let \(g:X\longrightarrow Y\) and \(f:Y\longrightarrow Z\) be two functions. The composite function \(f\circ g\) is the function \(X\longrightarrow Z\) given by \[(f\circ g)(x)=f\left (g(x)\right ),\] read “\(f\) of \(g\)”. That is: first apply \(g\) to \(x\), then apply \(f\) to the result.

Note 6.26. The order is the thing to get right, and the notation works against you: in \(f\circ g\) the function written second acts first. Reading \((f\circ g)(x)=f(g(x))\) from the inside outwards makes it plain — \(x\) goes into \(g\), and whatever comes out goes into \(f\).

For the composite to make sense at all, the outputs of \(g\) must be things \(f\) can accept: the range of \(g\) must lie inside the domain of \(f\). With \(g:X\to Y\) and \(f:Y\to Z\) this is automatic, which is why the sets are labelled that way above. When the functions are given by formulas rather than by named sets, it has to be checked — \(f(x)=\sqrt {x}\) and \(g(x)=x-10\) compose only for \(x\geq 10\).

Example 6.27.

Let \(f:\mathbb {R}\longrightarrow \mathbb {R}\) and \(g:\mathbb {R}\longrightarrow \mathbb {R}\) be functions defined by \(f(x)=3x^2+x-2\), \(g(x)=\frac {1}{x}\).

Then

(a)
\((gof)(x)=g(f(x))=\frac {1}{f(x)}=\frac {1}{3x^2+x-2}\)
(b)
\((fog)(x)=f(g(x))=3\left (\frac {1}{x}\right )^2+\left (\frac {1}{x}\right )-2=\frac {3}{x^2}+\frac {1}{x}-2\)

We see from (a) and (b) that in general \(fog\neq gof\).

Example 6.28.

1.
Let \(f(x)=\frac {3x}{3-x}\) and \(h(x)=\frac {1}{x^2+1}\)
(a)
Find \((hof)(x)\)
(b)
Solve \((foh)(x)=1\)
2.
Let \(f(x)=\frac {3x}{3-x}\) and \(g(x)=\frac {1}{x}\). Find \((f\circ g)^{-1}(x)\).

Solution. 1(a). \(h\circ f\) means apply \(f\) first, then \(h\): \[(h\circ f)(x)=h\left (f(x)\right )=\frac {1}{\left (\frac {3x}{3-x}\right )^{2}+1} =\frac {(3-x)^{2}}{9x^{2}+(3-x)^{2}} ,\] multiplying above and below by \((3-x)^{2}\) to clear the compound fraction.

1(b). \(f\circ h\) means apply \(h\) first: \[(f\circ h)(x)=f\left (\frac {1}{x^{2}+1}\right ) =\frac {3\cdot \frac {1}{x^{2}+1}}{3-\frac {1}{x^{2}+1}} =\frac {3}{3\left (x^{2}+1\right )-1}=\frac {3}{3x^{2}+2},\] again clearing the compound fraction by multiplying above and below by \(x^{2}+1\). Setting this equal to \(1\), \[\frac {3}{3x^{2}+2}=1 \implies 3x^{2}+2=3 \implies x^{2}=\frac {1}{3} \implies x=\pm \frac {1}{\sqrt {3}} .\]

2. First compose, then invert. Applying \(g\) first, \[(f\circ g)(x)=f\left (\frac {1}{x}\right ) =\frac {\frac {3}{x}}{3-\frac {1}{x}}=\frac {3}{3x-1} .\] Now set \(y=\frac {3}{3x-1}\) and solve for \(x\): \[y(3x-1)=3 \implies 3xy=3+y \implies x=\frac {3+y}{3y},\] so \[(f\circ g)^{-1}(x)=\frac {3+x}{3x},\quad x\neq 0 .\]

Note 6.29. Part 1 shows again that \(f\circ h\) and \(h\circ f\) are different functions — \(\frac {3}{3x^{2}+2}\) against \(\frac {(3-x)^{2}}{9x^{2}+(3-x)^{2}}\) — so composition is not commutative. It is, however, associative: \(f\circ (g\circ h)=(f\circ g)\circ h\) always, because both sides mean ”do \(h\), then \(g\), then \(f\)”.

There is also a shortcut for part 2 worth knowing: \[(f\circ g)^{-1}=g^{-1}\circ f^{-1},\] with the order reversed. To undo “put on socks, then shoes” you take off the shoes first. Try it here: \(g^{-1}(x)=\frac {1}{x}\) and \(f^{-1}(x)=\frac {3x}{x+3}\), and composing them in that order returns \(\frac {3+x}{3x}\) as above.

Questions on this section

Stuck on something here? Ask below and it stays attached to this topic.