Free for students · Ad-free · WCAG 2.1 AA Compliant · Accessibility

Composition of Functions

Lesson ~11 min read 8 MCQs

In simple terms: In simple terms, composition of functions is about plugging the output of one function directly into the input of another, like a two-step assembly line.

Why this matters

Imagine you're shopping in Dallas for a new pair of headphones that cost $100. You have two coupons: a "20% off" coupon from the manufacturer and a "10% off" store-wide coupon. You can use both! Does the order you present them at the register matter?

If you apply the 20% off first, then the 10% off, is that the same as applying the 10% off first, then the 20%? This is a real-world composition of functions problem. Each coupon is a function that changes the price. We're plugging the result of one coupon into the function of the next. Today, we'll master this idea of "chaining" functions together.

Visualizing the composition of two coupon functions on an initial price.

Concept overview

flowchart LR
    subgraph Composition f(g(x))
        direction LR
        A[Input x = 1] --> B{g(x) = x + 2};
        B --> C[Output g(1) = 3];
        C --> D{f(x) = x^2};
        D --> E[Final Output f(3) = 9];
    end
This diagram shows a left-to-right flowchart for evaluating the composite function f(g(x)). An input of x=1 enters a function block for g(x)=x+2, producing an output of 3. This output then becomes the input for a second function block, f(x)=x^2, which produces the final output of 9.

Core explanation

At its heart, function composition is about a sequence of operations. Think of it like an assembly line for numbers. An input value goes into the first machine, gets processed, and the result of that becomes the input for the second machine.

Notation and The "Function Machine"

Let's say we have two functions, f(x) and g(x). The composition of f with g is written as (f ∘ g)(x) or, more commonly, f(g(x)).

  • (f ∘ g)(x): That little circle means "composed with." It is NOT a multiplication sign.
  • f(g(x)): This notation is more intuitive. It shows that the function g(x) is sitting inside the function f(x).

In the expression f(g(x)):

  • g(x) is the inner function. It's the first step in our assembly line.
  • f(x) is the outer function. It's the second step, which acts on the result of g(x).

The Golden Rule of Composition: Always work from the inside out.

Evaluating Composite Functions (LO 2.7.A)

Let's use our "function machine" example.

  • Let the inner function be g(x) = x + 2.
  • Let the outer function be f(x) = x^2.

What is f(g(1))?

  1. 1
    Start inside
    First, find the value of the inner function, g(1). g(1) = 1 + 2 = 3 So, our first machine takes in 1 and spits out 3.
  2. 2
    Use the output as the new input
    Now, take that output, 3, and plug it into the outer function, f(x). f(3) = 3^2 = 9 Our second machine takes in 3 and spits out 9.

So, f(g(1)) = 9.

We can do this using any representation of a function—equations, tables, or graphs. For a table, you'd find the output of g(1) in its table, then look for that value as an input in f's table.

Does Order Matter?

Let's flip it. What is g(f(1))?

  1. 1
    Start inside
    Evaluate the inner function, f(1). f(1) = 1^2 = 1
  2. 2
    Use the output as the new input
    Plug that result into g(x). g(1) = 1 + 2 = 3

So, g(f(1)) = 3.

The only major exception is the identity function, f(x) = x. This function just returns its input, unchanged. If you compose any function g(x) with f(x) = x, you just get g(x) back. It's like adding 0 or multiplying by 1; it doesn't change the original.

Constructing a New Composite Function (LO 2.7.B)

Sometimes, we need to create a single formula for the entire two-step process. To build the equation for f(g(x)), we substitute the entire expression for the inner function into every instance of the variable in the outer function.

Let's use our same functions: f(x) = x^2 and g(x) = x + 2.

To find the formula for h(x) = f(g(x)):

  1. Start with the outer function: f(x) = x^2.
  2. Identify its input variable: x.
  3. Replace that x with the entire inner function, g(x) = x + 2.

So, f(g(x)) = f(x + 2) = (x + 2)^2.

This new function, h(x) = (x + 2)^2, represents the entire assembly line in one step. If we plug x=1 into it, we get h(1) = (1 + 2)^2 = 3^2 = 9, the same answer we got before.

Decomposing Functions (LO 2.7.C)

Decomposition is the reverse process: breaking a complex function down into two or more simpler, "nested" functions. This is a crucial skill for calculus.

Given a function like h(x) = √(4x - 1), how can we write it as h(x) = f(g(x))?

Look for an "inner" operation that's being acted upon by an "outer" operation.

  • The expression 4x - 1 is inside the square root. This is a good candidate for our inner function. Let g(x) = 4x - 1.
  • The "outer" operation is taking the square root of something. So, our outer function can be f(x) = √x.

Let's check: f(g(x)) = f(4x - 1) = √(4x - 1). It works!

There can be multiple ways to decompose a function, but we usually look for the most obvious "inner" piece.

This idea also helps us understand transformations. A horizontal shift like F(x) = (x - 3)^2 is really a composition. If f(x) = x^2 and g(x) = x - 3, then F(x) = f(g(x)). This reframes something you already know in the language of composition.

Tracing an input through inner function g(x) then outer function f(x).

Worked examples

Example 1

Evaluating and Constructing from Equations

Problem: Given f(x) = 3x + 5 and g(x) = x^2 - 4. a) Find f(g(3)). b) Find g(f(3)). c) Construct an analytic representation of f(g(x)).

Solution:

Part a) Find f(g(3)) Remember, we work from the inside out.

  1. Evaluate the inner function g(3): g(3) = (3)^2 - 4 g(3) = 9 - 4 = 5
  2. Use that output as the input for f(x): Now we find f(5). f(5) = 3(5) + 5 f(5) = 15 + 5 = 20 So, f(g(3)) = 20.

Part b) Find g(f(3)) The order is now reversed.

  1. Evaluate the inner function f(3): f(3) = 3(3) + 5 f(3) = 9 + 5 = 14
  2. Use that output as the input for g(x): Now we find g(14). g(14) = (14)^2 - 4 g(14) = 196 - 4 = 192 So, g(f(3)) = 192. As expected, f(g(3)) is not the same as g(f(3)).

Part c) Construct f(g(x)) We need a single formula.

  1. Start with the outer function f(x) = 3x + 5.
  2. Identify the input variable x.
  3. Replace that x with the entire expression for g(x), which is x^2 - 4. Use parentheses! f(g(x)) = 3( g(x) ) + 5 f(g(x)) = 3(x^2 - 4) + 5
  4. Simplify the expression: f(g(x)) = 3x^2 - 12 + 5 f(g(x)) = 3x^2 - 7 Our new composite function is f(g(x)) = 3x^2 - 7. Self-check: Let's test this with x=3. f(g(3)) = 3(3)^2 - 7 = 3(9) - 7 = 27 - 7 = 20. This matches our answer from Part a!

Example 2

Decomposing a Function

Problem: Decompose the function h(x) = |2x + 7|^3 into two functions f(x) and g(x) such that h(x) = f(g(x)).

Solution:

Our goal is to find an inner function g(x) and an outer function f(x).

  1. 1
    Look for the "innermost" calculation
    What's buried deepest inside the parentheses, absolute values, or radicals? Here, the expression 2x + 7 is inside the absolute value bars. This is a great candidate for our inner function. Let g(x) = 2x + 7.
  2. 2
    Figure out what the outer function is doing
    Once we have the result of g(x), what happens to it? It's put into absolute value bars, and then the result is cubed. So, the outer function takes an input, finds its absolute value, and cubes it. Let's represent the input with x. The function would be |x|^3. So, let f(x) = |x|^3.
  3. 3
    Check your work
    Let's compose the f(x) and g(x) we just found and see if we get h(x) back. f(g(x)) = f(2x + 7) Now, we plug 2x + 7 into the x of f(x): f(2x + 7) = |(2x + 7)|^3 This is exactly our original function h(x). So our decomposition is correct.

A common wrong turn here is to make the functions too simple or too complex. For example, choosing g(x) = x is not helpful. Another possibility could be g(x) = |2x + 7| and f(x) = x^3. This also works! Often, there's more than one correct answer for decomposition, but you should aim for the most logical split of operations.

Graph of the composite function f(g(x)) = 3x^2 - 7.

Try it yourself

Ready to try one on your own? You've got this.

Problem 1: Let p(t) be the number of people in a store t hours after it opens at 9 AM, given by p(t) = 10t^2 - 5t. Let C(p) be the total dollars in sales when p people are in the store, given by C(p) = 15p.

a) Find and interpret C(p(2)). b) Construct a function S(t) that gives the total sales t hours after opening.

Hints:

  • For part (a), work inside-out. What does p(2) represent in the real world?
  • For part (b), you're looking for C(p(t)). Substitute the entire expression for p(t) into the variable p in the function C(p).

Problem 2: Decompose the function k(x) = 1 / (x^2 + 3) into two simpler functions f(x) and g(x).