## Section7.3Composite Functions

We combine two functions to get a new function by using function composition. Given two functions $$f$$ and $$g$$ we create a new function such that the image of $$a$$ in the domain of $$f$$ is $$g(f(a))\text{.}$$ To compute $$g(f(a))$$ we first apply $$f$$ to determine $$f(a)\text{,}$$ and then apply $$g$$ to the result. This is only works if $$f(a)$$ is in the domain of $$g\text{.}$$

### Definition7.3.1.

Let $$f \colon A \to B\text{,}$$ and let $$g \colon B \to C\text{.}$$ The composite function $$g \circ f\text{,}$$ is the function $$g \circ f \colon A \to C$$ defined by

\begin{equation*} (g \circ f)(x) = g(f(x))\text{.} \end{equation*}

We read $$g\circ f$$ as “the composite of (the functions) $$g$$ and $$f\text{.}$$” We read $$(g\circ f)(x)$$ as “the composite of $$g$$ and $$f$$ of $$x$$” or as “$$g$$ of $$f$$ of $$x\text{.}$$

Complete the definitions:

Let f : B $$\rightarrow$$ C and g : A $$\rightarrow$$ B be functions. The

• select

• subset

• identity

• inverse

• composite

of f and g, written f$$\circ$$g, is the function f$$\circ$$g :
• select

• A

• B

• C

$$\rightarrow$$
• select

• A

• B

• C

defined by f$$\circ$$g(x) = f(g(x)).

$$\text{composite}$$

$$\text{A}$$

$$\text{C}$$

We can soften the conditions on the domain and codomain of $$f$$ and $$g$$ by only requiring that the codomain of $$f$$ is a subset of the domain of $$g\text{.}$$

In the video in Figure 7.3.3 we motivate the composition of functions and give examples.

Evaluating composite functions is not more difficult than evaluating functions.

Let $$f:\{1,2,3,4,5\}\to\Z$$ be given by $$f(x)=3\cdot x$$ and $$g:\Z\to\Z$$ be given by $$g(x)=x+2\text{.}$$

Let $$h:=g\circ f$$ be the composite of $$f$$ and $$g\text{.}$$ The domain of $$g\circ f$$ is the domain of $$f$$ namely $$\{1,2,3,4,5\}$$ and the codomain of $$g\circ f$$ is $$\Z$$ which is the codomain of $$g\text{,}$$ in short:

\begin{equation*} g\circ f:\{1,2,3,4,5\}\to \Z. \end{equation*}

We evaluate $$h$$ at several integers.

First we compute $$h(5)\text{.}$$ By the definition of $$h$$ as the composite of $$f$$ and $$g$$ we have

\begin{equation*} h(5)=(g\circ f)(5)=g(f(5)). \end{equation*}

We evaluate $$g(f(5))$$ from the inside out. First we use the definition of $$f$$ to find $$f(5)=3\cdot 5=15\text{.}$$ Then we evaluate $$g$$ at the result of this computation, namely 15. We get

\begin{equation*} h(5)=(g\circ f)(5)=g(f(5))=g(15)=15+2=17 \end{equation*}

Similarly we get

\begin{align*} h(1)\amp=(g\circ f)(1)=g(f(1))=g(3\cdot 1)=g(3)=3+2=5\\ h(2)\amp=(g\circ f)(2)=g(f(2))=g(3\cdot 2)=g(6)=6+2=8\\ h(3)\amp=(g\circ f)(3)=g(f(3))=g(3\cdot 3)=g(9)=9+2=11\\ h(4)\amp=(g\circ f)(4)=g(f(4))=g(3\cdot 4)=g(12)=12+2=14 \end{align*}

We use the functions

\begin{equation*} \mathrm{studentid} \colon N \to I \end{equation*}

and

\begin{equation*} \mathrm{grade} \colon I \to G \end{equation*}

from Example 7.1.5 and Example 7.1.7 given by the tables in Figure 7.1.4 and Figure 7.1.6 respectively.

To find the grade of a student, we first need to look up the student's identification number in the table from Figure 7.1.4 and then with the identification number look up the grade in the table from Figure 7.1.4.

So to find Alice's grade we first look up her identification number in Figure 7.1.4 and find that it is $$1001\text{.}$$ From Figure 7.1.6 we get that the grade of the student with identification number $$1001$$ is a $$\mathsf{B}\text{.}$$ Thus Alice's grade in MAT 112 is a $$\mathsf{B}\text{.}$$

Now we formulate this process in terms of function composition The composite function

given a student's name yields the student's grade. The domain of $$\mathrm{grade} \circ\mathrm{studentid}$$ is the set

\begin{equation*} N=\{\mathsf{Aaron},\mathsf{Alice},\mathsf{Bob},\mathsf{Eve},\mathsf{James},\mathsf{Nathan},\mathsf{Oscar},\mathsf{Sandi}\} \end{equation*}

of student names and the codomain of $$\mathrm{grade} \circ\mathrm{studentid}$$ is the set

\begin{equation*} G=\{\mathsf{A},\mathsf{B},\mathsf{C},\mathsf{D},\mathsf{F}\} \end{equation*}

In Figure 7.3.9, we give an example of the composite of two functions that are given by a diagram.

Consider the two functions

$$f:\mathbb{Z}_{4}\to \mathbb{Z}_{3}\text{,}$$ $$f(x)=(2)\bmod 3$$

and

$$g:\mathbb{Z}\to \mathbb{Z}_{4}\text{,}$$ $$g(x)=(0)\bmod 4\text{.}$$

Evaluate:

$$g(0) =$$ $$f(g(0)) =$$

$$g(1) =$$ $$f(g(1)) =$$

$$g(2) =$$ $$f(g(2)) =$$

$$g(3) =$$ $$f(g(3)) =$$

$$0$$

$$2$$

$$0$$

$$2$$

$$0$$

$$2$$

$$0$$

$$2$$

Let $$s:\N\to\N$$ be given by $$s(n):=n^2$$ as in Example 7.1.10, and let $$m:\N\to \Z_5$$ be given by $$m(a):=a\fmod 5$$ as in Example 7.1.11.

The composite function $$m\circ s$$ is a function from $$\N$$ to $$\Z_5\text{,}$$ and we have that $$(m\circ s)(n)=m\left(s(n)\right)=m(n^2)=n^2\fmod 5$$ for each $$n \in \N\text{.}$$ Notice that the algebraic rule for $$m\circ s$$ is the same as the algebraic rule for the function $$g$$ in Figure 7.1.9. However, $$m \circ s \neq g$$ since the domain of $$m \circ s$$ is $$\N$$ and the domain of $$g$$ is $$\Z_5\text{.}$$

The order in which the functions are composed matters, that is, there are functions $$f$$ and $$g$$ such that $$g \circ f \neq f \circ g\text{.}$$

We show that the order of the composition of function matters. Let $$f:\N\to \N$$ given by $$f(n):=2\cdot n$$ and $$g:\N\to\N$$ given by $$g(m):=m^2\text{.}$$ The domains of $$f$$ and $$g$$ allow us to form the composites $$g\circ f$$ and $$f\circ g\text{.}$$ To show that $$f\circ g$$ is not equal to $$g\circ f$$ we only need to find an $$b\in\N$$ with $$(g\circ f)(b)\ne (f\circ g)(b)\text{.}$$ For $$b=3$$ we have

\begin{equation*} (g\circ f)(3)=g(f(3))=g(2\cdot 3)=g(6)=6^2=36 \end{equation*}

and

\begin{equation*} (f\circ g)(3)=f(g(3))=f(3^2)=f(9)=2\cdot 9=18\text{,} \end{equation*}

So the functions $$g\circ f$$ and $$f\circ g$$ are not equal.

Consider the two functions

\begin{align*} g:\amp \{-1,0,1\}\to \{0,1,2\} \text{ given by } g(x) := x^2, \{ and }\\ h:\amp \{0,1,2\}\to \{2,3,4\} \text{ given by } h(y) := y+2\text{.} \end{align*}
1. Does the composite function $$h\circ g$$ exist? If yes, give $$(h\circ g)(x)$$ for all x in $$\{-1,0,1\}\text{.}$$

2. Does the composite function $$g\circ h$$ exist? If yes, specify $$(g\circ h)(x)$$ for all x in $$\{0,1,2\}\text{.}$$

Solution.

$$\qquad$$

1. The codomain of $$g$$ is equal to the domain of $$h\text{,}$$ so the composite $$h\circ g$$ exists. We specify $$h\circ g:\{-1,0,1\}\to \{2,3,4\}$$ by evaluating it at all elements of its domain. We have:

\begin{align*} (h\circ g)(-1)\amp =h(g(-1))=h(1)=3\\ (h\circ g)(0)\amp =h(g(0))=h(0)=2\\ (h\circ g)(1)\amp =h(g(1))=h(1)=3 \end{align*}
2. The codomain of $$h$$ is not equal to the domain of $$g\text{,}$$ so $$g\circ h$$ does not exist.

Consider the two functions

$$f:\mathbb{Z}_{4}\to \mathbb{Z}_{3}\text{,}$$ $$f(x)=(2)\bmod 3$$

and

$$g:\mathbb{Z}\to \mathbb{Z}_{4}\text{,}$$ $$g(x)=(0)\bmod 4\text{.}$$

Evaluate:

$$g(0) =$$ $$f(g(0)) =$$

$$g(1) =$$ $$f(g(1)) =$$

$$g(2) =$$ $$f(g(2)) =$$

$$g(3) =$$ $$f(g(3)) =$$

$$0$$

$$2$$

$$0$$

$$2$$

$$0$$

$$2$$
$$0$$
$$2$$