1.3.5: Composition of Functions
We saw in section 3.4 that the inverse \(f^{-1}\) of a bijection \(f\) is itself a function. Another operation on functions is composition: we can define a new function by composing two functions, \(f\) and \(g\) , i.e., by first applying \(f\) and then \(g\) . Of course, this is only possible if the ranges and domains match, i.e., the range of \(f\) must be a subset of the domain of \(g\) . This operation on functions is the analogue of the operation of relative product on relations from section 2.7 .
A diagram might help to explain the idea of composition. In Figure \(\PageIndex{1}\), we depict two functions \(f \colon A \to B\) and \(g \colon B \to C\) and their composition \((\comp{f}{g})\) . The function \((\comp{f}{g}) \colon A \to C\) pairs each element of \(A\) with an element of \(C\) . We specify which element of \(C\) an element of \(A\) is paired with as follows: given an input \(x \in A\) , first apply the function \(f\) to \(x\) , which will output some \(f(x) = y \in B\) , then apply the function \(g\) to \(y\) , which will output some \(g(f(x)) = g(y) = z \in C\) .
Let \(f\colon A \to B\) and \(g\colon B \to C\) be functions. The composition of \(f\) with \(g\) is \(\comp{f}{g} \colon A \to C\) , where \((\comp{f}{g})(x) = g(f(x))\) .
Consider the functions \(f(x) = x + 1\) , and \(g(x) = 2x\) . Since \((\comp{f}{g})(x) = g(f(x))\) , for each input \(x\) you must first take its successor, then multiply the result by two. So their composition is given by \((\comp{f}{g})(x) = 2(x+1)\) .
Show that if \(f \colon A \to B\) and \(g \colon B \to C\) are both injective, then \(\comp{f}{g}\colon A \to C\) is injective.
Show that if \(f \colon A \to B\) and \(g \colon B \to C\) are both surjective, then \(\comp{f}{g}\colon A \to C\) is surjective.
Suppose \(f \colon A \to B\) and \(g \colon B \to C\) . Show that the graph of \(\comp{f}{g}\) is \(R_f \mid R_g\) .