What Is Composition Of Functions?
Composition of Functions is the operation that chains two functions together so that the output of the first becomes the input of the second. If $f$ and $g$ are functions, their composite is written $f \circ g$ and defined by a single rule.
$$(f \circ g)(x) = f\big(g(x)\big)$$
Read $f \circ g$ as "$f$ composed with $g$," or "$f$ of $g$ of $x$." The small circle $\circ$ is not multiplication. It says: take $x$, apply the inner function $g$ to get $g(x)$, then apply the outer function $f$ to that result.
The order of the two steps is fixed. In $f\big(g(x)\big)$, the function written closest to $x$ acts first, so you always work from the inside out. That single habit, inside first, prevents most of the errors on this topic.
How Do You Find A Composite Function Like $f(g(x))$?
To find a composite, substitute the whole inner function into the outer function wherever its variable appears. You are not multiplying the two expressions; you are replacing the outer function's input with the inner function's output.
Example 1: Build both composites from $f(x) = x^2 + 1$ and $g(x) = x - 3$.
First find $f(g(x))$. The inner function is $g(x) = x - 3$, so replace every $x$ in $f$ with $(x-3)$:
$$f\big(g(x)\big) = (x - 3)^2 + 1 = x^2 - 6x + 9 + 1 = x^2 - 6x + 10$$
Now reverse the order and find $g(f(x))$. The inner function is now $f(x) = x^2 + 1$, so replace the $x$ in $g$ with $(x^2 + 1)$:
$$g\big(f(x)\big) = (x^2 + 1) - 3 = x^2 - 2$$
The two results are different functions: $x^2 - 6x + 10$ is not the same as $x^2 - 2$. That difference is the whole point of the next section.
Final answer: $f(g(x)) = x^2 - 6x + 10$ and $g(f(x)) = x^2 - 2$.
A quick check settles which is which. Evaluate both at $x = 5$: $f(g(5)) = 25 - 30 + 10 = 5$, while $g(f(5)) = 25 - 2 = 23$. Same two functions, same input, two different outputs, because the order of the steps was swapped.
Why Does Order Matter In Composition Of Functions?
Order matters because composition records a sequence of actions, and actions in sequence usually depend on their order. Putting on socks then shoes is not the same as shoes then socks. In symbols, $f \circ g \neq g \circ f$ in general.
Example 1 already showed it: $f(g(x)) = x^2 - 6x + 10$ but $g(f(x)) = x^2 - 2$. These agree only for special pairs of functions, never as a general rule.
Composition is not commutative. Swapping the inner and outer function usually changes the result, so $f \circ g$ and $g \circ f$ must be treated as separate problems.
Composition is associative. For three functions, $(f \circ g) \circ h = f \circ (g \circ h)$, so you may group the steps differently, as long as you keep them in the same left-to-right order.
The identity function does nothing. If $\text{id}(x) = x$, then $f \circ \text{id} = \text{id} \circ f = f$, the same role the number $1$ plays for multiplication.
One special pairing does commute in a meaningful way: a function and its inverse. If $g = f^{-1}$, then $f(g(x)) = x$ and $g(f(x)) = x$, each undoing the other. That is the defining test for inverse functions, and it is the one case where the two orders give the same clean result.
How Do You Find The Domain Of A Composite Function?
The domain of $f \circ g$ is every input $x$ that clears two gates: $x$ must be allowed by the inner function $g$, and the output $g(x)$ must be allowed by the outer function $f$. Miss either gate and the composite is undefined there.
Example 2: A square-root outer function.
Let $f(x) = \sqrt{x}$ and $g(x) = 5 - x$.
$$f\big(g(x)\big) = \sqrt{5 - x}$$
The inner function $g(x) = 5 - x$ accepts every real number. The outer function $\sqrt{\phantom{x}}$ needs its input to be non-negative, so it requires $g(x) \ge 0$, that is $5 - x \ge 0$, giving $x \le 5$. The domain of the composite is $x \le 5$.
Example 3: A division outer function.
Let $f(x) = \dfrac{1}{x}$ and $g(x) = x - 2$.
$$f\big(g(x)\big) = \frac{1}{x - 2}$$
The outer function forbids a zero denominator, so $g(x) \neq 0$, meaning $x - 2 \neq 0$, so $x \neq 2$. The domain is every real number except $2$.
The subtle case is when simplifying hides a restriction. Take $g(x) = \sqrt{x}$ and $f(x) = x^2$. The composite simplifies to $f(g(x)) = (\sqrt{x})^2 = x$, which looks defined everywhere.
It is not. The inner $\sqrt{x}$ still demands $x \ge 0$, so the composite's domain is $x \ge 0$, even though the simplified formula $x$ hides that. Always check the inner function's domain before you simplify. For the underlying idea of allowed inputs and outputs, see domain and range of a function.
How Do You Decompose A Function Into A Composition?
Decomposing is composition run backwards: you look at a complicated function and name an inner function $g$ and an outer function $f$ so that $f(g(x))$ rebuilds it. This is the skill the chain rule demands, so it is worth practising in its own right.
The trick is to ask, "what is the last thing I would do if I computed this by hand?" That last step is the outer function; everything inside it is the inner function.
Example 4: Decompose $\sqrt{3x^2 + 1}$.
Computing this by hand, the final step is the square root, and the thing under the root is $3x^2 + 1$. So take the inner and outer functions:
$$g(x) = 3x^2 + 1, \qquad f(u) = \sqrt{u}$$
Then $f\big(g(x)\big) = \sqrt{3x^2 + 1}$, which is the original. The letter $u$ is just a placeholder for whatever the inner function hands over.
Decompositions are not unique; you could push more or less work into each piece. But the natural split, outer operation versus everything inside it, is the one that makes the chain rule fall out cleanly in the next section.
Table: A repeatable procedure for the four composition tasks.
Task | What to do | Example result |
|---|---|---|
Find $f(g(x))$ | Substitute $g(x)$ into $f$ wherever its variable sits | $f(x)=x^2+1,\ g(x)=x-3 \Rightarrow x^2-6x+10$ |
Find $g(f(x))$ | Substitute $f(x)$ into $g$ (usually a different answer) | Same $f,g \Rightarrow x^2-2$ |
Domain of $f \circ g$ | Keep $x$ in domain of $g$ AND $g(x)$ in domain of $f$ | $\sqrt{5-x} \Rightarrow x \le 5$ |
Decompose | Outer $=$ last operation; inner $=$ everything inside it | $\sqrt{3x^2+1} \Rightarrow f(u)=\sqrt{u},\ g(x)=3x^2+1$ |
Why Does Composition Of Functions Matter In Calculus?
Composition is the reason the chain rule exists. Once a function is written as $f(g(x))$, its derivative follows one rule: differentiate the outer function at the inner value, then multiply by the derivative of the inner function.
$$\frac{d}{dx} f\big(g(x)\big) = f'\big(g(x)\big) \cdot g'(x)$$
Example 5: Differentiate $\sqrt{3x^2 + 1}$ using the decomposition.
From Example 4, the outer function is $f(u) = \sqrt{u}$ with $f'(u) = \dfrac{1}{2\sqrt{u}}$, and the inner function is $g(x) = 3x^2 + 1$ with $g'(x) = 6x$. Apply the rule:
$$\frac{d}{dx}\sqrt{3x^2 + 1} = \frac{1}{2\sqrt{3x^2 + 1}} \cdot 6x = \frac{3x}{\sqrt{3x^2 + 1}}$$
Every chain-rule problem is really a composition problem in disguise, which is why spotting the inner and outer function first is the habit that makes differentiation of the derivative of a function built from other functions manageable.
Composition also carries a geometric guarantee. If $g$ is continuous at $x = a$ and $f$ is continuous at $g(a)$, then the composite $f \circ g$ is continuous at $a$: an unbroken inner curve fed into an unbroken outer curve produces an unbroken result. That fact underpins much of the continuity of a function toolkit, because it lets you certify that a complicated built-up function has no jumps without graphing it.
Why Does Composition Of Functions Work?
Composition works because a function is a rule that turns an input into an output, and any output can serve as the next input as long as it is a legal one. Nothing more is needed than matching the exit of one machine to the entrance of the next.
Outputs become inputs. The only requirement is that $g(x)$ lands inside the domain of $f$. When it does, $f(g(x))$ is a perfectly ordinary value, and the whole chain behaves like one new function.
The pipeline is itself a function. Feeding one input through both steps gives exactly one output, so $f \circ g$ satisfies the definition of a function and can be composed, inverted, or graphed like any other.
Order is baked into the meaning. Because each step transforms what the previous step produced, reversing the steps asks a different question. This is why $f \circ g \neq g \circ f$ is the expected behaviour, not a defect.
Seen this way, composition is just the mathematics of "do this, then do that." Most real processes are sequences of smaller steps, so a language for chaining steps is exactly what modelling them requires.
Who Shaped The Idea Of Composition Of Functions?
The idea of feeding one quantity's output into another is old, but treating a function as an object you can combine, and giving that combination a symbol, is surprisingly recent.
Two named figures anchor the shift:
Gottfried Wilhelm Leibniz (1646–1716, Germany) coined the term "function" and, with his calculus, made rates of change of dependent quantities central.
Leonhard Euler (1707–1783, Switzerland) gave the $f(x)$ notation its modern form and treated functions as objects, the conceptual step that makes composition natural to write down.
Where Is Composition Of Functions Used In The Real World?
Composition shows up wherever a result is produced by running several steps in a fixed order.
Unit conversion chains: converting a price per gallon into a cost per kilometre driven is one function (fuel used per kilometre) fed into another (cost per unit of fuel), a composite of two rates.
Computer graphics: a point on a 3D model is scaled, then rotated, then moved, and the on-screen position is the composition of those transformations applied in a strict order.
Programming and data pipelines: software is built by piping the output of one function into the next, so $f(g(x))$ is the everyday shape of a data-processing stage.
Finance and pricing: a final price is often a base cost passed through a markup function, then through a tax function, a composite whose order changes the total.
Science formulas: the loudness a listener perceives depends on intensity, which depends on distance, so perceived loudness is a composition of the two relationships.
One idea, chaining steps in order, describes filters on a photo, stages in a program, and conversions between units. Composition is the grammar of multi-step processes.
What Are The Most Common Mistakes With Composition Of Functions?
These three errors account for most lost marks on composition, and each matches a confusion real students raise on exam-doubt forums and beginner pages.
Multiplying the two functions instead of substituting.
Where it slips in:
A student reads $f \circ g$ as $f \times g$ and writes $(x^2 + 1)(x - 3)$ for $f(g(x))$.
Don't do this:
Do not treat the circle $\circ$ as a multiplication dot. Composition is substitution, not a product.
The correct way:
Replace the outer function's variable with the whole inner function: $f(g(x)) = (x - 3)^2 + 1 = x^2 - 6x + 10$.
Applying the functions in the wrong order.
Where it slips in:
Seeing $f$ written on the left in $f \circ g$, a student applies $f$ first and computes $g(f(x))$ by mistake.
Don't do this:
Do not read left to right as the order of operations. The inner function, written closest to $x$, always runs first.
The correct way:
Work inside out. For $f \circ g$, compute $g(x)$ first, then feed it into $f$: $f(g(x))$, which for our functions is $x^2 - 6x + 10$, not $x^2 - 2$.
Ignoring the domain of the composite.
Where it slips in:
A student simplifies $(\sqrt{x})^2$ to $x$, then claims the composite is defined for every real number.
Don't do this:
Do not read the domain off the simplified formula. Simplifying can hide a restriction the inner function still imposes.
The correct way:
Check the inner function first. Since $\sqrt{x}$ needs $x \ge 0$, the composite $(\sqrt{x})^2 = x$ is valid only for $x \ge 0$, not for negative inputs.
Practice Problems On Composition Of Functions
Use $f(x) = 2x + 1$ and $g(x) = x^2$ unless a problem says otherwise. Answers are verified.
Find $f(g(x))$.
(Answer: $f(x^2) = 2x^2 + 1$.)Find $g(f(x))$.
(Answer: $g(2x+1) = (2x+1)^2 = 4x^2 + 4x + 1$.)Evaluate $(f \circ g)(3)$.
(Answer: $g(3) = 9$, then $f(9) = 19$.)With $f(x) = \sqrt{x}$ and $g(x) = x - 7$, find the domain of $f(g(x)) = \sqrt{x - 7}$.
(Answer: $x \ge 7$.)Decompose $h(x) = (4x - 5)^3$ as a composition.
(Answer: $g(x) = 4x - 5$, $f(u) = u^3$.)Differentiate $h(x) = (4x - 5)^3$ using the chain rule.
(Answer: $3(4x - 5)^2 \cdot 4 = 12(4x - 5)^2$.)
Where Should You Go Next After Composition Of Functions?
Composition is a hinge between algebra and calculus, and several natural doors open from here.
Chain rule. The direct payoff: differentiate any composite by pairing the outer derivative at the inner value with the inner derivative.
Inverse functions. The special composition where $f(g(x)) = x$ and $g(f(x)) = x$, so each function undoes the other.
Transformations of functions. Shifts, stretches, and reflections are all compositions with simple linear functions, seen on a graph.
Function notation. Firm up the $f(x)$ language that composition is written in before pushing further into calculus.
If your child is meeting Composition of Functions for the first time, a live Bhanzu trainer teaches it from the two-machine picture through to the chain rule in the Bhanzu math program.
Was this article helpful?
Your feedback helps us write better content
