2.4 Composition of Functions: $f\circ g$
1. Definition of Composite Functions
For two functions $f$ and $g$, the composite function $f\circ g$ is obtained by using the output of $g$ as the input of $f$. In other words, $g$ is performed first, and then $f$ is performed second.
The order is important. In general, $$f\circ g\neq g\circ f.$$ This means that composing functions is usually not commutative.
| Composition | Meaning | Order of operations |
|---|---|---|
| $(f\circ g)(x)$ | $f(g(x))$ | Apply $g$ first, then apply $f$. |
| $(g\circ f)(x)$ | $g(f(x))$ | Apply $f$ first, then apply $g$. |
EXAMPLE 1
Let $$f(x)=2x^2-1,\qquad g(x)=x+1.$$ Find $(f\circ g)(x)$, $(g\circ f)(x)$, $(f\circ g)(1)$, and $(g\circ f)(1)$.
Solution:
- Find $(f\circ g)(x)$: $$\begin{aligned} (f\circ g)(x) &=f(g(x))\\ &=f(x+1)\\ &=2(x+1)^2-1\\ &=2(x^2+2x+1)-1\\ &=2x^2+4x+1. \end{aligned}$$
- Find $(g\circ f)(x)$: $$\begin{aligned} (g\circ f)(x) &=g(f(x))\\ &=g(2x^2-1)\\ &=(2x^2-1)+1\\ &=2x^2. \end{aligned}$$
- Find $(f\circ g)(1)$: $$\begin{aligned} (f\circ g)(1) &=2(1)^2+4(1)+1\\ &=7. \end{aligned}$$ Alternatively, $$\begin{aligned} g(1)&=1+1=2,\\ f(g(1))&=f(2)=2(2)^2-1=7. \end{aligned}$$
- Find $(g\circ f)(1)$: $$\begin{aligned} f(1)&=2(1)^2-1=1,\\ g(f(1))&=g(1)=1+1=2. \end{aligned}$$
EXAMPLE 2
Let $$f(x)=\dfrac{x+1}{2},\qquad g(x)=\sqrt{x}.$$ Find $(f\circ g)(x)$, $(g\circ f)(x)$, $(f\circ f)(x)$, $(g\circ g)(x)$, and $(f\circ f\circ f)(x)$.
Solution:
- Find $(f\circ g)(x)$: $$ (f\circ g)(x) =f(g(x)) =f(\sqrt{x}) =\dfrac{\sqrt{x}+1}{2}. $$
- Find $(g\circ f)(x)$: $$ (g\circ f)(x) =g(f(x)) =g\left(\dfrac{x+1}{2}\right) =\sqrt{\dfrac{x+1}{2}}. $$
- Find $(f\circ f)(x)$: $$\begin{aligned} (f\circ f)(x) &=f(f(x)) =f\left(\dfrac{x+1}{2}\right) =\dfrac{\dfrac{x+1}{2}+1}{2}\\ &=\dfrac{x+1+2}{4} =\dfrac{x+3}{4}. \end{aligned}$$
- Find $(g\circ g)(x)$: $$ (g\circ g)(x) =g(g(x)) =g(\sqrt{x}) =\sqrt{\sqrt{x}} =\sqrt[4]{x}. $$
- Find $(f\circ f\circ f)(x)$: $$\begin{aligned} (f\circ f\circ f)(x) &=f\left((f\circ f)(x)\right) =f\left(\dfrac{x+3}{4}\right) =\dfrac{\dfrac{x+3}{4}+1}{2}\\ &=\dfrac{x+3+4}{8} =\dfrac{x+7}{8}. \end{aligned}$$
2. The Identity Function $i(x)$
The identity function maps every input to itself: $$i(x)=x.$$ Composing any function with the identity function leaves the function unchanged.
EXAMPLE 3
Let $$f(x)=x^2+3x-1,\qquad i(x)=x.$$ Verify that $f\circ i=f$ and $i\circ f=f$.
Solution:
3. Domain Constraints for Compositions (HL)
A composition is only defined when the output of the inner function is allowed as an input of the outer function. Therefore, the domain of a composite function may be more restricted than the domains of the individual functions.
- For $(f\circ g)(x)=f(g(x))$, the function $g$ is applied first. Therefore, the output $g(x)$ must lie inside the domain of $f$.
- If the whole range of $g$ is contained in the domain of $f$, then the composition is defined for every $x$ in the domain of $g$: $$R_g\subseteq D_f.$$
- More generally, the domain of $f\circ g$ is $$D_{f\circ g}=\{x\in D_g:g(x)\in D_f\}.$$
- Similarly, $$D_{g\circ f}=\{x\in D_f:f(x)\in D_g\}.$$
| Composite function | Inner function | Outer function | Domain condition |
|---|---|---|---|
| $(f\circ g)(x)=f(g(x))$ | $g$ | $f$ | $x\in D_g$ and $g(x)\in D_f$ |
| $(g\circ f)(x)=g(f(x))$ | $f$ | $g$ | $x\in D_f$ and $f(x)\in D_g$ |
EXAMPLE 4
Let $$f(x)=\sqrt{x},\qquad g(x)=x-3.$$ Find $(f\circ g)(x)$ and its domain.
Solution:
EXAMPLE 5
Let $$f(x)=\dfrac{1}{x},\qquad g(x)=x-2.$$ Find $(f\circ g)(x)$, $(g\circ f)(x)$, and the domain of each composite function.
Solution:
4. Composition as a Process Diagram
The expression $(f\circ g)(x)=f(g(x))$ can be understood as a two-step process:
The input enters $g$ first. The output from $g$ then becomes the input for $f$.