Skip to main content

Discrete Mathematical Structures

Subsection 2.3.7 Composition of functions

Definition 2.3.7.1.

Let \(f \colon A \to B\text{,}\) and let \(g \colon B \to C\text{.}\) The composition, denoted \(g \circ f\text{,}\) is the function \(g \circ f \colon A \to C\) defined by
\begin{equation*} (g \circ f)(x) = g(f(x)). \end{equation*}
Three sets A and B and C are represented each by an oval.  The ovals do not overlap. An arrow labeled f goes from A to B. An arrow labeled g goes from B to C. An arrow labeled the composition of g and f  goes from A to C.
Figure 2.3.7.2. Composition \(g \circ f\) of two functions \(f:A\to B\) and \(g:B\to C\text{.}\)
Three sets A and B and C are represented each by an oval.  The ovals do not overlap. Inside A are the numbers 1, 2, and 3. Inside B are the numbers 2, 3, and 4. Inside C are the numbers 0, 1, and 2. An arrow labeled f goes from 1 in A to to 3 in B. An arrow labeled f goes from 2 in A to to 4 in B. An arrow labeled f goes from 3 in A to to 4 in B. An arrow labeled g goes from 2 in B to to 0 in C. An arrow labeled g goes from 3 in B to to 1 in C. An arrow labeled g goes from 4 in B to to 2 in C. An arrow labeled the composition of g and f goes from 1 in A to to 1 in C. An arrow labeled the composition of g and f goes from 2 in A to to 2 in C. An arrow labeled the composition of g and f goes from 2 in A to to 2 in C.
Figure 2.3.7.3. Two functions \(f:A\to B\) and \(g:B\to C\) and their composition \(g \circ f\) where \(A=\{1,2,3\}\text{,}\) \(B=\{2,3,4\}\text{,}\) and \(C=\{0,1,2\}\text{.}\)

Example 2.3.7.4. Composition.

Let \(f(x) = x^2 + 2x - 1\) and \(g(x) = 3x - 5\) be functions from \(\RR\) to \(\RR\text{.}\)
Let’s compute some compositions. First, consider \(f \circ g\text{.}\)
\begin{align*} (f \circ g) (x) \amp = f(g(x)) \\ \amp = f(3x - 5) \\ \amp = (3x - 5)^2 + 2(3x - 5) - 1 \\ \amp = (9x^2 - 30x + 25) + (6x - 10) - 1 \\ \amp = 9x^2 - 24x + 14. \end{align*}
Next, let’s compose them in the opposite order.
\begin{align*} (g \circ f)(x) \amp = g(f(x)) \\ \amp =g(x^2 + 2x - 1) \\ \amp = 3(x^2 + 2x - 1) - 5 \\ \amp = (3x^2 + 6x - 3) - 5 \\ \amp = 3x^2 + 6x - 8. \end{align*}
Finally, let’s compose \(g\) with itself.
\begin{align*} (g \circ g) (x) \amp = g(g(x)) \\ \amp = g(3x - 5) \\ \amp = 3(3x - 5) - 5 \\ \amp = (9x - 15) - 5 \\ \amp = 9x - 20. \end{align*}

Definition 2.3.7.5.

Let \(A\) be a nonempty set. We call \(\id{A}:A\to A\) with \(\id{A}(x)=x\) the identity function on \(A\text{.}\)
It follows from Definition 2.3.6.7 and Definition 2.3.7.1 that for a bijective function \(f:A\to B\) and its inverse \(f^{-1}:B\to A\) that
\begin{equation*} f\circ f^{-1}= \id{B}\quad \text{ and }\quad f^{-1}\circ f=\id{A}. \end{equation*}