Section 7.3 Composite 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{.}\)
Definition 7.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
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{.}\)”
Checkpoint 7.3.2. Definition of the composite function.
Complete the definitions:
Let f : B \(\rightarrow\) C and g : A \(\rightarrow\) B be functions. The
select
subset
identity
inverse
composite
select
A
B
C
select
A
B
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.
Example 7.3.4. Evaluating the composite of two 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:
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
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
Similarly we get
Example 7.3.5. Composite of \(\mathrm{grade}\) and \(\mathrm{studentid}\).
We use the functions
and
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
of student names and the codomain of \(\mathrm{grade} \circ\mathrm{studentid}\) is the set
of grades. We get
In Figure 7.3.9, we give an example of the composite of two functions that are given by a diagram.
Checkpoint 7.3.6. Evaluate a composite function.
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)) =\)
Example 7.3.7. Composite of two functions algebraic.
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{.}\)
Example 7.3.8. Order of composition matters.
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
and
So the functions \(g\circ f\) and \(f\circ g\) are not equal.
Problem 7.3.10. Do \(h\circ g\) and \(g\circ h\) exits ?
Consider the two functions
Does the composite function \(h\circ g\) exist? If yes, give \((h\circ g)(x)\) for all x in \(\{-1,0,1\}\text{.}\)
Does the composite function \(g\circ h\) exist? If yes, specify \((g\circ h)(x)\) for all x in \(\{0,1,2\}\text{.}\)
\(\qquad\)
-
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*} The codomain of \(h\) is not equal to the domain of \(g\text{,}\) so \(g\circ h\) does not exist.
Checkpoint 7.3.11. Compose two functions.
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)) =\)