Composition of functions
Theory
A composite function feeds the output of one function into another: \((f\circ g)(x)=f\big(g(x)\big)\) applies the inner function \(g\) first, then the outer function \(f\). The order matters — \(f\circ g\) is generally not \(g\circ f\) — and the composite is only defined where the range of the inner sits inside the domain of the outer, \(\operatorname{ran}g\subseteq\operatorname{dom}f\).
A composite function is built by using the output of one function as the input of another. Given two functions \(f\) and \(g\), the composite “\(f\) of \(g\)” is written \(f\circ g\) and defined by \((f\circ g)(x)=f\big(g(x)\big)\): you apply the inner function \(g\) to \(x\) first, then apply the outer function \(f\) to that result. Reading \(f(g(x))\) from the inside out mirrors exactly how it is calculated.
The order matters. In general \(f\circ g\neq g\circ f\), because swapping which function is applied first changes the rule. For example, with \(f(x)=x^{2}\) and \(g(x)=x+1\), \(f(g(x))=(x+1)^{2}\) but \(g(f(x))=x^{2}+1\) — two different functions. So you must always be clear about which function is inner and which is outer.
For the composite to make sense, every output of \(g\) must be an allowable input of \(f\). This is the existence condition \(\operatorname{ran}g\subseteq\operatorname{dom}f\). The domain of \(f\circ g\) is then \(\{x\in\operatorname{dom}g : g(x)\in\operatorname{dom}f\}\) — start with the domain of the inner function and keep only the \(x\)-values whose image \(g(x)\) is a legal input of the outer function. If the condition fails, you restrict the domain of \(g\) until its range fits inside \(\operatorname{dom}f\).
The composite — apply the inner function first, then the outer:
The existence condition — every output of the inner must be a legal input of the outer:
The domain of the composite — the inputs of \(g\) whose images land in \(\operatorname{dom}f\):
How to work with a composite function
- Identify inner and outer. In \(f(g(x))\) the inner function is \(g\) (applied first) and the outer is \(f\). Being clear about the order prevents mixing up \(f\circ g\) and \(g\circ f\).
- Evaluate at a value inside-out. For \(f(g(a))\), first compute \(g(a)\), then substitute that number into \(f\).
- Form the rule. Substitute the whole expression \(g(x)\) into \(f\) wherever the variable appears, then expand and simplify.
- Find the domain. Take \(\operatorname{dom}g\) and keep only the \(x\) for which \(g(x)\in\operatorname{dom}f\); this is \(\operatorname{dom}(f\circ g)\).
- Check existence. The composite is defined when \(\operatorname{ran}g\subseteq\operatorname{dom}f\); if not, restrict \(\operatorname{dom}g\) so its range fits inside \(\operatorname{dom}f\).
| \(g(3)\) | \(=\) | \(3^{2}=9\) |
| \(f(g(3))=f(9)\) | \(=\) | \(2(9)+1=19\) |
| \(f(3)\) | \(=\) | \(2(3)+1=7\) |
| \(g(f(3))=g(7)\) | \(=\) | \(7^{2}=49\) |
| \(f(g(x))\) | \(=\) | \((x-3)^{2}+1\) |
| \(=\) | \(x^{2}-6x+9+1\) | |
| \(=\) | \(x^{2}-6x+10\) |
| \(g(f(x))\) | \(=\) | \((x^{2}+1)-3\) |
| \(=\) | \(x^{2}-2\) |
| \(f(g(x))\) | \(=\) | \(\sqrt{x-2}\) |
| \(g(x)\ge 0\) | \(\Rightarrow\) | \(x-2\ge 0\) |
| \(\Rightarrow\) | \(x\ge 2\) |
| \(\operatorname{ran}g\) | \(=\) | \((-\infty,4]\) |
| \(\operatorname{dom}f\) | \(=\) | \([0,\infty)\) |
| \(4-x^{2}\ge 0\) | \(\Rightarrow\) | \(x^{2}\le 4\) |
| \(\Rightarrow\) | \(-2\le x\le 2\) |
| \(f(g(x))\) | \(=\) | \(\sqrt{4-x^{2}}\) |
Common pitfalls
Frequently asked questions
What is a composite function?
A composite function applies one function to the output of another. Written \(f\circ g\), it means: first apply the inner function \(g\) to \(x\), then apply the outer function \(f\) to the result, so \((f\circ g)(x)=f(g(x))\).
How do you evaluate a composite function at a value?
Work from the inside out. For \(f(g(3))\), first find \(g(3)\), then substitute that into \(f\). With \(g(x)=x^{2}\), \(f(x)=2x+1\): \(g(3)=9\) and \(f(9)=19\), so \(f(g(3))=19\).
Is f of g the same as g of f?
No — in general order matters and \(f\circ g\neq g\circ f\). For \(f(x)=x^{2}\), \(g(x)=x+1\): \(f(g(x))=(x+1)^{2}\) while \(g(f(x))=x^{2}+1\), which are different functions.
How do you find the domain of a composite function?
The domain of \(f\circ g\) is the \(x\) in \(\operatorname{dom}g\) whose output \(g(x)\) also lies in \(\operatorname{dom}f\). Start from the inner domain and remove any \(x\) for which \(g(x)\) is not a valid input of \(f\); e.g. \(\sqrt{x-2}\) has domain \(x\ge 2\).
When does a composite function exist?
The composite \(f\circ g\) exists when the range of the inner function fits inside the domain of the outer: \(\operatorname{ran}g\subseteq\operatorname{dom}f\). If this fails, restrict \(\operatorname{dom}g\) so all its outputs become valid inputs of \(f\).
How do you form the rule for f(g(x))?
Substitute the whole inner function \(g(x)\) into \(f\) wherever the variable appears, then simplify. For \(f(x)=x^{2}+1\), \(g(x)=x-3\): \(f(g(x))=(x-3)^{2}+1=x^{2}-6x+10\).