Resources For Teachers For Tutors For Students & Parents Pricing
Year 12 Maths - Methods (Unit 3 & Unit 4) Algebra and equations

Composition of functions

20 practice questions 0 video lessons Theory + worked examples
Create a free accountTrack your progress and save your work as you go.
Create free account

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\).

Key idea. \((f\circ g)(x)=f\big(g(x)\big)\): evaluate the inner function first. The composite exists exactly when \(\operatorname{ran}g\subseteq\operatorname{dom}f\), and generally \(f\circ g\neq g\circ f\).
Mapping chain for the composite f(g(x))An input x flows through the inner function g to give g(x), then through the outer function f to give f(g(x)). Below, the number 3 maps to 9 under g(x)=x squared, then to 19 under f(x)=2x+1. x g g(x) f f(g(x)) 3 ( )² 9 2( )+1 19
The chain \(x\xrightarrow{\,g\,}g(x)\xrightarrow{\,f\,}f(g(x))\); with \(g(x)=x^{2}\), \(f(x)=2x+1\), input \(3\mapsto 9\mapsto 19\)
Composites f of g and g of f differTwo parabolas on the same axes: f(g(x)) equals (x+1) squared with vertex at (-1,0), and g(f(x)) equals x squared plus 1 with vertex at (0,1). The curves are different, showing composition order matters. x y f(g(x)) g(f(x))
With \(f(x)=x^{2}\), \(g(x)=x+1\): \(f(g(x))=(x+1)^{2}\) and \(g(f(x))=x^{2}+1\) are different — order matters

The composite — apply the inner function first, then the outer:

\[(f\circ g)(x)=f\big(g(x)\big) \qquad (g\circ f)(x)=g\big(f(x)\big)\]
(fg)(x)=f(g(x))

The existence condition — every output of the inner must be a legal input of the outer:

\[\operatorname{ran}g\subseteq\operatorname{dom}f\]
rangdomf

The domain of the composite — the inputs of \(g\) whose images land in \(\operatorname{dom}f\):

\[\operatorname{dom}(f\circ g)=\{\,x\in\operatorname{dom}g : g(x)\in\operatorname{dom}f\,\}\]
dom(fg)={xdomg:g(x)domf}
Order matters. \(f\circ g\) and \(g\circ f\) are usually different functions, so check which one is being asked. The composite \(f\circ g\) reads right-to-left: \(g\) acts first.

How to work with a composite function

  1. 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\).
  2. Evaluate at a value inside-out. For \(f(g(a))\), first compute \(g(a)\), then substitute that number into \(f\).
  3. Form the rule. Substitute the whole expression \(g(x)\) into \(f\) wherever the variable appears, then expand and simplify.
  4. 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)\).
  5. 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\).
Domain shortcut. Do not read the domain off the simplified rule — it is inherited from the inner function. For \(g(x)=\sqrt{x}\), \(f(x)=x^{2}\), the rule \(f(g(x))=x\) still has domain \(x\ge 0\), because \(g\) is only defined there.
Example 1 — evaluate a composite
Given \(f(x)=2x+1\) and \(g(x)=x^{2}\), find \(f(g(3))\) and \(g(f(3))\).
Solution
\(f(g(3))\)
Work inside-out — evaluate the inner function first:
\(g(3)\)\(=\)\(3^{2}=9\)
\(f(g(3))=f(9)\)\(=\)\(2(9)+1=19\)
\(\therefore\) \(f(g(3))=19\)
\(g(f(3))\)
Swap the order — now \(f\) is applied first:
\(f(3)\)\(=\)\(2(3)+1=7\)
\(g(f(3))=g(7)\)\(=\)\(7^{2}=49\)
\(\therefore\) \(g(f(3))=49\) — order matters
f(g(3))=19
Example 2 — form and simplify a rule
Given \(f(x)=x^{2}+1\) and \(g(x)=x-3\), find rules for \(f(g(x))\) and \(g(f(x))\).
Solution
\(f(g(x))\)
Substitute \(g(x)=x-3\) into \(f\), then expand:
\(f(g(x))\)\(=\)\((x-3)^{2}+1\)
\(=\)\(x^{2}-6x+9+1\)
\(=\)\(x^{2}-6x+10\)
\(\therefore\) \(f(g(x))=x^{2}-6x+10\)
\(g(f(x))\)
Substitute \(f(x)=x^{2}+1\) into \(g\):
\(g(f(x))\)\(=\)\((x^{2}+1)-3\)
\(=\)\(x^{2}-2\)
\(\therefore\) \(g(f(x))=x^{2}-2\), so \(f\circ g\neq g\circ f\)
f(g(x))=x2-6x+10
Example 3 — domain of a composite
Let \(f(x)=\sqrt{x}\) (with \(\operatorname{dom}f=[0,\infty)\)) and \(g(x)=x-2\). Find \(f(g(x))\) and its domain.
Solution
Form the rule — substitute \(g(x)=x-2\) into \(f\):
\(f(g(x))\)\(=\)\(\sqrt{x-2}\)
Domain — the inner output must lie in \(\operatorname{dom}f=[0,\infty)\):
\(g(x)\ge 0\)\(\Rightarrow\)\(x-2\ge 0\)
\(\Rightarrow\)\(x\ge 2\)
\(\therefore\) \(f(g(x))=\sqrt{x-2}\), domain \([2,\infty)\)
Graph of the composite sqrt(x-2)The curve y equals square root of (x minus 2), starting at the point (2,0) and increasing slowly to the right. It is defined only for x greater than or equal to 2. x y y=sqrt(x-2) (2,0)
f(g(x))=x-2,x2
Example 4 — existence condition
Let \(f(x)=\sqrt{x}\), \(\operatorname{dom}f=[0,\infty)\), and \(g(x)=4-x^{2}\) with \(\operatorname{dom}g=\mathbb{R}\). Does \(f\circ g\) exist? If not, restrict \(g\) so it does, and state the composite.
Solution
Test the condition \(\operatorname{ran}g\subseteq\operatorname{dom}f\):
\(\operatorname{ran}g\)\(=\)\((-\infty,4]\)
\(\operatorname{dom}f\)\(=\)\([0,\infty)\)
Since \((-\infty,4]\not\subseteq[0,\infty)\) (negative outputs are not valid), \(f\circ g\) does not exist on all of \(\mathbb{R}\).
Restrict \(\operatorname{dom}g\) so the outputs stay \(\ge 0\):
\(4-x^{2}\ge 0\)\(\Rightarrow\)\(x^{2}\le 4\)
\(\Rightarrow\)\(-2\le x\le 2\)
On \([-2,2]\), \(\operatorname{ran}g=[0,4]\subseteq[0,\infty)\), so the composite now exists:
\(f(g(x))\)\(=\)\(\sqrt{4-x^{2}}\)
\(\therefore\) restrict to \(x\in[-2,2]\); then \(f(g(x))=\sqrt{4-x^{2}}\)
f(g(x))=4-x2,-2x2

Common pitfalls

Order matters — \(f\circ g\neq g\circ f\). \(f(g(x))\) applies \(g\) first, \(g(f(x))\) applies \(f\) first. With \(f(x)=x^{2}\), \(g(x)=x+1\), \(f(g(x))=(x+1)^{2}\) but \(g(f(x))=x^{2}+1\).
Substitute the whole inner expression. To form \(f(g(x))\), replace every \(x\) in \(f\) by \(g(x)\), not the other way round. For \(f(x)=x^{2}+1\), \(g(x)=x-3\), it is \((x-3)^{2}+1\), never \(x^{2}+1-3\) unless you are asked for \(g(f(x))\).
The domain is inherited from the inner function. Do not read it off the simplified rule. For \(g(x)=\sqrt{x}\), \(f(x)=x^{2}\), \(f(g(x))=x\) still has domain \(x\ge 0\), because \(g\) is only defined there.

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\).