topic badge

4.07 Function composition

Function composition

We can create a composite function using an operation that combines two functions f and g and produces a function h such that h\left(x\right)=g\left(f\left(x\right)\right). The output, or function values, of the function f\left(x\right) become the input, or x-values, of the function g\left(x\right).

Exploration

Let f(x)= 2x+5 and g(x)= x-1

The composition of f with g is:

\displaystyle f(g(x))\displaystyle =\displaystyle 2(x-1)+5
\displaystyle =\displaystyle 2x-2+5
\displaystyle =\displaystyle 2x+3
  1. Find the composition of g with f.

    g(f(x))= ⬚

  2. Is g(f(x)) the same as f(g(x))? Explain.

  3. Evaluate g(2). Then evaluate f(g(2)).

    g(2)= ⬚

    f(g(2))=⬚

  4. Explain what f(g(2)) represents.
Composite function

A function created when one function is substituted into another function

The symbol \circ can also be used to represent a composite function. f\left(g\left(x\right)\right)=\left(f\circ g\right)\left(x\right)

In a composition of functions, the inner function is evaluated first, followed by the outer function. For example, in the composition g\left(f\left(x\right)\right), the function f is applied first, followed by the function g. This means that \left(g \circ f\right)\left(x\right) is not necessarily equal to \left(f \circ g\right)\left(x\right).

We can use graphs to evaluate the composition of functions. For example, consider the graphs of f(x) and g(x) shown. We will use these graphs to find g(f(8)).

-1
1
2
3
4
5
6
7
8
9
x
-2
-1
1
2
3
4
5
6
7
8
f(x)

In a composition of function, the inner function is evaluated first.

For this example, we need to find f(8). Looking at the graph of f\left(x\right), we see that when the x-value is 8, the y-value is 4.f(8)=4

-5
-4
-3
-2
-1
1
2
3
4
5
x
-1
1
2
3
4
5
6
7
8
9
g(x)

The output we just found from f(x) now becomes the input for the outer function, g(x).g\left(f\left(8\right)\right)=g(4)

Looking at the graph, we see that when the x-value is 4, the y-value is 5. g(4)=5

Therefore, g(f(8))=5

Examples

Example 1

For f(x)= x^2 + 5 and g(x)=3x-2:

a

Find f(-1).

Worked Solution
Create a strategy

To evaluate f(-1), we need to substitute x=-1 into the function f(x)=x^2 +5.

Apply the idea
\displaystyle f(x)\displaystyle =\displaystyle x^2+5Original function
\displaystyle f(-1)\displaystyle =\displaystyle (-1)^2+5Substitute x=-1
\displaystyle {}\displaystyle =\displaystyle 1+5Evaluate the exponent
\displaystyle {}\displaystyle =\displaystyle 6Evaluate the addition

This shows f\left(-1\right)=6.

b

Find g\left(f(-1)\right).

Worked Solution
Create a strategy

Since we know f(-1)=6, we will use 6 as the input for the outer function g(x).g\left(f\left(-1\right)\right)=g\left(6\right)

Apply the idea
\displaystyle g(x)\displaystyle =\displaystyle 3x-2Original function, g\left(x\right)
\displaystyle g(6)\displaystyle =\displaystyle 3(6)-2Substitute x=6
\displaystyle {}\displaystyle =\displaystyle 18-2Evaluate the multiplication
\displaystyle {}\displaystyle =\displaystyle 16Evaluate the subtraction

This shows that g(f(-1))=16.

Example 2

Consider the graphs of f(x) and g(x) shown.

-5
-4
-3
-2
-1
1
2
3
4
5
x
-6
-5
-4
-3
-2
-1
1
2
3
4
f(x)
-7
-6
-5
-4
-3
-2
-1
1
2
3
x
-1
1
2
3
4
5
6
7
8
9
g(x)
a

Find g(-3).

Worked Solution
Create a strategy

Use the graph of g\left(x\right) to find the output (the y-value) when the input (the x-value) is -3.

Apply the idea
-7
-6
-5
-4
-3
-2
-1
1
2
3
x
-1
1
2
3
4
5
6
7
8
9
g(x)

When x=-3, the output is 3.

This means g\left(-3\right)=3.

b

Find f(g(-3)).

Worked Solution
Create a strategy

The input of f\left(x\right) is the output of g\left(-3\right), which we found to be 3.f\left(g\left(-3\right)\right)=f\left(3\right) We now need to evaluate f\left(3\right).

Apply the idea

Using the graph of f\left(x\right), we will look for the output or y-value when x=3.

-5
-4
-3
-2
-1
1
2
3
4
5
x
-6
-5
-4
-3
-2
-1
1
2
3
4
f(x)

When x=3, the output is -5.

Therefore, f(g(-3))=-5

Example 3

Consider the following pair of functions:

\begin{aligned} f\left(x\right) & = -5x+5\\\ g\left(x\right) & = 2x^2+3x-10 \end{aligned}

a

Find \left(f \circ g\right)\left(x\right)

Worked Solution
Create a strategy

To find \left(f \circ g\right)\left(x\right), we need to use g\left(x\right) as the input of f\left(x\right).

Apply the idea
\displaystyle \left(f \circ g\right)\left(x\right)\displaystyle =\displaystyle f\left(g\left(x\right)\right)Definition of function composition
\displaystyle =\displaystyle f\left(2x^2+3x-10\right)Substitute g\left(x\right)

The notation f\left(2x^2+3x-10\right) means we need to replace the independent variable in f\left(x\right) with 2x^2+3x-10.

\displaystyle f\left(x\right)\displaystyle =\displaystyle -5x+5Original function, f\left(x\right)
\displaystyle f\left(2x^2+3x-10\right)\displaystyle =\displaystyle -5\left(2x^2+3x-10\right)+5Substitute \left(2x^2+3x-10\right)
\displaystyle =\displaystyle -10x^2-15x+50+5Distribute -5
\displaystyle =\displaystyle -10x^2-15x+55Evaluate the addition

Therefore, \left(f\circ g\right)=-10x^2-15x+55.

b

Find \left(g\circ f\right)\left(x\right)

Worked Solution
Create a strategy

To find \left(g \circ f\right)\left(x\right), we need to use f\left(x\right) as the input of f\left(x\right).

Apply the idea
\displaystyle g\left(x\right)\displaystyle =\displaystyle -2x^2+3x-10Original function, g\left(x\right)
\displaystyle g\left(-5x+5\right)\displaystyle =\displaystyle 2\left(-5x+5\right)^2+3(-5x+5)-10Substitute \left(-5x+5\right)
\displaystyle =\displaystyle 2(25x^2-50x+25)+3(-5x+5)-10Expand (-5x+5)^2
\displaystyle =\displaystyle 50x^2-100x+50-15x+15-10Distribute
\displaystyle =\displaystyle 50x^2-115x+55Evaluate

Therefore, \left(g\circ f\right)=50x^2-115x+55.

c

Does \left(f\circ g\right)\left(x\right)=\left(g\circ f\right)\left(x\right)?

Worked Solution
Create a strategy

Compare \left(f\circ g\right)\left(x\right)=\left(g\circ f\right)\left(x\right).

Apply the idea

\left(f\circ g\right)=-10x^2-15x+55

\left(g\circ f\right)=50x^2-115x+55

\left(f\circ g\right)\neq \left(g\circ f\right)

Reflect and check

It is possible to have two functions such that \left(f\circ g\right)\left(x\right)=\left(g\circ f\right)\left(x\right).

For example, consider the functions f(x)=5x-4 and g(x)= \dfrac{x+4}{5}.

Finding \left(f \circ g\right)\left(x\right):

\displaystyle \left(f \circ g\right)\left(x\right)\displaystyle =\displaystyle f\left(g\left(x\right)\right)Definition of function composition
\displaystyle =\displaystyle f\left(\dfrac{x+4}{5}\right)Substitute g\left(x\right)
\displaystyle f\left(x\right)\displaystyle =\displaystyle 5x-4Original function, f\left(x\right)
\displaystyle f\left(\dfrac{x+4}{5}\right)\displaystyle =\displaystyle 5\left(\dfrac{x+4}{5}\right)-4Substitute f\left(\dfrac{x+4}{5}\right)
\displaystyle =\displaystyle x+4-4Distribute 5
\displaystyle =\displaystyle xEvaluate the subtraction

Finding \left(g \circ f\right)\left(x\right):

\displaystyle \left(g \circ f\right)\left(x\right)\displaystyle =\displaystyle g\left(f\left(x\right)\right)Definition of function composition
\displaystyle =\displaystyle g(5x-4)Substitute g\left(x\right)
\displaystyle g\left(x\right)\displaystyle =\displaystyle \dfrac{x+4}{5}Original function, g\left(x\right)
\displaystyle g(5x-4)\displaystyle =\displaystyle \frac{(5x-4)+4}{5}Substitute g(5x-4)
\displaystyle =\displaystyle \frac{5x}{5}Combine like terms
\displaystyle =\displaystyle xDivide

As we can see, \left(f\circ g\right)\left(x\right)=\left(g\circ f\right)\left(x\right).

d

Compare the domain and range of \left(f\circ g\right)\left(x\right) and \left(g\circ f\right)\left(x\right).

Worked Solution
Create a strategy

We can use the structure of the equations to determine what function family each belongs to, then use what we know about that family to identify the domain and range.

Since both \left(f\circ g\right)\left(x\right) and \left(g\circ f\right)\left(x\right) are quadratics, we will need to use the formula x=-\dfrac{b}{2a} to find the vertex in order to find the range.

Apply the idea

Since \left(f\circ g\right)=-10x^2-15x+55 and \left(g\circ f\right)=50x^2-115x+55 are both quadratic functions, the domain is all real numbers, (-\infty,\infty).

The range of a quadratic function depends on the y-value of its vertex and whether it is a maximum or minimum.

For \left(f\circ g\right)=-10x^2-15x+55, the x-coordinate of the vertex is computed as {x=-\dfrac{-15}{-20}=-0.75}

Substituting this into the equation to find the y-coordinate of the vertex, we get:

\displaystyle -10(-0.75)^2-15(-0.75)+55\displaystyle =\displaystyle 60.625

Since the leading coefficient is negative, the parabola opens downward, so the range is (-\infty,60.625].

For \left(g\circ f\right)=50x^2-115x+55, the x-coordinate of the vertex is computed as x=-\dfrac{-155}{100}=1.15

Substituting this into the equation to find the y-coordinate of the vertex, we get:

\displaystyle 50(1.15)^2-115(1.15)+55\displaystyle =\displaystyle -11.125

Since the leading coefficient is positive, this parabola opens upward, so the range is [-11.125, \infty).

Example 4

Use the graphs of g\left(x\right) and f\left(x\right) to find (f\circ g)\left(1\right)

-3
-2
-1
1
2
3
4
x
-5
-4
-3
-2
-1
1
2
3
g(x)
-3
-2
-1
1
2
3
x
-5
-4
-3
-2
-1
1
2
f(x)
Worked Solution
Create a strategy

Finding (f\circ g)\left(1\right) can also be written as f(g(1)). To evaluate this composite function using graphs, we must first evaluate the inner function, g(1). The result of that will become the input for the outer function, f(x).

Apply the idea
-3
-2
-1
1
2
3
4
x
-5
-4
-3
-2
-1
1
2
3
g(x)

To find f(g(1)) we must first evaluate the inner function, g(1), using the graph of g\left(x\right).

When x=1, the output is 2.g\left(1\right)=2

-3
-2
-1
1
2
3
x
-5
-4
-3
-2
-1
1
2
f(x)

The input of f(x) is the output of g(1), which we found to be 2. This means we need to use the graph of f\left(x\right) to find the y-value when x=2.

When x=2, the output is 0.

Therefore, (f\circ g)\left(1\right)=0

Example 5

A cylindrical tank initially contains 200 \text{ in}^3 of grain and starts being filled at a constant rate of 40 \text{ in}^3 per second.

The radius of the tank is 12 inches. Let g be the amount of grain in the container after t seconds.

a

State the function for h\left(g\right), the height of the grain in the container, in terms of g.

Worked Solution
Create a strategy

As the tank fills with grain, the amount of grain takes the shape of a cylinder which has a volume given by V=\pi r^2h.

We know that:

  • g represents the volume of grain

  • h\left(g\right) represents the height of the grain in terms of g

  • r is given to be 12 inches

Substituting these values into the volume of a cylinder, V=\pi r^2h, we can form an equation relating g and h\left(g\right).

Apply the idea
\displaystyle V\displaystyle =\displaystyle \pi r^2 hVolume of a cylinder
\displaystyle g\displaystyle =\displaystyle \pi \left(12\right)^2 \cdot h\left(g\right)Substituting V=g, r=12, and h=h\left(g\right)
\displaystyle g\displaystyle =\displaystyle 144 \pi \cdot h\left(g\right)Evaluating the square
\displaystyle \dfrac{g}{144\pi}\displaystyle =\displaystyle h\left(g\right)Divide both sides by 144\pi
\displaystyle h\left(g\right)\displaystyle =\displaystyle \dfrac{g}{144\pi}Symmetric property of equality

The function h\left(g\right)=\dfrac{g}{144\pi} represents the height of the grain in the container, in terms of the volume of grain g.

b

State the function for g\left(t\right), the amount of grain in the tank after t seconds.

Worked Solution
Create a strategy

We know that initially, t=0, there are 200 \text{ in}^3 of grain in the tank. Each second that passes, 40 \text{ in}^3 is added.

Apply the idea
t0123
g\left(t\right)200240280320

Creating a table of values, we can see that we have a linear equation where the amount of grain is equal to 200 plus 40 for every second that passes.

The function g\left(t\right)=40t+200

c

The function A\left(t\right) is defined as A\left(t\right)=\left( h \circ g \right)\left(t\right). Form an equation for A\left(t\right) in terms of t.

Worked Solution
Create a strategy

\left(h \circ g\right)\left(t\right) is the same as h\left(g\left(t\right)\right), so want to substitute g\left(t\right)=40t+200 into the function h\left(g\right)=\dfrac{g}{144\pi}.

Apply the idea
\displaystyle A\left(t\right)\displaystyle =\displaystyle \left( h \circ g \right)\left(t\right)
\displaystyle =\displaystyle h\left(g\left(t\right)\right)Definition of \left( h \circ g \right)\left(t\right)
\displaystyle =\displaystyle h\left(40t+200\right)Substitute g\left(t\right)
\displaystyle =\displaystyle \dfrac{40t+200}{144\pi}Substitute h\left(g\right)
\displaystyle =\displaystyle \dfrac{5t+25}{18\pi}Simplifying the quotient
Reflect and check

In the working above we substituted g\left(t\right)=40t+200 into the function for h. We can also obtain the same answer by first substituting h\left(g\right)=\dfrac{g}{144\pi} into h\left(g\left(t\right)\right):

\displaystyle A\left(t\right)\displaystyle =\displaystyle h\left(g\left(t\right)\right)
\displaystyle =\displaystyle \dfrac{g\left(t\right)}{144\pi}Substitute h\left(g\right)
\displaystyle =\displaystyle \dfrac{40t+200}{144\pi}Substitute g\left(t\right)
\displaystyle =\displaystyle \dfrac{5t+25}{18\pi}Simplifying the quotient
d

Explain what A\left(t \right) represents.

Worked Solution
Create a strategy

g\left(t\right) represents the amount of grain in the container after t seconds, and h\left(g\right) represents the height of grain in terms of the amount of grain. Composing the two gives us \left(h \circ g\right)\left(t\right). This represents height as a function of time.

Apply the idea

A\left(t \right) represents the height of the grain in the container, in inches, after t seconds.

e

If the barrel can hold 10\,000 \text{ in}^3 of grain, determine the domains of g\left(t\right), h\left(g\right) and A\left(t\right).

Worked Solution
Create a strategy

The lower boundary of the domain of g\left(t\right) is 0 as the time starts at 0 seconds. This means the lower boundary of the domain of A\left(t\right) is also 0 seconds.

To calculate the upper boundaries, we can use the fact that the barrel can hold a maximum of 10\, 000 \text{ in}^3 of grain. The time it takes to fill the barrel will be the upper boundary of both g\left(t\right) and A\left(t\right).

As g is the input for h\left(g\right), the range of g\left(t\right) will be the domain of h\left(g\right). So, the lower boundary of h\left(g\right) will be the amount of grain in the barrel initially, and the upper amount will be the maximum amount of grain the barrel can hold.

Apply the idea

The lower boundary of h\left(g\right) is 200 \text{ in}^3 as this is how much is in the barrel initially, and the upper boundary is 10\, 000 \text{ in}^3 as this is the maximum amount of grain the barrel can hold.

Calculating the total amount of time needed to fill the barrel:

\displaystyle g\left(t\right)\displaystyle =\displaystyle 40t+200
\displaystyle 10\,000\displaystyle =\displaystyle 40t+200Substitute g\left(t\right)=10\,000
\displaystyle 9800\displaystyle =\displaystyle 40tSubtract 200 from both sides
\displaystyle 245\displaystyle =\displaystyle tDivide both sides by 40

This means the barrel will be completely full after 245 seconds. The domain of both g\left(t\right) and A\left(t\right) is \left[0, 245 \right].

  • Domain of g\left(t\right): \left[0, 245\right]
  • Domain of h\left(g\right): \left[200, 10\,000\right]
  • Domain of A\left(t\right): \left[0, 245\right]
Idea summary

In a composition of functions, the inner function is evaluated first, followed by the outer function.\left(f \circ g\right)\left(x\right)= f\left(g\left(x\right)\right)

\left(g \circ f\right)\left(x\right)= g\left(f\left(x\right)\right)

Outcomes

A2.F.2

The student will investigate and analyze characteristics of square root, cube root, rational, polynomial, exponential, logarithmic, and piecewise-defined functions algebraically and graphically.

A2.F.2f

For any value, x, in the domain of f, determine f(x) using a graph or equation. Explain the meaning of x and f(x) in context, where applicable.

A2.F.2k

Determine the composition of two functions algebraically and graphically.

What is Mathspace

About Mathspace