Function Composition Examples: 46 Problems with Answers

Worked examples of Function Composition to try before you open each solution, then practice problems with answers.

Worked Examples

Example 1

easy
Given f(x)=2x+1 and g(x)=x2, find (f∘g)(3).
Show solution

Answer

19

First step

1.
(f∘g)(3) means f(g(3)), so evaluate the inner function first.

Full solution

  1. 2.
    Compute g(3)=32=9.
  2. 3.
    Substitute that result into f: f(9)=2(9)+1=19.
Function composition works from the inside out: evaluate the inner function first, then feed its output into the outer function.

Example 2

medium
Given f(x)=x+3 and g(x)=2x2−1, find the formula for (g∘f)(x).

Example 3

easy
Given f(x)=x2 and g(x)=x−3, compute both (f∘g)(5) and (g∘f)(5) and notice the order matters.

Example 4

medium
Given f(x)=x−1 and g(x)=x2, find (f∘g)(x) and state its domain.

Example 5

medium
Express h(x)=2x+5 as a composition f∘g with simple f,g.

Example 6

hard
Let f(x)=11−x. Compute f(f(x)) and f(f(f(x))) and describe what you observe.

Example 7

challenge
Define f1(x)=xx+1 and fn+1=f1∘fn. Find a closed form for fn(x).

Practice Problems

Try each one, then open the solution to compare your method.

Example 1

easy
Given f(x)=x−4 and g(x)=3x, find (f∘g)(5).

Example 2

hard
Given f(x)=x and g(x)=x2+5, find the domain of (f∘g)(x).

Example 3

easy
If f(x)=x+1 and g(x)=2x, find (f∘g)(3).

Example 4

easy
If f(x)=x2 and g(x)=x+3, find (f∘g)(1).

Example 5

easy
If f(x)=2x and g(x)=x−1, find (g∘f)(4).

Example 6

easy
If f(x)=x+2 and g(x)=3x, find (f∘g)(x).

Example 7

easy
If f(x)=x−5 and g(x)=x+5, find (f∘g)(x).

Example 8

easy
If f(x)=x2, find (f∘f)(2).

Example 9

easy
If f(x)=x and g(x)=x+9, find (f∘g)(0).

Example 10

easy
If f(x)=3x+1 and g(x)=x, find (f∘g)(x).

Example 11

medium
If f(x)=x+1 and g(x)=x2, find (f∘g)(x) and (g∘f)(x).

Example 12

medium
If f(x)=2x−1 and g(x)=x+12, find (f∘g)(x).

Example 13

medium
If h(x)=(x+3)2, write h as f∘g.

Example 14

medium
If f(x)=x2+1 and (f∘g)(x)=x2+2x+2, find g(x) (linear).

Example 15

medium
If f(x)=1x and g(x)=x−2, find the domain of (f∘g)(x).

Example 16

medium
If f(x)=3x, find a function g with (f∘g)(x)=x.

Example 17

medium
If f(x)=x+a and (f∘f)(x)=x+6, find a.

Example 18

medium
If f(x)=2x and g(x)=x+1, find (f∘g∘f)(2).

Example 19

challenge
If f(x)=xx+1, find (f∘f)(x) simplified.

Example 20

challenge
If (f∘g)(x)=4x2+4x+2 and f(x)=x2+1, find a linear g(x).

Example 21

challenge
Functions satisfy f(x)=2x+3 and f(g(x))=g(f(x)) for all x, with g linear g(x)=mx+b. Find a relation between m and b.

Example 22

medium
If f(x)=x−4 and g(x)=x2, find (g∘f)(x).

Example 23

easy
If f(x)=4x−3 and g(x)=x+2, find (f∘g)(5).

Example 24

easy
If f(x)=x2−1 and g(x)=2x, find (f∘g)(3).

Example 25

easy
If f(x)=x+7 and g(x)=2x−1, find (f∘g)(x).

Example 26

medium
If f(x)=2x+5 and g(x)=x2−4, find (f∘g)(x).

Example 27

medium
If f(x)=x2+x and g(x)=x−1, find (f∘g)(x) simplified.

Example 28

medium
If f(x)=1x−3 and g(x)=x+1, find the domain of (f∘g)(x).

Example 29

medium
If f(x)=2x+1 and (f∘g)(x)=2x+7, find a linear g(x).

Example 30

medium
If g(x)=x−2 and (f∘g)(x)=x2−4x+1, find f(x).

Example 31

medium
If f(x)=3x−1, find (f∘f)(x).

Example 32

medium
Express h(x)=(3x−7)4 as f∘g.

Example 33

medium
If f(x)=1x, find (f∘f)(x) for x≠0.

Example 34

hard
Given f(x)=x2+1 and (g∘f)(x)=2x2+5, find g(x).

Example 35

hard
If f(x)=x+1x−1, find (f∘f)(x) in simplified form for x≠1.

Example 36

hard
If f(x)=ax+b and (f∘f)(x)=9x+8, find all real (a,b).

Example 37

hard
Find a function g with (g∘g)(x)=4x+3, assuming g is linear.

Example 38

hard
If f(x)=2x+1 and g(x)=x−3, find (f∘g)−1(x).

Example 39

challenge
Find all linear functions f(x)=ax+b (with a≠0) such that f∘f=f−1.

What to focus on

Core idea: Composition feeds the result of the inner function straight into the outer function.

Common stuck point: The procedure for function composition is the easy part; the trap is applying f before g in (f∘g)(x). Asking "Is the output of one function being used as the input of another, in a fixed order?" first is what keeps a correct-looking calculation from being attached to the wrong concept.

Ask yourself: Is the output of one function being used as the input of another, in a fixed order?

Concept recap

Function composition applies one function to the output of another: (f∘g)(x)=f(g(x)), meaning evaluate g first, then apply f to the result.

Composition is a relay race: the second runner cannot start until the first hands over the baton, and what the second runner carries is exactly what the first delivered. Swap the running order and the finish can change, just as (x+1)2 differs from x2+1.

Read the full lesson on Function Composition

Common mistakes to watch for

Function Composition is covered with related ideas in the guide Functions and Graphs: Complete Foundations for Algebra and Calculus.

Related concepts

Background knowledge

These ideas may be useful before you work through the harder examples.

function definition