Composition of Functions
Quick Reference
| Field | Value |
|---|---|
| Textbook | OpenStax Precalculus 2e |
| Chapter | Ch 1: Functions |
| Section | 1.4 Composition of Functions |
| Subsection | 1.4 Composition of Functions |
| Pages | Page numbers pending faculty verification. |
| Course | MATH141 |
For lecture, the load-bearing ideas are the order of operations in $f(g(x))$ (the inner function acts first), the two equally valid evaluation routes (evaluate-then-substitute versus build-the-formula), and the domain restriction that the inner output must land in the domain of the outer function.
Before You Start: Prerequisite Check
Can you do these? (Click to reveal self-test)
Test yourself on these prerequisite skills:
Function evaluation: If $g(x) = 2x + 1$, find $g(3)$.
Check
$g(3) = 2(3) + 1 = 7$
Substituting an expression: If $f(x) = x^2$, find $f(a + 1)$.
Check
$f(a + 1) = (a + 1)^2 = a^2 + 2a + 1$
Domain awareness: What input is not allowed for $h(x) = \dfrac{1}{x - 4}$?
Check
$x = 4$, because that makes the denominator zero.
If you struggled:
- Review Functions and Function Notation for evaluating and substituting.
- Review Domain and Range for which inputs are allowed.
Try This First
A vending machine takes a dollar coin and gives back a soda. A second machine takes that soda and gives back a bottle cap with a prize code. Put the two machines side by side and feed a coin into the first one. The prize code that comes out the far end is the result of running both machines in order.
Before any symbols, answer this with the picture in mind. Suppose the first machine doubles whatever number you put in, and the second machine adds 10 to whatever it receives. You put in the number 3.
- Predict: what number comes out the far end?
- Now check by tracing it. The first machine turns 3 into 6. The second machine receives 6 and turns it into 16.
Did your prediction match?
The far-end output is 16. Notice the order matters. If you had run “add 10” first and “double” second, you would have put in 3, gotten 13, then gotten 26. Two different results from the same two machines in a different order.
A Function Is a Process
A function is a process that takes an input and gives back an output. Composition is what happens when the output of one process becomes the input of the next process. The far-end machine never sees your original coin; it only ever sees what the first machine handed it.
This single idea, output-of-one-becomes-input-of-the-next, is what composition means. The symbols and the domain rules just record that idea precisely.
Prerequisite Hub
Builds on:
| Skill | Why it is needed |
|---|---|
Functions and Function Notation (m141-functions-and-function-notation) |
Composition reads $f(g(x))$ from the inside out, so substituting one expression into another must be automatic. |
Domain and Range (m141-domain-and-range) |
The domain of a composite depends on the domain of the inner function and whether its output is allowed into the outer function. |
Cross-course connection:
| Course | Connection |
|---|---|
CSCD 210 (function-composition) |
Nested method calls and method chaining in programming run inner calls first and feed the result outward, the same order as $f(g(x))$. |
Unlocks:
| Skill | What it leads to |
|---|---|
Inverse Functions (m141-inverse-functions) |
An inverse function is defined by composition: $f$ and its inverse compose to give back the original input. |
The Official Definition
Composite function:
When the output of one function is used as the input of another, the entire operation is a composition of functions. For any input $x$ and functions $f$ and $g$, this defines a composite function written as $(f \circ g)(x) = f(g(x))$.
Source: OpenStax Precalculus 2e, Section 1.4 Composition of Functions
Read $(f \circ g)(x)$ aloud as “$f$ composed with $g$ of $x$” or “$f$ of $g$ of $x$.” The symbol $\circ$ is the composition symbol, not multiplication. The function written closest to the input variable, here $g$, runs first.
Two Representations of the Same Idea
| Representation | $(f \circ g)(x) = f(g(x))$ |
|---|---|
| Worded process | Run $g$ on the input, then run $f$ on whatever $g$ produced. |
| Machine diagram | input $\to$ [ $g$ ] $\to$ $g(x)$ $\to$ [ $f$ ] $\to$ $f(g(x))$ |
| Algebraic rule | Replace every $x$ in the formula for $f$ with the entire expression $g(x)$. |
Translate between these on purpose. Given the worded process “square it, then add one,” write the machine diagram input $\to$ [ square ] $\to$ [ add one ], then the rule $f(g(x)) = x^2 + 1$ where $g(x) = x^2$ is the inner squaring step and $f(u) = u + 1$ is the outer add-one step.
The Domain of a Composite Function
Domain of a composite function:
The domain of a composite function $f(g(x))$ is the set of those inputs $x$ in the domain of $g$ for which $g(x)$ is in the domain of $f$.
Source: OpenStax Precalculus 2e, Section 1.4 Composition of Functions
Two gates must both be open for an input $x$ to be allowed:
- Gate one: $x$ must be allowed into the inner function $g$. If $g$ rejects $x$, nothing reaches $f$.
- Gate two: the value $g(x)$ that comes out must be allowed into the outer function $f$. An output that $f$ rejects breaks the composite even if $g$ accepted the input.
A common slip is to find the domain of the final simplified formula and stop there. That misses inputs blocked at gate one. The simplified formula may hide a restriction that the inner function imposed before any simplification.
Worked Examples
Example 1: Evaluate at a Number (Two Ways)
Let $f(x) = x^2 + 1$ and $g(x) = 3x - 2$. Find $(f \circ g)(4)$.
Predict first. The inner function $g$ turns 4 into a number near 10, and squaring that gives something around 100. Expect a result close to but above 100.
One way to see this: evaluate then substitute.
$$g(4) = 3(4) - 2 = 10$$ $$(f \circ g)(4) = f(g(4)) = f(10) = 10^2 + 1 = 101$$
Another way to see this: build the formula first, then plug in.
$$(f \circ g)(x) = f(g(x)) = (3x - 2)^2 + 1$$ $$(f \circ g)(4) = (3(4) - 2)^2 + 1 = (10)^2 + 1 = 101$$
Both routes give $101$, which matches the prediction of a value just above 100. The first route is faster for a single number. The second route is the one to use when a general formula is needed. Which do you prefer here, and why?
Example 2: Build the Composite Formula
Let $f(x) = \sqrt{x}$ and $g(x) = x + 5$. Find a formula for $(f \circ g)(x)$ and for $(g \circ f)(x)$.
Build $(f \circ g)(x) = f(g(x))$: replace the input of $f$ with the whole expression $g(x) = x + 5$.
$$(f \circ g)(x) = f(x + 5) = \sqrt{x + 5}$$
Build $(g \circ f)(x) = g(f(x))$: replace the input of $g$ with the whole expression $f(x) = \sqrt{x}$.
$$(g \circ f)(x) = g(\sqrt{x}) = \sqrt{x} + 5$$
These two results are different, $\sqrt{x + 5}$ versus $\sqrt{x} + 5$. Order changes the answer. Composition is not commutative.
Example 3: Domain of a Composite
Using $f(x) = \sqrt{x}$ and $g(x) = x + 5$ from Example 2, find the domain of $(f \circ g)(x) = \sqrt{x + 5}$.
Gate one (inner function $g$): $g(x) = x + 5$ is a polynomial, allowed for every real number. Gate one blocks nothing.
Gate two (output must enter outer function $f$): $f(u) = \sqrt{u}$ requires its input $u \geq 0$. Here $u = g(x) = x + 5$, so the requirement is
$$x + 5 \geq 0 \quad\Longrightarrow\quad x \geq -5.$$
Domain: $[-5, \infty)$. Confirm with the simplified formula $\sqrt{x + 5}$, which also requires $x + 5 \geq 0$. The two gates agree here because gate one was wide open.
Example 4: When the Hidden Restriction Bites
Let $f(x) = \dfrac{1}{x}$ and $g(x) = \dfrac{1}{x - 3}$. Find $(f \circ g)(x)$ and its domain.
Build the formula:
$$(f \circ g)(x) = f\!\left(\frac{1}{x - 3}\right) = \frac{1}{\frac{1}{x - 3}} = x - 3.$$
The simplified formula $x - 3$ looks allowed for every real number. That is a trap.
Gate one (inner function $g$): $g(x) = \dfrac{1}{x - 3}$ rejects $x = 3$, because that makes its denominator zero. So $x = 3$ is blocked before $f$ is ever reached.
Gate two (output into $f$): $f(u) = \dfrac{1}{u}$ rejects $u = 0$. But $g(x) = \dfrac{1}{x - 3}$ is never zero (a fraction with numerator 1 cannot equal zero), so gate two blocks nothing new.
Domain: all real numbers except $x = 3$, written $(-\infty, 3) \cup (3, \infty)$. The simplified formula $x - 3$ hid the restriction that the original inner function imposed. This is exactly why the domain is read from the gates, not from the final formula alone.
Common Misconceptions
composition is the same as chaining the formulas in reading order, left to right. The expression $(f \circ g)(x)$ runs $g$ first, even though $f$ is written first. Reading $f \circ g$ left to right and applying $f$ before $g$ produces the wrong order. Test it on $f(x) = x^2$ and $g(x) = x + 1$ at $x = 2$. The correct value is $f(g(2)) = f(3) = 9$. Applying $f$ first instead gives $g(f(2)) = g(4) = 5$. The two orders disagree, so the order cannot be ignored. Predict-then-check: before computing any composite, say out loud which function touches the input first, then verify by tracing one number through.
the inner output and the original input are interchangeable. In $f(g(x))$, the function $f$ never sees $x$. It only sees the number $g(x)$ that the inner function handed it. A student who writes $f(g(x))$ and then substitutes $x$ into $f$ has skipped the inner machine entirely. Predict-then-check: with $f(x) = x^2 + 1$ and $g(x) = 3x - 2$, predict whether $(f \circ g)(4)$ should use the number 4 or the number $g(4)$ as the input to $f$, then evaluate $g(4) = 10$ and confirm that $f$ squares 10, not 4.
Practice Problems
Let $f(x) = x + 7$ and $g(x) = 2x$. Find $(f \circ g)(5)$.
Let $f(x) = x^2$ and $g(x) = x - 4$. Find both $(f \circ g)(6)$ and $(g \circ f)(6)$, and state whether they are equal.
A student evaluates $(f \circ g)(2)$ where $f(x) = 3x$ and $g(x) = x + 5$, and writes $(f \circ g)(2) = g(f(2)) = g(6) = 11$.
Where is the error?
(A) No error. The work is correct.
(B) The student applied $f$ first, but $(f \circ g)$ requires applying $g$ first.
(C) The student should have multiplied $f$ and $g$ instead of composing them.
(D) The student used the wrong value of $f(2)$.
Let $f(x) = x^2 - 1$ and $g(x) = 4x + 3$. Write a simplified formula for $(f \circ g)(x)$.
Let $f(x) = \sqrt{x}$ and $g(x) = 2x - 6$. Find $(f \circ g)(x)$ and its domain.
Express $H(x) = \sqrt{5x + 2}$ as a composition $H = f \circ g$ of two simpler functions, where neither $f$ nor $g$ is the identity function. Then explain why more than one valid decomposition exists.
Mastery Checklist
Novice (Level 1-2):
Competent (Level 3-4):
Proficient (Level 5):
Mental Model
The two-machine assembly line.
Picture an assembly line with two machines bolted in sequence. A raw part enters the first machine (the inner function $g$), gets transformed, and the transformed part slides directly into the second machine (the outer function $f$). The second machine never touches the raw part; it only ever works on what the first machine produced. The far-end output is $f(g(x))$.
This picture explains both hard parts at once. Order matters because swapping the machines changes the line. The domain has two gates because a part must fit into the first machine and the result must fit into the second.
Connections
Looking back:
- Functions and Function Notation gives the substitution skill that composition runs on.
- Domain and Range gives the allowed-input reasoning that the two-gate domain rule extends.
Looking ahead:
- Inverse Functions are defined through composition: a function and its inverse compose to return the original input.
Cross-course connection:
- In CSCD 210, a nested method call such as
f(g(x))runs the inner call first and passes its result outward, the same inside-out order as function composition. Method chaining is composition written with a different syntax.
Resources
| Resource | Reference |
|---|---|
| OpenStax Precalculus 2e, Section 1.4 Composition of Functions (primary text for this node) | https://openstax.org/books/precalculus-2e/pages/1-4-composition-of-functions |
| OpenStax Precalculus 2e, Chapter 1 Key Concepts (review summary) | https://openstax.org/books/precalculus-2e/pages/1-key-concepts |
| Previous | Up | Next |
|---|---|---|
| Domain and Range | Skills Index | Inverse Functions |
Last updated: 2026-06-16