The Composition of Two Functions

# The Composition of Two Functions

On the Injective, Surjective, and Bijective Functions page we recalled the definition of a general function and looked at three types of special functions. We will now look at another type of function that can be obtained by composing two compatible functions.

 Definition: Let $f : A \to B$ and $g : B \to C$. The Composition of $f$ and $g$ is the function $g \circ f : A \to C$ defined for all $x \in A$ by $(g \circ f)(x) = g(f(x))$.

For $g \circ f$ to properly be defined we must have that the codomain of $f$ be the same as the domain of $g$. Also, it is important to notice the order. The composition of $f$ and $g$ will be $g \circ f$ while the composition of $g$ and $f$ will be $f \circ g$.

For example, consider the functions $f : \mathbb{R} \to \mathbb{R}$ and $g : \mathbb{R} \to \mathbb{R}$ defined by $f(x) = x + 4$ and $g(x) = x^2$. Then:

(1)
\begin{align} \quad (g \circ f)(x) = g(f(x)) = g(x + 4) = (x + 4)^2 \end{align}

We can also look at the composition of $g$ and $f$ which is:

(2)
\begin{align} \quad (f \circ g)(x) = f(g(x)) = f(x^2) = x^2 + 4 \end{align}

In general, if $g \circ f$ and $f \circ g$ are well defined, then $g \circ f$ need not equal $f \circ g$.

We will now look at some interesting results regarding the composition of two functions.

 Theorem 1 (The Associativity of $\circ$): Let $f, g, h : A \to A$. Then $f \circ (g \circ h) = (f \circ g) \circ h$.
• Proof: Let $f, g, h : A \to A$. Then for all $x \in A$ we have that:
(3)
\begin{align} \quad [f \circ (g \circ h)](x) = f((g \circ h)(x)) = f(g(h(x))) = (f \circ g)(h(x)) = [(f \circ g) \circ h](x) \end{align}
• Therefore $f \circ (g \circ h) = (f \circ g) \circ h$. $\blacksquare$
 Theorem 2: Let $f : A \to B$ and $g : B \to C$ both be injective functions. Then $g \circ f : A \to C$ is an injective function.
• Proof: Let $f : A \to B$ and $g : B \to C$ both be injective functions, and consider the function $g \circ f : A \to C$. Suppose that $(g \circ f)(x) = (g \circ f)(y)$. Then:
(4)
\begin{align} \quad (g \circ f)(x) = (g \circ f)(y) \\ \quad g(f(x)) = g(f(y)) \end{align}
• Since $g$ is injective we have that $f(x) = f(y)$, and since $f$ is injective we have that $x = y$. Therefore $g \circ f$ is injective. $\blacksquare$
 Theorem 3: Let $f : A \to B$ and $g : B \to C$ both be surjective functions. Then $g \circ f : A \to C$ is a surjective function.
• Proof: Let $f : A \to B$ and $g : B \to C$ both be surjective functions, and consider the function $g \circ f : A \to C$. Let $y \in C$ and consider $(g \circ f)(x) = y$.
• Since $g$ is surjective there exists a $b \in B$ such that $g(b) = y$, and since $f$ is surjective there exists an $x \in A$ such that $f(x) = b$. Therefore:
(5)
\begin{align} \quad y = g(b) = g(f(x)) \end{align}
• Therefore $g \circ f$ is surjective. $\blacksquare$
 Corollary 1: Let $f : A \to B$ and $g : B \to C$ both be bijective functions. Then $g \circ f: A \to C$ is a bijective function.
• Proof: Since $f$ and $g$ are both bijective, we have that they are both injective and surjective by definition. By Theorem 1 and Theorem 2 we have that then $g \circ f$ is both injective and surjective and hence bijective. $\blacksquare$