← MATH 141 MathScape 0 MATH141

Composition of Functions

11 min read

Jump to a section

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:

  1. Function evaluation: If $g(x) = 2x + 1$, find $g(3)$.

    Check

    $g(3) = 2(3) + 1 = 7$

  2. Substituting an expression: If $f(x) = x^2$, find $f(a + 1)$.

    Check

    $f(a + 1) = (a + 1)^2 = a^2 + 2a + 1$

  3. 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:


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.

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:

  1. Gate one: $x$ must be allowed into the inner function $g$. If $g$ rejects $x$, nothing reaches $f$.
  2. 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

Common misconception

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.

Common misconception

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

Level 1 Evaluate a Composite at a Number

Let $f(x) = x + 7$ and $g(x) = 2x$. Find $(f \circ g)(5)$.

Thought Process

Run the inner function $g$ first on the input 5, then run $f$ on the result.

Show Answer

$$g(5) = 2(5) = 10$$ $$(f \circ g)(5) = f(10) = 10 + 7 = 17$$

Answer: $17$.

Level 2 Order Matters

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.

Thought Process

For $(f \circ g)(6)$, run $g$ then $f$. For $(g \circ f)(6)$, run $f$ then $g$. Compare.

Show Answer

$$(f \circ g)(6) = f(g(6)) = f(6 - 4) = f(2) = 2^2 = 4$$ $$(g \circ f)(6) = g(f(6)) = g(6^2) = g(36) = 36 - 4 = 32$$

The results $4$ and $32$ are not equal. Order changes the answer, so composition is not commutative.

Level 3 Diagnostic: Which Function Runs First

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

Thought Process

In $(f \circ g)(x) = f(g(x))$, the inner function $g$ touches the input first. The student wrote $g(f(2))$, which is the opposite order.

Show Answer

Answer: (B). The notation $(f \circ g)(2)$ means $f(g(2))$, so $g$ runs first.

The correct work is $$g(2) = 2 + 5 = 7, \qquad (f \circ g)(2) = f(7) = 3(7) = 21.$$

  • (A) Incorrect: the order is reversed.
  • (B) Correct: $g$ must run before $f$.
  • (C) Incorrect: $\circ$ is composition, not multiplication.
  • (D) Incorrect: $f(2)$ was not even the value needed; the student should have computed $g(2)$ first.
Level 3 Build the Composite Formula

Let $f(x) = x^2 - 1$ and $g(x) = 4x + 3$. Write a simplified formula for $(f \circ g)(x)$.

Thought Process

Replace every $x$ in the formula for $f$ with the entire expression $g(x) = 4x + 3$, then expand.

Show Answer

$$(f \circ g)(x) = f(4x + 3) = (4x + 3)^2 - 1$$ $$= 16x^2 + 24x + 9 - 1 = 16x^2 + 24x + 8$$

Answer: $(f \circ g)(x) = 16x^2 + 24x + 8$.

Level 4 Domain of a Composite

Let $f(x) = \sqrt{x}$ and $g(x) = 2x - 6$. Find $(f \circ g)(x)$ and its domain.

Thought Process

Gate one: which inputs does $g$ allow? Gate two: which outputs $g(x)$ does $f$ allow? The square root needs a nonnegative input.

Show Answer

Formula: $(f \circ g)(x) = f(2x - 6) = \sqrt{2x - 6}$.

Gate one: $g(x) = 2x - 6$ is a polynomial, allowed for all real $x$. Nothing blocked.

Gate two: $f(u) = \sqrt{u}$ requires $u \geq 0$, so $2x - 6 \geq 0$, which gives $x \geq 3$.

Domain: $[3, \infty)$.

Level 5 Decompose a Function

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.

Thought Process

Look for the last operation performed on the input. To compute $H(x)$, you first form $5x + 2$, then take a square root. The inner step is a candidate for $g$ and the outer step for $f$.

Show Answer

One natural decomposition. Let the inner function be the part under the root and the outer function be the square root:

$$g(x) = 5x + 2, \qquad f(u) = \sqrt{u}.$$

Check: $f(g(x)) = \sqrt{5x + 2} = H(x)$.

Another valid decomposition. Split the inside differently:

$$g(x) = 5x, \qquad f(u) = \sqrt{u + 2}.$$

Check: $f(g(x)) = \sqrt{5x + 2} = H(x)$.

Why more than one exists: decomposition asks where to cut the chain of operations into an inner part and an outer part. Any cut that, when the pieces are recomposed, rebuilds the original chain is valid. The first cut groups all the linear work inside; the second leaves the “$+2$” with the outer function. Which cut a person prefers often depends on what makes the next step (such as finding a derivative later) cleaner. Which do you prefer, and why?

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:

Looking ahead:

Cross-course connection:


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


Last updated: 2026-06-16