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.25.
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{.}\)”
Checkpoint7.26.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
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)).
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.27 we motivate the composition of functions and give examples.
Evaluating composite functions is not more difficult than evaluating functions.
Example7.28.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 \(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
To find the grade of a student, we first need to look up the student’s identification number in the table from Figure 7.4 and then with the identification number look up the grade in the table from Figure 7.4.
So to find Alice’s grade we first look up her identification number in Figure 7.4 and find that it is \(1001\text{.}\) From Figure 7.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
We have \(g(0)=0\text{.}\) Thus \(f(g(0)) = f(0) = 2\text{.}\)
We have \(g(1)=0\text{.}\) Thus \(f(g(1)) = f(0) = 2\text{.}\)
Example7.31.Composite of two functions algebraic.
Let \(s:\N\to\N\) be given by \(s(n):=n^2\) as in Example 7.10, and let \(m:\N\to \Z_5\) be given by \(m(a):=a\fmod 5\) as in Example 7.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.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{.}\)
Example7.32.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
So the functions \(g\circ f\) and \(f\circ g\) are not equal.
Problem7.34.Do \(h\circ g\) and \(g\circ h\) exits ?
Consider the two functions
\begin{align*}
g:\amp \{-1,0,1\}\to \{0,1,2\} \text{ given by } g(x) := x^2, \text{ and }\\
h:\amp \{0,1,2\}\to \{2,3,4\} \text{ given by } h(y) := y+2\text{.}
\end{align*}
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{.}\)
Solution.
\(\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: