← MathScape

Function Composition

MATH161
Reference: Stewart 1.3  •  Chapter: 1  •  Section: 3

Navigation: Wiki Home > Skills > Function Composition

Function Composition

Functions Inside Functions

What happens when the output of one function becomes the input of another? If a car travels at 60 mph and fuel efficiency drops with speed, how do you find fuel consumption as a function of time? You need to chain these relationships together—that's composition.

Composition is everywhere: temperature depends on altitude, altitude depends on location, so temperature depends on location. Understanding composition is essential because the chain rule—one of the most important differentiation techniques—is entirely about derivatives of composed functions.

The notation $(f \circ g)(x)$ means "apply $g$ first, then apply $f$ to the result." Think of it as a pipeline where data flows through $g$, then through $f$.

Prerequisite Map

This skill
Function Composition

Quick Reference

Property Value
Course MATH 161
Chapter 1.3
Difficulty Intermediate
Time ~20 minutes

Key Concepts

The Definition

If $f$ and $g$ are functions, the composition of $f$ and $g$ is:

$$(f \circ g)(x) = f(g(x))$$

Read as: "$f$ composed with $g$" or "$f$ of $g$ of $x$"

The pipeline:

    x  →  [ g ]  →  g(x)  →  [ f ]  →  f(g(x))
         (inner)           (outer)

Order Matters!

$$f \circ g \neq g \circ f \text{ in general}$$

Example: Let $f(x) = x^2$ and $g(x) = x + 1$.

These are different functions! $(f \circ g)(2) = 9$ but $(g \circ f)(2) = 5$.

Finding the Domain

The domain of $f \circ g$ requires TWO conditions:

  1. $x$ must be in the domain of $g$ (so $g(x)$ exists)
  2. $g(x)$ must be in the domain of $f$ (so $f(g(x))$ exists)

Formula: $$\text{dom}(f \circ g) = \{x \in \text{dom}(g) : g(x) \in \text{dom}(f)\}$$

Example: If $f(x) = \sqrt{x}$ and $g(x) = 1 - x^2$, find the domain of $f \circ g$.

Domain: $[-1, 1]$

Decomposing Composite Functions

Given a complicated function, identify the "inner" and "outer" parts:

Composite Outer $f$ Inner $g$
$\sqrt{x^2 + 1}$ $\sqrt{u}$ $x^2 + 1$
$(3x - 5)^7$ $u^7$ $3x - 5$
$\sin(x^2)$ $\sin u$ $x^2$
$\sin^2 x$ $u^2$ $\sin x$

Strategy: Ask "What's the last operation performed?" That's the outer function.

Visualizing Composition

COMPOSITION: (f ∘ g)(x) = f(g(x))

    INPUT                  OUTPUT
      │                      │
      ▼                      │
    ┌───┐                    │
    │ g │  ← INNER          │
    └─┬─┘   (applied first) │
      │                      │
      ▼                      │
    ┌───┐                    │
    │ f │  ← OUTER          │
    └─┬─┘   (applied second)│
      │                      │
      ▼                      │
    RESULT ◄─────────────────┘

Multiple Compositions

You can compose more than two functions:

$$(f \circ g \circ h)(x) = f(g(h(x)))$$

Apply from right to left: first $h$, then $g$, then $f$.

Example: If $h(x) = x + 1$, $g(x) = x^2$, $f(x) = 3x$, then: $$(f \circ g \circ h)(x) = 3(x+1)^2$$

Connection to Transformations

Composition explains why horizontal transformations work "backwards":

$$y = f(x - 3) = (f \circ g)(x) \text{ where } g(x) = x - 3$$

To get $f(0)$, you need to input $x = 3$ into $g$. That's why "$-3$ inside" means "shift right."

Practice Problems

Level 1 Direct Evaluation

If $f(x) = x^2$ and $g(x) = x + 3$, find $(f \circ g)(2)$.

Thought Process

Work inside-out: first compute $g(2)$, then plug that result into $f$.

Show Answer

$(f \circ g)(2) = f(g(2))$

First: $g(2) = 2 + 3 = 5$

Then: $f(5) = 5^2 = 25$

$(f \circ g)(2) = \boxed{25}$

Level 2 Finding a Composition Formula

Let $f(x) = \frac{1}{x}$ and $g(x) = x^2 - 4$. Find formulas for:

  1. $(f \circ g)(x)$
  2. $(g \circ f)(x)$
Thought Process

For $(f \circ g)$: replace every $x$ in $f(x)$ with $g(x)$. For $(g \circ f)$: replace every $x$ in $g(x)$ with $f(x)$.

These will be different—composition is not commutative.

Show Answer

(a) $(f \circ g)(x) = f(g(x)) = f(x^2 - 4) = \frac{1}{x^2 - 4}$

$$\boxed{(f \circ g)(x) = \frac{1}{x^2 - 4}}$$

(b) $(g \circ f)(x) = g(f(x)) = g\left(\frac{1}{x}\right) = \left(\frac{1}{x}\right)^2 - 4 = \frac{1}{x^2} - 4$

$$\boxed{(g \circ f)(x) = \frac{1}{x^2} - 4}$$

Note: These are completely different functions!

Level 3 Domain of a Composition

Let $f(x) = \sqrt{x}$ and $g(x) = 4 - x^2$. Find the domain of $(f \circ g)(x)$.

Thought Process

Two conditions:

  1. $x$ must be in domain of $g$ (all reals—polynomial)
  2. $g(x)$ must be in domain of $f$ (need $g(x) \geq 0$)

The second condition gives: $4 - x^2 \geq 0$.

Show Answer

Step 1: $(f \circ g)(x) = f(g(x)) = \sqrt{4 - x^2}$

Step 2: Domain of $g(x) = 4 - x^2$ is all real numbers.

Step 3: For $(f \circ g)$ to be defined, we need $g(x) \geq 0$: $$4 - x^2 \geq 0$$ $$4 \geq x^2$$ $$-2 \leq x \leq 2$$

Domain: $\boxed{[-2, 2]}$

Level 4 Decomposing a Composite Function

Express $H(x) = \sqrt[3]{\frac{x}{x+1}}$ as a composition $H = f \circ g$ where neither $f$ nor $g$ is the identity function.

Then find two different valid decompositions.

Thought Process

Ask: "What's the last operation?" The cube root is applied last, so that could be the outer function.

Alternative: The fraction could be the outer function with a different inner choice.

There are multiple valid answers—the decomposition isn't unique.

Show Answer

Decomposition 1:

Let $g(x) = \frac{x}{x+1}$ and $f(u) = \sqrt[3]{u} = u^{1/3}$

Then $(f \circ g)(x) = \sqrt[3]{\frac{x}{x+1}} = H(x)$ ✓

Decomposition 2:

Let $g(x) = \frac{1}{x+1}$ and $f(u) = \sqrt[3]{xu}$...

Actually, this doesn't work because $f$ would depend on $x$.

Valid alternative:

Let $g(x) = x + 1$ and $f(u) = \sqrt[3]{\frac{u-1}{u}}$

Then $(f \circ g)(x) = \sqrt[3]{\frac{(x+1)-1}{x+1}} = \sqrt[3]{\frac{x}{x+1}} = H(x)$ ✓

Most natural decomposition: $f(u) = u^{1/3}$, $g(x) = \frac{x}{x+1}$

Level 5 Self-Composition and Fixed Points

Let $f(x) = \frac{1}{1-x}$.

  1. Find $(f \circ f)(x)$.
  2. Find $(f \circ f \circ f)(x)$.
  3. What pattern do you notice? Prove your observation.
  4. A fixed point of $f$ is a value $x$ where $f(x) = x$. Find all fixed points of $f$.
Thought Process

For (a) and (b), carefully substitute and simplify the fractions.

For (c), look at the sequence $f, f \circ f, f \circ f \circ f, \ldots$

For (d), solve $\frac{1}{1-x} = x$.

Show Answer

(a) $(f \circ f)(x) = f(f(x)) = f\left(\frac{1}{1-x}\right)$

$$= \frac{1}{1 - \frac{1}{1-x}} = \frac{1}{\frac{1-x-1}{1-x}} = \frac{1}{\frac{-x}{1-x}} = \frac{1-x}{-x} = \boxed{\frac{x-1}{x}}$$

(b) $(f \circ f \circ f)(x) = f\left(\frac{x-1}{x}\right)$

$$= \frac{1}{1 - \frac{x-1}{x}} = \frac{1}{\frac{x - (x-1)}{x}} = \frac{1}{\frac{1}{x}} = \boxed{x}$$

(c) Pattern: Composing $f$ with itself three times returns the identity!

$$f \circ f \circ f = \text{identity}$$

This means $f$ has "order 3": applying it three times undoes everything. We say $f$ is a periodic function under composition with period 3.

(d) Fixed points: Solve $f(x) = x$:

$$\frac{1}{1-x} = x$$ $$1 = x(1-x)$$ $$1 = x - x^2$$ $$x^2 - x + 1 = 0$$

Discriminant: $1 - 4 = -3 < 0$

No real fixed points. The fixed points are complex: $x = \frac{1 \pm i\sqrt{3}}{2}$

Mastery Checklist

Mental Model

The Factory Pipeline: Think of composition as a factory with multiple stations. Raw material (input $x$) enters the first machine ($g$), which produces an intermediate product ($g(x)$). This intermediate product then enters the second machine ($f$), which produces the final output ($f(g(x))$).

The order matters: if you switch which machine comes first, you get a different product. And the pipeline only works if the intermediate product is compatible with the second machine (domain restrictions).

When you later learn the chain rule, you'll see it as calculating how fast the final product changes based on how fast each machine transforms its input.


Connections

Looking back:

Looking ahead:


Previous Up Next
Function Arithmetic Section 1.3 The Tangent Line Problem

Last updated: 2026-01-22