5.3 Composition of Functions

We often want to look at how two functions work together.

Example 5.1 Suppose that oil is spilled from a ruptured tanker and spreads in a circular pattern. If the oil is leaving the tanker at a rate of 70 gallons an hour, then what is the radius of the \(1\) cm thick oil slick after \(t\) hours?

In order to find a solution to this word problem (note that this is not really a modeling problem), we will create some functions that we will compose together. We will start by letting \(g\) be the rate in gallons per hour that oil is leaking out of the boat.

Let \(T(g)=\frac{1}{264.172} g\) be the cubic meters equivalent to \(g\) gallons.

Let \(r(V)= \sqrt{\frac{100V}{\pi}}\) be the radius (in meters) of an oil slick with volume \(V\) (in cubic meters) that is \(1\) cm thick.

Then \(r(V(T(g)\cdot t))\) gives us the radius of the oil slick after \(t\) hours.

Using this motivation, we will give a mathematical definition for the composition of functions.

Definition 5.5 Let \(f:A\rightarrow B\) and \(g: B \rightarrow C\) be functions. Then we define the function \((g\circ f):A\rightarrow C\) by \[(g\circ f) (a)= g(f(a)), \quad \mbox{ for all } a \in A.\]

Sketch of $f:A \rightarrow B$, $g:B \rightarrow C$, and $g \circ f: A \rightarrow C$

Figure 5.3: Sketch of \(f:A \rightarrow B\), \(g:B \rightarrow C\), and \(g \circ f: A \rightarrow C\)

The sketch in Figure 5.3 describes how the domains, ranges, and codomains of the three functions interact when describing function composition.

5.3.1 Inverse Functions

In addition to composing functions together, it is often useful to define a function that undoes another function. In the previous example, it is easiest to find the radius of the oil slick based on volume by first finding the volume as a function of the radius. In the case of a cylindrical cylinder, \(V(r)= \pi r^2 h\) and so \(r(V)=\sqrt{\frac{V}{\pi h}}\) is a function that undoes the volume. A more precise definition of these inverse functions is given below.

Definition 5.6 Let \(f:A \rightarrow B\) and \(g:B \rightarrow A\) be functions. If \[(g\circ f) (a)=a \mbox{ for all } a\in A \mbox{, and}\] \[(f\circ g) (b)=b \mbox{ for all }b\in B,\] then we say that \(f\) is invertible, or it has an inverse.

Note that in our example we define \(f:\mathbb{R}^+\rightarrow \mathbb{R}^+\) by \(f(r)= \pi r^2 h\) to be the volume function and \(g:\mathbb{R}^+\rightarrow \mathbb{R}^+\) by \(g(V)=\sqrt{\frac{V}{\pi h}}\) to be the radius function. Then for all \(r\in \mathbb{R}^+\), \[(g\circ f) (r) = g (f(r)) = g\left(\pi r^2 h\right) = \sqrt{ \frac{\left(\pi r^2 h\right)}{\pi h}} = \sqrt{r^2}=r\] and \[(f \circ g) (V) = f(g(V)) = f\left(\sqrt{\frac{V}{\pi h}}\right) = \pi \left(\sqrt{\frac{V}{\pi h}}\right)^2 h = V.\]

So \(g\circ f\) and \(f \circ g\) are each equal to the appropriate identity function and so are inverses of each other.

If instead, we define \(f:\mathbb{R}\rightarrow \mathbb{R}^+\) by \(f(x)=x^2\) and \(g:\mathbb{R^+} \rightarrow \mathbb{R}\) by \(g(y)=\sqrt{y}\), then \[(f\circ g) (y) =\left(\sqrt{y}\right)^2 =y, \: \forall y\in \mathbb{R}^+\] but \[(g\circ f)(x) = \sqrt{x^2} = |x|.\]

Since \(x\neq |x|\) for \(x<0\), we see that \(g\circ f\) is not the identity function on \(\mathbb{R}\). So \(f\) and \(g\) are not invertible.

The next theorem is useful to verify that if a function is invertible, then the inverse function is unique.

Theorem 5.1 If \(f:A \rightarrow B\) is invertible, the function \(g:B\rightarrow A\) satisfying the properties \[(g\circ f) (a)=a \mbox{ for all } a\in A \mbox{, and}\] \[(f\circ g) (b)=b \mbox{ for all }b\in B\] is unique and so we say that that \(g\) is the inverse function of \(f\). We then denote this inverse function as \(f^{-1}\).

Furthermore, we have that \(f^{-1}\) is invertible.

Proof. In order to prove the uniqueness of \(g\) we will give a proof by contradiction. So we assume that \(f:A\rightarrow B\) is an invertible function and that there are function \(g:B\rightarrow A\) and \(\tilde{g}:B\rightarrow A\) such that \[(g\circ f) (a)=a \mbox{ and } (\tilde{g}\circ f)(a) = a \mbox{ for all } a \in A \mbox{, and}\] \[(f\circ g)(b)=b \mbox{ and } (f\circ \tilde{g})(b)=b \mbox{ for all } b\in B.\]

Then for each \(b\in B\) we have that \[\begin{align*} \tilde{g}(b) &= \tilde{g}\left( (f\circ g)(b)\right) \quad (\mbox{since } (f\circ g)(b)=b \mbox{, for all } b \in B) \\ &= \tilde{g}\left(f(g(b))\right) = (\tilde{g} \circ f)(g(b)) \quad \mbox{ (by the definition of function composition)} \\ &= g(b) \: (\mbox{since } \quad (\tilde{g}\circ f)(a)=a \mbox{, for all } a\in A). \end{align*}\]

Since \(g\) and \(\tilde{g}\) have the same output for each input, they are the same function. Therefore, the inverse function of \(f\) is unique.

Now that we have the uniqueness of inverse functions when a function is invertible, it would be helpful to further understand the properties of a function that make it invertible without having to find the inverse. This will save time looking for an inverse that doesn’t exist and help us to adjust a function to make it invertible by restricting the domain and/or co-domain of the function.

Theorem 5.2 The function \(f:A \rightarrow B\) is invertible if and only if it is a bijection.

Proof. Since this statement is an ‘if and only if’ statement we must prove both implications.

  • Invertible implies bijection. Assume that the function \(f:A \rightarrow B\) is invertible. Then there exists a unique \(f^{-1}:B\rightarrow A\) such that \((f\circ f^{-1})(b)=b\) for all \(b\in B\) and \((f^{-1}\circ f)(a)=a\) for all \(a\in A\).

    To prove that \(f\) is an injection (one-to-one), we assume that there are elements \(a_1, a_2\in A\) such that \(f(a_1)=f(a_2)\) as an element of \(B\). Since \(f^{-1}\) is a function from \(B\) to \(A\), we know that \(f^{-1}(f(a_1))=f^{-1}(f(a_2))\). From the definitions of function composition and inverse function, this implies that \[a_1 = (f^{-1}\circ f)(a_1)= f^{-1}(f(a_1))=f^{-1}(f(a_2))= (f^{-1}\circ f)(a_2)=a_2\] and so \(a_1=a_2\) proving that \(f\) is an injection.

    To prove that \(f\) is a surjection (onto) we choose a generic element of the co-domain of \(f\) and prove that it is in the range of \(f\). Let \(b\in B\) be that generic element of the co-domain of \(f\). Since \[b = (f\circ f^{-1})(b) = f(f^{-1}(b))\] we see that \(b\) is the image of \(f\) acting on \(f^{-1}(b) \in A\) and so is in the range of \(f\). Therefore, \(f\) is a bijection.

  • Bijection implies invertible. On the other hand, if we assume that \(f:A\rightarrow B\) is a bijection, we can define a function \(g: B \rightarrow A\) in the following way.

    Since \(f\) is a surjection, for each \(b\in B\) there is at least one element \(a\in A\) such that \(b=f(a)\). Since \(f\) is an injection, this element is unique, and we will call the element \(a_b\). Thus we can define \(g:B\rightarrow A\) by \(g(b)=a_b\) and this relation satisfies the definition of a function.

    We can also see from this definition of \(g\) that \((f\circ g)(b)=f(g(b))=f(a_b)=b\) for all \(b\in B\).

    Furthermore, for all \(a\in A\), \((g \circ f)(a) = g(f(a))=a\), thereby making \(f\) invertible.

This means that this concept of bijections is one that is very important in terms of the composition of functions. In particular it is important to understand what properties the composition of two bijections would have. This leads to the following theorem.

Theorem 5.3 Let \(f:A \rightarrow B\) and \(g:B \rightarrow C\) be two bijections. Then the function \(g\circ f : A \rightarrow C\) is also a bijection.

Proof. Let \(f:A \rightarrow B\) and \(g:B\rightarrow C\) be bijections.

We will first prove that \((g\circ f):A\rightarrow C\) is an injection.

Let \(a_1\) and \(a_2\) be elements of \(A\) such that \[(g\circ f)(a_1)=(g\circ f)(a_2).\] From the definition of the composition of functions this implies that \[g\left( f(a_1)\right) = g\left(f(a_2)\right).\] Since \(g\) is an injection on \(B\), we know that \(f(a_1)=f(a_2)\). Since \(f\) is an injection, this implies that \(a_1=a_2\) and thus proving that \(g\circ f\) is an injection.

We will now prove that \((g\circ f):A\rightarrow C\) is a surjection.

Let \(c\) be a generic element of \(C\). Since \(g:B\rightarrow C\) is onto, there exists an element \(b_c\in B\) such that \(g(b_c)=c\). Since \(f:A \rightarrow B\) is onto, there exists an element \(a_{b_c}\in A\) such that \(f\left(a_{b_c}\right) = b_c\). We then have that \[c=g(b_c)=g\left( f\left(a_{b_c}\right) \right) = (g \circ f) \left( a_{b_c}\right)\] and so \(g\circ f\) is a surjection.

Therefore, \((g\circ f):A \rightarrow C\) is a bijection.

Note: In the proof that \((g\circ f):A \rightarrow C\) is an injection, the only assumptions used are that \(f\) and \(g\) are both injections, and the only sets referenced are the domains of the functions. This signifies that the property of a function being one-to-one is a property that focuses on the domain of the function and is independent of the co-domain defined for the function. Hence, one could enlarge the co-domain of an injective function to a new function that is also an injection.

Similarly, the surjective property of the composition of the functions depends only on the surjective properties of the individual functions. However, unlike the injective property, the surjective property involves a heavy reliance upon both the domain and co-domain of the function. While one could expand the domain to a larger set while maintaining the surjective nature of the function, one may not be able to reduce the size of the domain.

Since the composition of bijections is also a bijection, we know from Theorem 5.2 that the composition of a bijection is also invertible. Combining the results of these theorems we have the following theorem.

Theorem 5.4 Let \(f:A\rightarrow B\) and \(g:B\rightarrow C\) be bijections. Then we have the following:

  • \(f\) is invertible with inverse \(f^{-1}:B\rightarrow A\)

  • \(g\) is invertible with inverse \(g^{-1}:C\rightarrow B\)

  • \(g\circ f\) is invertible with inverse \((g\circ f)^{-1}:C\rightarrow A\)

  • \((g\circ f)^{-1} = f^{-1} \circ g^{-1}\)

We can illustrate this theorem with Figure 5.4.

Composition of Bijections

Figure 5.4: Composition of Bijections

5.3.2 Exercises

  1. Let \(f:A \rightarrow B\) and \(g:B \rightarrow C\) be functions. Prove that if \(g\circ f : A \rightarrow C\) is a bijection that \(f\) must be an injection and \(g\) must be a surjection.

  2. What adjustments can be made to the domain and/or the co-domain of \(f:\mathbb{R}\rightarrow \mathbb{R}\) defined by \(f(x)=x^2\) in order to make it an invertible function.

  3. Let \(f:A\rightarrow B\) and \(g:B\rightarrow C\) be functions.

    1. What properties hold for \(g\circ f\) if both \(f\) and \(g\) are injections?

    2. What properties hold for \(g\circ f\) if both \(f\) and \(g\) are surjections?

    3. What properties hold for \(g\circ f\) if \(f\) is an injection and \(g\) is a surjection?

    4. What properties hold for \(g\circ f\) if \(f\) is a surjection and \(g\) in an injection?