Virginia SOL Algebra 2 - 2020 Edition
topic badge
1.06 Composition of functions
Lesson

The idea behind the composition of functions is best explained with an example.

Suppose we think about the function given by $f\left(x\right)=2x+1$f(x)=2x+1. We understand that the function takes values of $x$x in the domain and maps them to values, say $y=2x+1$y=2x+1, in the range.

Suppose however that this is only the first part of a two-stage treatment of $x$x. Suppose we now take these function values and map them using another function, say $g\left(x\right)=x^2$g(x)=x2. This means that the $y$y values given by $\left(2x+1\right)$(2x+1) become the squared values $\left(2x+1\right)^2$(2x+1)2. The diagram below captures the idea.

The function values $f\left(x\right)$f(x) have become the domain values of $g\left(x\right)$g(x). Thus we could describe the complete two-stage process by the expression $g\left(f\left(x\right)\right)$g(f(x)), sometimes written $g\left[f\left(x\right)\right]$g[f(x)] or $\left(g\circ f\right)\left(x\right)$(gf)(x) and spoken of as "$g$g of $f$f of $x$x" or the "gof" of $x$x

Algebraically, we can write $g\left(f\left(x\right)\right)=g\left[2x+1\right]=\left(2x+1\right)^2$g(f(x))=g[2x+1]=(2x+1)2

Note that if we reversed the order of the two-stage processing, we would, in this instance, develop a different composite function. 

Thus $f\left(g\left(x\right)\right)=f\left(x^2\right)=2\left(x^2\right)+1=2x^2+1$f(g(x))=f(x2)=2(x2)+1=2x2+1. This is known as the "fog" of $x$x.

Composition of functions

To find $f\left(g\left(x\right)\right)$f(g(x)) algebraically, we replace all instances of $x$x in $f(x)$f(x) with $g(x)$g(x).

Worked example

Question 1

If $f(x)=3x+2$f(x)=3x+2 and $g(x)=2x^2-3x+1$g(x)=2x23x+1, evaluate $f\left(g\left(x\right)\right)$f(g(x)) and $g\left(f\left(x\right)\right)$g(f(x)).

Think: To find the composition of a function we need to replace all of the "x"s in the outer function with the inner function.

Do: 

$f\left(g\left(x\right)\right)$f(g(x)) $=$= $3g(x)+2$3g(x)+2
  $=$= $3\left(2x^2-3x+1\right)+2$3(2x23x+1)+2
  $=$= $6x^2-9x+3+2$6x29x+3+2
  $=$= $6x^2-9x+5$6x29x+5
$g\left(f\left(x\right)\right)$g(f(x)) $=$= $2[f(x)]^2-3f(x)+1$2[f(x)]23f(x)+1
  $=$= $2\left(3x+2\right)^2-3\left(3x+2\right)+1$2(3x+2)23(3x+2)+1
  $=$= $2\left(9x^2+12x+4\right)-3\left(3x+2\right)+1$2(9x2+12x+4)3(3x+2)+1
  $=$= $18x^2+24x+8-9x-6+1$18x2+24x+89x6+1
  $=$= $18x^2+15x+3$18x2+15x+3

 

Practice questions

Question 2

Consider the functions $f\left(x\right)=-2x-3$f(x)=2x3 and $g\left(x\right)=-2x-6$g(x)=2x6.

  1. Find $f\left(7\right)$f(7).

  2. Hence, or otherwise, evaluate $g\left(f\left(7\right)\right)$g(f(7)).

  3. Now find $g\left(7\right)$g(7).

  4. Hence, evaluate $f\left(g\left(7\right)\right)$f(g(7)).

  5. Is it true that $f\left(g\left(x\right)\right)=g\left(f\left(x\right)\right)$f(g(x))=g(f(x)) for all $x$x?

    Yes

    A

    No

    B

    Yes

    A

    No

    B

Question 3

Consider the functions $f\left(x\right)=-2x+6$f(x)=2x+6 and $g\left(x\right)=3x+1$g(x)=3x+1.

  1. The function $r\left(x\right)$r(x) is defined as $r\left(x\right)=f\left(x^2\right)$r(x)=f(x2). Define $r\left(x\right)$r(x).

  2. Using the results of the previous part, define $q\left(x\right)$q(x), which is $g\left(f\left(x^2\right)\right)$g(f(x2)).

 

The domain of composite functions

One very important point needs to be made here in terms of the domain of composite functions.

If we consider, say $g\left(f\left(x\right)\right)$g(f(x)), then range of the function $f\left(x\right)$f(x) (which is the function applied first) must be a subset of the domain of the function $g\left(x\right)$g(x) (the function that is applied second).

That is to say, the domain of $g\left(f\left(x\right)\right)$g(f(x)) must only consist of elements that can be mapped by both $f\left(x\right)$f(x) and then by $g\left(x\right)$g(x) without causing an issue in either function. 

A similar situation applies for  $f\left(g\left(x\right)\right)$f(g(x)).

For example, if $f\left(x\right)=\sqrt{x}$f(x)=x and $g\left(x\right)=\frac{1}{x}$g(x)=1x, then both $f\left(g\left(x\right)\right)$f(g(x)) and $g\left(f\left(x\right)\right)$g(f(x)) have the restricted domain $x\in R^+$xR+. Lets explain why.

If we consider $g\left(f\left(x\right)\right)$g(f(x)), the range of $f\left(x\right)$f(x) includes non-negative real numbers, but we can't use all of these in $g\left(x\right)$g(x). The number zero needs to be deleted.

If we consider $f\left(g\left(x\right)\right)$f(g(x)), the range of $g\left(x\right)$g(x) includes all real numbers other than zero, but only positive reals can be considered for $f\left(x\right)$f(x)

Taking this last example, we have $f\left(g\left(x\right)\right)=f\left(\frac{1}{x}\right)=\sqrt{\frac{1}{x}}=\frac{1}{\sqrt{x}}$f(g(x))=f(1x)=1x=1x and $g\left(f\left(x\right)\right)=g\left(\sqrt{x}\right)=\frac{1}{\sqrt{x}}$g(f(x))=g(x)=1x and so in this instance the fog and the gof are equal. 

The graph of the composition is shown here. Note that the composition is graphed for positive reals only.

 

Outcomes

AII.7k

Investigate and analyze linear, quadratic, absolute value, square root, cube root, rational, polynomial, exponential, and logarithmic function families algebraically and graphically for the concept of compostion of functions, algebraically and graphically

What is Mathspace

About Mathspace