Composite Functions
In some sense, a function $f: A \rightarrow B$ is a rule that takes each element in $A$, and assigns it some element in $B$. In other words, if we have some element $a \in A$, then $f$ will assign some element $b \in B$ to $a$. Suppose we also had some other function $g: B \rightarrow C$. Since $g$ assigns elements from $C$ to elements in $B$, we would be able to assign some element $c \in C$ to that element $b$ we got from using function $f$. What we’ve done is daisy-chain the outputs of functions $f$ and $g$ to assign to element $a \in A$ some element $c \in C$, even though we don’t explicitly have some other function that has domain $A$ and codomain $C$.
Just as we can combine real numbers together by adding or multiplying them, and like we can combine sets together using union and intersection, we can combine functions together using the daisy chaining concept to form a new function. In this section, we learn about function composition, the technical term for daisy chaining functions together.
An Example
Conceptually understanding how daisy-chaining functions together can be made a lot easier by examining an example using arrow diagrams.
Example 6.5.1
There are several large cities and towns scattered throughout the United States. Some are located further south, closer to the Equator, while others are located farther north. In general, the closer you get to the Equator (your latitude gets close to 0), the warmer the average temperature will be. The farther north (or south) you go (your latitude gets larger), the colder the average temperature will be.
One way to determine whether a city or town will generally have higher or lower temperatures is to look at their latitudes. Suppose we are interested in looking at the average temperatures of the towns Anchorage, Chicago, Denver, and Miami. Looking at a map of the United States, we may make the following arrow diagrams. Figure 6.5.1 Figure 6.5.2 Figure 6.5.3
Using arrow diagrams, we can simply follow the path laid out by the arrows at the left end of the diagram (the start) to the right end of the diagram (the end). By looking at what the start and end values, we can form a new function that cuts out all of the intermediate steps.
A Formal Definition of Function Composition
Just like any other function, a composite function has a domain and codomain, and every element in the domain must map exactly to one element of the codomain. With composite functions, there are intermediary sets that act as a middleman between the domain and codomain.
Composite Function
Consider the two arbitrary functions
$$f: A \rightarrow B$$$$g: B \rightarrow C$$The composite function $h: A \rightarrow C$ is the function where
$$\forall a \in A \bigl[h(a) = g(f(a))\bigr]$$Typically, we write
$$h = g \circ f$$to show that $h$ is the composite of $f$ and $g$, and we would write something like
\[ \begin{align*} h(x) &= [g \circ f](x) \\ &= g(f(x)) \end{align*} \]when we’re trying to evaluate the function for some $x \in \text{Dom}(h)$.
Let’s look at a small example to get more comfortable with the above notation.
Example 6.5.2
Consider the arrow diagram depicted below in Figure 6.5.4. Figure 6.5.4
The Domain, Codomain, and Range of Composite Functions
Based on the definition of composite functions, and the examples we’ve seen, it would seem that whatever set is used as the domain of the first function in the composition will also be the domain of the composite function itself. After all, whatever can be an input into the first function can also be put into the composite function.
We can make a similar observation for the domain of composite functions. As such, we immediately see that the following facts about composite functions are true by definition of composite functions:
\[ \begin{align*} \text{Dom}(g \circ f) &= \text{Dom}(f) \\ \text{Cod}(g \circ f) &= \text{Cod}(g) \end{align*} \]Can we make a similar observation about the range of a composite function?
Example 6.5.3
Consider the following arrow diagram showing two functions. Figure 6.5.5
As the previous example demonstrates, when some elements of the intermediate set are missed, then the range of the composite function may only contain some - but not all - elements of the range of the last function used in the composition.
Of course when the first function uses all elements of the intermediate set in its range, then we won’t have to worry about some elements being left out of the composite’s range. In other words, when the first function is surjective, then we expect the range of the composite to be equal to the range of the last function used in the composition.
Theorem 6.5.1
Suppose for arbitrary sets $\text{A}$, $\text{B}$, and $\text{C}$, and for arbitrary functions
\[ \begin{align*} f: \text{A} \rightarrow \text{B} \\ g: \text{B} \rightarrow \text{C} \end{align*} \]If $f$ is surjective, then we have that
$$\text{Rng}(g \circ f) = \text{Rng}(g)$$Multiple functions
We used the analogy of daisy-chaining to convey the idea of function composition. The analogy continues by acknowledging that in theory, daisy chains can extend beyond two, three, four, or more components.
Likewise, we can have any number of functions composed together with any number of sets. For example, we could compose three functions together:
\[ \begin{align*} f: \text{A} \rightarrow \text{B} \\ g: \text{B} \rightarrow \text{C} \\ h: \text{C} \rightarrow \text{D} \end{align*} \]With these three functions, we could form the composite function $j$ like so:
$$j: \text{A} \rightarrow \text{D};\ j(x) = [h \circ g \circ f](x),\ x \in \text{A}$$Example 6.5.4
Let's take a look at the following four functions:
\[
\begin{align*}
f: \text{A} \rightarrow \text{B} \\
g: \text{B} \rightarrow \text{C} \\
h: \text{C} \rightarrow \text{D} \\
j: \text{D} \rightarrow \text{E} \\
\end{align*}
\]
where we have that
\[
\begin{align*}
\text{A} &= \{\text{m}, \text{o}, \text{s}\} \\
\text{B} &= \{\text{a}, \text{n}, \text{w}\} \\
\text{C} &= \{\text{a}, \text{g}, \text{i}\} \\
\text{D} &= \{\text{i}, \text{m}, \text{o}\} \\
\text{E} &= \{\text{c}, \text{n}, \text{p}\} \\
\end{align*}
\]
Suppose the functions were defined as depicted in the following arrow diagram: Figure 6.5.6