TExcelTAD
Home › School Functions, Exponentials & Logarithms › Composition of Functions: (f ∘ g)(x) and Its Domain

Composition of Functions: (f∘g)(x)(f \circ g)(x) and Its Domain

When you solve mathematical models in physics, finance, or engineering, a single input rarely produces a final output in one step. Often, one process feeds its result directly into another process.

In mathematics, this "assembly line" operation is called the composition of functions. Instead of calculating an intermediate number, you can combine the algebraic rules of two functions into a single new function.


1. Concepts & Paper Visuals

The Function Machine Analogy

Think of a function as an input-output machine:

  • The inner function gg takes an initial input xx and produces the output g(x)g(x).
  • The outer function ff takes that intermediate output g(x)g(x) as its raw material and produces the final output f(g(x))f(g(x)).
           Initial Input: x
                 │
                 ▼
       ┌───────────────────┐
       │  Inner Machine: g │  Produces intermediate output: g(x)
       └─────────┬─────────┘
                 │
                 ▼  Intermediate value enters f
       ┌───────────────────┐
       │  Outer Machine: f │  Evaluates f at the value g(x)
       └─────────┬─────────┘
                 │
                 ▼
          Final Output: f(g(x))

Mathematical Notation

The composite function is denoted with a small circle ∘\circ:

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

Read this aloud as: "f of g of x" or "f composed with g of x".

[!IMPORTANT] The order of operations is strictly right-to-left:

  • In (f∘g)(x)(f \circ g)(x), the rightmost function gg acts first.
  • In (g∘f)(x)(g \circ f)(x), the rightmost function ff acts first. Function composition is not commutative: in general, (f∘g)(x)≠(g∘f)(x)(f \circ g)(x) \neq (g \circ f)(x).

2. Formula Box & Domain Definition

┌─────────────────────────────────────────────────────────────────────────────┐
│                       COMPOSITE FUNCTION & DOMAIN                           │
│                                                                             │
│  Definition:                                                                │
│      (f ∘ g)(x) = f(g(x))                                                   │
│                                                                             │
│  Domain of (f ∘ g):                                                         │
│      D_{f ∘ g} = { x ∈ ℝ | x ∈ D_g  and  g(x) ∈ D_f }                       │
│                                                                             │
│  In plain words:                                                            │
│  1. x must be an allowed input for the inner function g.                    │
│  2. The resulting value g(x) must be an allowed input for outer function f. │
└─────────────────────────────────────────────────────────────────────────────┘

3. Step-by-Step Paper Notebook Method

When working on paper, follow this systematic four-step protocol:

[ Step 1: Identify Inner & Outer Functions ]
  - Determine which function is applied first (inner) and second (outer).
  - State the natural domain of the inner function: D_g.

[ Step 2: Set Up Algebraic Substitution ]
  - Write outer function template f(□) with blank parentheses:
    f(x) = 2x² - 3  ──>  f(□) = 2(□)² - 3
  - Insert g(x) into every placeholder:
    f(g(x)) = 2(g(x))² - 3

[ Step 3: Expand and Simplify Algebraically ]
  - Expand powers, distribute factors, and collect like terms.
  - Keep denominators factored when simplifying rational expressions.

[ Step 4: Determine the Composite Domain ]
  - Condition A: x must satisfy the domain of g (x ∈ D_g).
  - Condition B: g(x) must satisfy the domain restrictions of f (g(x) ∈ D_f).
  - Intersect both conditions: D_{f ∘ g} = Condition A ∩ Condition B.

4. Step-by-Step Notebook Examples

Example 1: Basic Polynomial Composition & Order Dependence

Problem: Let f(x)=2x+5f(x) = 2x + 5 and g(x)=x2−3g(x) = x^2 - 3.

  1. Find the formula for (f∘g)(x)(f \circ g)(x) and evaluate (f∘g)(4)(f \circ g)(4).
  2. Find the formula for (g∘f)(x)(g \circ f)(x) and evaluate (g∘f)(4)(g \circ f)(4).

Solution (1): Computing (f∘g)(x)(f \circ g)(x)

  • Identify inner and outer: Inner is g(x)g(x), outer is f(u)=2u+5f(u) = 2u + 5.
  • Substitute g(x)g(x) into ff:
    (f∘g)(x)=f(g(x))=2(g(x))+5=2(x2−3)+5=2x2−6+5=2x2−1\begin{aligned} (f \circ g)(x) &= f(g(x)) \\ &= 2(g(x)) + 5 \\ &= 2(x^2 - 3) + 5 \\ &= 2x^2 - 6 + 5 \\ &= 2x^2 - 1 \end{aligned}
  • Evaluate at x=4x = 4:
    (f∘g)(4)=2(4)2−1=2(16)−1=32−1=31(f \circ g)(4) = 2(4)^2 - 1 = 2(16) - 1 = 32 - 1 = 31

Solution (2): Computing (g∘f)(x)(g \circ f)(x)

  • Identify inner and outer: Inner is f(x)f(x), outer is g(u)=u2−3g(u) = u^2 - 3.

  • Substitute f(x)f(x) into gg:

    (g∘f)(x)=g(f(x))=(f(x))2−3=(2x+5)2−3=(4x2+20x+25)−3=4x2+20x+22\begin{aligned} (g \circ f)(x) &= g(f(x)) \\ &= (f(x))^2 - 3 \\ &= (2x + 5)^2 - 3 \\ &= (4x^2 + 20x + 25) - 3 \\ &= 4x^2 + 20x + 22 \end{aligned}
  • Evaluate at x=4x = 4:

    (g∘f)(4)=4(4)2+20(4)+22=4(16)+80+22=64+80+22=166(g \circ f)(4) = 4(4)^2 + 20(4) + 22 = 4(16) + 80 + 22 = 64 + 80 + 22 = 166
  • Paper Conclusion:

    (f∘g)(x)=2x2−1,(g∘f)(x)=4x2+20x+22(f \circ g)(x) = 2x^2 - 1, \qquad (g \circ f)(x) = 4x^2 + 20x + 22

    Since 31≠16631 \neq 166, this confirms on paper that (f∘g)(x)≠(g∘f)(x)(f \circ g)(x) \neq (g \circ f)(x).


Example 2: Radical and Rational Functions with Domain Restrictions

Problem: Let f(x)=1x−3f(x) = \frac{1}{x - 3} and g(x)=x+2g(x) = \sqrt{x + 2}.
Find the formula for (f∘g)(x)(f \circ g)(x) and state its exact domain in interval notation.


Solution:

  • Step 1: Write down the expression

    (f∘g)(x)=f(g(x))=1g(x)−3=1x+2−3\begin{aligned} (f \circ g)(x) &= f(g(x)) \\ &= \frac{1}{g(x) - 3} \\ &= \frac{1}{\sqrt{x + 2} - 3} \end{aligned}
  • Step 2: Find the domain of the inner function g(x)g(x)
    The inner function g(x)=x+2g(x) = \sqrt{x + 2} requires a non-negative radicand:

    x+2≥0  ⟹  x≥−2x + 2 \ge 0 \implies x \ge -2

    Therefore, the initial domain requirement is x∈[−2,∞)x \in [-2, \infty).

  • Step 3: Apply the domain restriction of the outer function ff
    The outer function f(u)=1u−3f(u) = \frac{1}{u - 3} requires that its denominator cannot be zero:

    u−3≠0  ⟹  u≠3u - 3 \neq 0 \implies u \neq 3

    Since the input to ff is g(x)=x+2g(x) = \sqrt{x + 2}, we require:

    x+2≠3(x+2)2≠32x+2≠9x≠7\begin{aligned} \sqrt{x + 2} &\neq 3 \\ (\sqrt{x + 2})^2 &\neq 3^2 \\ x + 2 &\neq 9 \\ x &\neq 7 \end{aligned}
  • Step 4: Intersect the two conditions on paper
    Combine x≥−2x \ge -2 with x≠7x \neq 7:

    Df∘g=[−2,7)∪(7,∞)D_{f \circ g} = [-2, 7) \cup (7, \infty)
  • Final Answer:

    (f∘g)(x)=1x+2−3,Df∘g=[−2,7)∪(7,∞)(f \circ g)(x) = \frac{1}{\sqrt{x + 2} - 3}, \quad D_{f \circ g} = [-2, 7) \cup (7, \infty)

Example 3: Composition of Rational Functions (Compound Fraction Simplification)

Problem: Let f(x)=x+1x−2f(x) = \frac{x + 1}{x - 2} and g(x)=2x+1x−1g(x) = \frac{2x + 1}{x - 1}.
Find (f∘g)(x)(f \circ g)(x) in fully simplified form and state its domain.


Solution:

  • Step 1: Substitute g(x)g(x) into f(x)f(x)

    (f∘g)(x)=f(2x+1x−1)=(2x+1x−1)+1(2x+1x−1)−2(f \circ g)(x) = f\left(\frac{2x + 1}{x - 1}\right) = \frac{\left(\frac{2x + 1}{x - 1}\right) + 1}{\left(\frac{2x + 1}{x - 1}\right) - 2}
  • Step 2: Simplify the compound fraction on paper
    Multiply numerator and denominator by the common denominator (x−1)(x - 1), assuming x≠1x \neq 1:

    (f∘g)(x)=(2x+1)+1⋅(x−1)(2x+1)−2⋅(x−1)=2x+1+x−12x+1−2x+2=3x3=x\begin{aligned} (f \circ g)(x) &= \frac{(2x + 1) + 1 \cdot (x - 1)}{(2x + 1) - 2 \cdot (x - 1)} \\ &= \frac{2x + 1 + x - 1}{2x + 1 - 2x + 2} \\ &= \frac{3x}{3} \\ &= x \end{aligned}
  • Step 3: Analyze the domain

    • Condition 1 (Inner function gg): The denominator of g(x)g(x) cannot be zero:
      x−1≠0  ⟹  x≠1x - 1 \neq 0 \implies x \neq 1
    • Condition 2 (Outer function ff): The denominator of f(g(x))f(g(x)) cannot be zero:
      g(x)−2≠0  ⟹  2x+1x−1≠2g(x) - 2 \neq 0 \implies \frac{2x + 1}{x - 1} \neq 2
      Solving the equation:
      2x+1=2(x−1)  ⟹  2x+1=2x−2  ⟹  1=−2(impossible)2x + 1 = 2(x - 1) \implies 2x + 1 = 2x - 2 \implies 1 = -2 \quad (\text{impossible})
      The equation g(x)=2g(x) = 2 has no solutions, so g(x)≠2g(x) \neq 2 is automatically satisfied for all x≠1x \neq 1.
  • Final Answer:

    (f∘g)(x)=x,Df∘g=R∖{1}=(−∞,1)∪(1,∞)(f \circ g)(x) = x, \quad D_{f \circ g} = \mathbb{R} \setminus \{1\} = (-\infty, 1) \cup (1, \infty)

    (Notice that even though the simplified formula is the line y=xy = x, the domain excludes x=1x = 1 because g(1)g(1) is undefined!)


5. Common Mistakes & Paper Traps

[!WARNING]

Trap 1: Finding Domain Only From the Simplified Expression

If f(x)=x2f(x) = x^2 and g(x)=xg(x) = \sqrt{x}, then:

(f∘g)(x)=(x)2=x(f \circ g)(x) = (\sqrt{x})^2 = x

Looking only at the final simplified formula "xx", a student might wrongly write D=RD = \mathbb{R}.
Reality: The number x=−4x = -4 cannot even enter the inner machine gg, because −4\sqrt{-4} is undefined in R\mathbb{R}. The domain is strictly [0,∞)[0, \infty). Always check the inner function first!

[!CAUTION]

Trap 2: Confusing Composition with Multiplication

  • Composition: (f∘g)(x)=f(g(x))(f \circ g)(x) = f(g(x))
  • Multiplication: (f⋅g)(x)=f(x)×g(x)(f \cdot g)(x) = f(x) \times g(x) Never multiply the two formulas together when you see the circle symbol ∘\circ.

[!TIP]

Trap 3: Dropping Parentheses on Substitution

If f(x)=3−xf(x) = 3 - x and g(x)=2x−5g(x) = 2x - 5:

  • Wrong: f(g(x))=3−2x−5=−2−2xf(g(x)) = 3 - 2x - 5 = -2 - 2x
  • Correct: f(g(x))=3−(2x−5)=3−2x+5=8−2xf(g(x)) = 3 - (2x - 5) = 3 - 2x + 5 = 8 - 2x Always place brackets around the entire inner function g(x)g(x) when substituting.

6. Pencil & Paper Practice

Try these exercises on paper before checking the worked solutions below.

Practice 1

Given f(x)=2xf(x) = \frac{2}{x} and g(x)=x−4g(x) = x - 4.

  1. Find (f∘g)(x)(f \circ g)(x) and its domain.
  2. Find (g∘f)(x)(g \circ f)(x) and its domain.

Practice 2

Given h(x)=9−x2h(x) = \sqrt{9 - x^2} and k(x)=2xk(x) = 2x.
Find (h∘k)(x)(h \circ k)(x) and state its domain in interval notation.


Worked Solutions

Solution to Practice 1:

  1. For (f∘g)(x)(f \circ g)(x):

    (f∘g)(x)=f(g(x))=2x−4(f \circ g)(x) = f(g(x)) = \frac{2}{x - 4}

    Inner function g(x)=x−4g(x) = x - 4 is defined for all x∈Rx \in \mathbb{R}. Outer function requires denominator x−4≠0  ⟹  x≠4x - 4 \neq 0 \implies x \neq 4.

    Df∘g=(−∞,4)∪(4,∞)D_{f \circ g} = (-\infty, 4) \cup (4, \infty)
  2. For (g∘f)(x)(g \circ f)(x):

    (g∘f)(x)=g(f(x))=2x−4=2−4xx(g \circ f)(x) = g(f(x)) = \frac{2}{x} - 4 = \frac{2 - 4x}{x}

    Inner function f(x)=2xf(x) = \frac{2}{x} requires x≠0x \neq 0. Outer function has no further restrictions.

    Dg∘f=(−∞,0)∪(0,∞)D_{g \circ f} = (-\infty, 0) \cup (0, \infty)

Solution to Practice 2:

(h∘k)(x)=h(2x)=9−(2x)2=9−4x2(h \circ k)(x) = h(2x) = \sqrt{9 - (2x)^2} = \sqrt{9 - 4x^2}

For the domain:

9−4x2≥0(3−2x)(3+2x)≥04x2≤9∣x∣≤32  ⟹  −32≤x≤32\begin{aligned} 9 - 4x^2 &\ge 0 \\ (3 - 2x)(3 + 2x) &\ge 0 \\ 4x^2 &\le 9 \\ |x| &\le \frac{3}{2} \implies -\frac{3}{2} \le x \le \frac{3}{2} \end{aligned}

Domain: Dh∘k=[−32,32]D_{h \circ k} = \left[-\frac{3}{2}, \frac{3}{2}\right].


Test yourself

Let f(x)=x2+1f(x) = x^2 + 1 and g(x)=3x−2g(x) = 3x - 2. What is the value of (f∘g)(2)(f \circ g)(2)?

  1. 1717
  2. 1313
  3. 1010
  4. 2525

What is the natural domain of (f∘g)(x)(f \circ g)(x) if f(x)=1x−5f(x) = \frac{1}{x - 5} and g(x)=2x+1g(x) = 2x + 1?

  1. (−∞,5)∪(5,∞)(-\infty, 5) \cup (5, \infty)
  2. (−∞,2)∪(2,∞)(-\infty, 2) \cup (2, \infty)
  3. (−∞,3)∪(3,∞)(-\infty, 3) \cup (3, \infty)
  4. (−∞,∞)(-\infty, \infty)

If f(x)=xf(x) = \sqrt{x} and g(x)=x−7g(x) = x - 7, what is the domain of (f∘g)(x)(f \circ g)(x)?

  1. [0,∞)[0, \infty)
  2. (−∞,7](-\infty, 7]
  3. [7,∞)[7, \infty)
  4. (7,∞)(7, \infty)