Composition of Functions

The composition of functions puts one function inside another. The composition (f \circ g)(x) = f(g(x)) means: first find g(x), then use that output as the input of f. Order matters, because f(g(x)) and g(f(x)) are usually different. Composition shows up whenever one step feeds into the next, like a discount followed by sales tax.

Before this lesson: You should know Function Operations, Function Notation and Multiplying Binomials.

What Composition Means

Think of each function as a machine. A composition sends an input through two machines in a row. The output of the first machine becomes the input of the second.

An input of 2 goes into the g machine, g(x) = x squared minus 3, which outputs 1. That output goes into the f machine, f(x) = 2x + 1, which outputs 3. So f of g of 2 equals 3. The inside function, g, works first.
In f(g(2)), the inside function g works first. Its output, 1, goes into f.
(f \circ g)(x) = f(g(x))

Read f \circ g as “f composed with g” or “f of g.” The small circle is not a multiplication sign. Work from the inside out: the function next to x acts first.

Domain of a Composition

An input x is in the domain of f \circ g when two things are true:

  • x is in the domain of g, so g(x) exists.
  • g(x) is in the domain of f, so f can use it.

How to Compose Functions

  1. To evaluate f(g(a)), find g(a) first.
  2. Then substitute that number into f.
  3. To find a formula for f(g(x)), replace every x in f with the whole expression g(x), in parentheses.
  4. Simplify, and check the domain.

Worked Examples

In Examples 1 and 2, f(x) = 2x + 1 and g(x) = x^2 - 3.

Example 1: Evaluate a composition

Find (f \circ g)(2).

  1. Start inside. Find g(2): g(2) = 2^2 - 3
  2. Simplify: g(2) = 4 - 3 = 1
  3. Put the output into f: f(1) = 2(1) + 1
  4. Simplify: f(1) = 3

Answer: (f \circ g)(2) = 3

Example 2: Find both compositions

Find (f \circ g)(x) and (g \circ f)(x).

  1. For f(g(x)), replace x in f with g(x): f(g(x)) = 2(x^2 - 3) + 1
  2. Distribute (see distributive property): 2x^2 - 6 + 1
  3. Combine like terms: f(g(x)) = 2x^2 - 5
  4. For g(f(x)), replace x in g with f(x): g(f(x)) = (2x + 1)^2 - 3
  5. Square the binomial (see special products of binomials): 4x^2 + 4x + 1 - 3
  6. Combine like terms: g(f(x)) = 4x^2 + 4x - 2

Answer: (f \circ g)(x) = 2x^2 - 5 and (g \circ f)(x) = 4x^2 + 4x - 2. They are different, so order matters.

Example 3: Domain of a composition

Let f(x) = \sqrt{x} and g(x) = x - 5. Find f(g(x)), g(f(x)) and the domain of each.

  1. Replace x in f with x - 5: f(g(x)) = \sqrt{x - 5}
  2. The square root needs x - 5 \ge 0. Add 5 to both sides: x \ge 5. Domain: [5, \infty)
  3. Replace x in g with \sqrt{x}: g(f(x)) = \sqrt{x} - 5
  4. Here \sqrt{x} must exist first, so x \ge 0. Domain: [0, \infty)
  5. Check one value: f(g(9)) = \sqrt{9 - 5} = \sqrt{4} = 2

Answer: f(g(x)) = \sqrt{x - 5} with domain [5, \infty). g(f(x)) = \sqrt{x} - 5 with domain [0, \infty).

Example 4: Break a function apart

Write h(x) = (3x - 2)^4 as a composition f(g(x)).

  1. Ask what happens first to x: it is multiplied by 3 and then 2 is subtracted. That is the inside function: g(x) = 3x - 2
  2. Then the result is raised to the 4th power. That is the outside function: f(x) = x^4
  3. Check: f(g(x)) = (3x - 2)^4 = h(x)

Answer: g(x) = 3x - 2 and f(x) = x^4. Breaking functions apart like this is a key skill in calculus.

Example 5: Word problem with a sale

A store takes 20% off every price, then adds 6% sales tax. Write functions for each step and a composition for the final price. Find the final price of a $50 item.

  1. The discount keeps 80% of the price: d(p) = 0.8p
  2. The tax adds 6%, so it multiplies by 1.06: t(p) = 1.06p
  3. The discount happens first, so it is inside: t(d(p)) = 1.06(0.8p)
  4. Multiply the decimals: t(d(p)) = 0.848p
  5. Evaluate at 50: t(d(50)) = 0.848(50) = 42.4

Answer: The final price is 0.848p, so a $50 item costs $42.40.

Common Mistakes

MistakeExample of the errorFix
Working from the outside inFor f(g(2)), finding f(2) firstStart with the inside: g(2).
Treating ∘ as multiplication(f \circ g)(x) = f(x) \cdot g(x)∘ means substitute: f(g(x)).
Forgetting parenthesesf(g(x)) = 2x^2 - 3 + 1Put g(x) in parentheses: 2(x^2 - 3) + 1.
Assuming order doesn’t matterSaying f(g(x)) = g(f(x))Find both. They are usually different.
Squaring a binomial term by term(2x + 1)^2 = 4x^2 + 1Include the middle term: 4x^2 + 4x + 1.

Practice Problems

In problems 1–5, f(x) = x + 4 and g(x) = 3x^2.

  1. Find (f \circ g)(1).
  2. Find (g \circ f)(1).
  3. Find (f \circ g)(x).
  4. Find (g \circ f)(x).
  5. Find (f \circ f)(x).
  6. Let f(x) = \sqrt{x} and g(x) = x + 9. Find f(g(x)) and its domain.
  7. Write h(x) = \sqrt{x^2 + 1} as f(g(x)).
  8. Write h(x) = \frac{1}{x - 7} as f(g(x)).
  9. Let f(x) = x + 2 and g(x) = x - 2. Show that f(g(x)) = g(f(x)) = x.
  10. A ripple spreads in a pond. Its radius is r(t) = 3t cm after t seconds, and the area of a circle is A(r) = \pi r^2. Find A(r(t)) and the area after 4 seconds.
Show answers
  1. Inside first: g(1) = 3(1)^2 = 3
    Then f: f(3) = 3 + 4 = 7
  2. Inside first: f(1) = 1 + 4 = 5
    Then g: g(5) = 3(5)^2 = 3(25) = 75
  3. Replace x in f with 3x^2: f(g(x)) = 3x^2 + 4
  4. Replace x in g with x + 4: g(f(x)) = 3(x + 4)^2
    Square the binomial: 3(x^2 + 8x + 16)
    Distribute: g(f(x)) = 3x^2 + 24x + 48
  5. Replace x in f with x + 4: f(f(x)) = (x + 4) + 4
    Combine: f(f(x)) = x + 8
  6. Replace x in f with x + 9: f(g(x)) = \sqrt{x + 9}
    Need x + 9 \ge 0
    Subtract 9 from both sides: x \ge -9. Domain: [-9, \infty)
  7. Inside: g(x) = x^2 + 1
    Outside: f(x) = \sqrt{x}
  8. Inside: g(x) = x - 7
    Outside: f(x) = \frac{1}{x}
  9. f(g(x)) = (x - 2) + 2 = x
    g(f(x)) = (x + 2) - 2 = x
    Both give x. Functions that undo each other like this are inverse functions, the next lesson.
  10. Replace r in A with 3t: A(r(t)) = \pi(3t)^2
    Square: A(r(t)) = 9\pi t^2
    At t = 4: 9\pi(4)^2 = 9\pi(16) = 144\pi
    Use a calculator: 144\pi \approx 452.39 cm²

FAQ

What does f(g(x)) mean?

It means put x into g first, then put that output into f. It is also written (f \circ g)(x).

Is f(g(x)) the same as g(f(x))?

Usually not. In Example 2, f(g(x)) = 2x^2 - 5 but g(f(x)) = 4x^2 + 4x - 2. They are equal only in special cases, such as inverse functions.

How do you find the domain of a composite function?

Keep the inputs that work in the inside function, and whose outputs also work in the outside function. Using the simplified formula alone can miss a restriction.

How do you decompose a function?

Find the first thing that happens to x. That is the inside function g. Whatever is done to that result is the outside function f.

Summary

  • (f \circ g)(x) = f(g(x)): apply g first, then f.
  • To evaluate, work from the inside out. To find a formula, replace x in f with (g(x)).
  • Order matters: f(g(x)) and g(f(x)) are usually different.
  • The domain includes only inputs that work in g and give outputs that work in f.

Previous lesson: Function Operations

Next lesson: Inverse Functions

Back to the Algebra 2 Index