# 8.3: Compositions and Inverse Functions

$$\newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} }$$

$$\newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}}$$

$$\newcommand{\id}{\mathrm{id}}$$ $$\newcommand{\Span}{\mathrm{span}}$$

( \newcommand{\kernel}{\mathrm{null}\,}\) $$\newcommand{\range}{\mathrm{range}\,}$$

$$\newcommand{\RealPart}{\mathrm{Re}}$$ $$\newcommand{\ImaginaryPart}{\mathrm{Im}}$$

$$\newcommand{\Argument}{\mathrm{Arg}}$$ $$\newcommand{\norm}[1]{\| #1 \|}$$

$$\newcommand{\inner}[2]{\langle #1, #2 \rangle}$$

$$\newcommand{\Span}{\mathrm{span}}$$

$$\newcommand{\id}{\mathrm{id}}$$

$$\newcommand{\Span}{\mathrm{span}}$$

$$\newcommand{\kernel}{\mathrm{null}\,}$$

$$\newcommand{\range}{\mathrm{range}\,}$$

$$\newcommand{\RealPart}{\mathrm{Re}}$$

$$\newcommand{\ImaginaryPart}{\mathrm{Im}}$$

$$\newcommand{\Argument}{\mathrm{Arg}}$$

$$\newcommand{\norm}[1]{\| #1 \|}$$

$$\newcommand{\inner}[2]{\langle #1, #2 \rangle}$$

$$\newcommand{\Span}{\mathrm{span}}$$ $$\newcommand{\AA}{\unicode[.8,0]{x212B}}$$

$$\newcommand{\vectorA}[1]{\vec{#1}} % arrow$$

$$\newcommand{\vectorAt}[1]{\vec{\text{#1}}} % arrow$$

$$\newcommand{\vectorB}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} }$$

$$\newcommand{\vectorC}[1]{\textbf{#1}}$$

$$\newcommand{\vectorD}[1]{\overrightarrow{#1}}$$

$$\newcommand{\vectorDt}[1]{\overrightarrow{\text{#1}}}$$

$$\newcommand{\vectE}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash{\mathbf {#1}}}}$$

$$\newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} }$$

$$\newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}}$$

$$\newcommand{\avec}{\mathbf a}$$ $$\newcommand{\bvec}{\mathbf b}$$ $$\newcommand{\cvec}{\mathbf c}$$ $$\newcommand{\dvec}{\mathbf d}$$ $$\newcommand{\dtil}{\widetilde{\mathbf d}}$$ $$\newcommand{\evec}{\mathbf e}$$ $$\newcommand{\fvec}{\mathbf f}$$ $$\newcommand{\nvec}{\mathbf n}$$ $$\newcommand{\pvec}{\mathbf p}$$ $$\newcommand{\qvec}{\mathbf q}$$ $$\newcommand{\svec}{\mathbf s}$$ $$\newcommand{\tvec}{\mathbf t}$$ $$\newcommand{\uvec}{\mathbf u}$$ $$\newcommand{\vvec}{\mathbf v}$$ $$\newcommand{\wvec}{\mathbf w}$$ $$\newcommand{\xvec}{\mathbf x}$$ $$\newcommand{\yvec}{\mathbf y}$$ $$\newcommand{\zvec}{\mathbf z}$$ $$\newcommand{\rvec}{\mathbf r}$$ $$\newcommand{\mvec}{\mathbf m}$$ $$\newcommand{\zerovec}{\mathbf 0}$$ $$\newcommand{\onevec}{\mathbf 1}$$ $$\newcommand{\real}{\mathbb R}$$ $$\newcommand{\twovec}[2]{\left[\begin{array}{r}#1 \\ #2 \end{array}\right]}$$ $$\newcommand{\ctwovec}[2]{\left[\begin{array}{c}#1 \\ #2 \end{array}\right]}$$ $$\newcommand{\threevec}[3]{\left[\begin{array}{r}#1 \\ #2 \\ #3 \end{array}\right]}$$ $$\newcommand{\cthreevec}[3]{\left[\begin{array}{c}#1 \\ #2 \\ #3 \end{array}\right]}$$ $$\newcommand{\fourvec}[4]{\left[\begin{array}{r}#1 \\ #2 \\ #3 \\ #4 \end{array}\right]}$$ $$\newcommand{\cfourvec}[4]{\left[\begin{array}{c}#1 \\ #2 \\ #3 \\ #4 \end{array}\right]}$$ $$\newcommand{\fivevec}[5]{\left[\begin{array}{r}#1 \\ #2 \\ #3 \\ #4 \\ #5 \\ \end{array}\right]}$$ $$\newcommand{\cfivevec}[5]{\left[\begin{array}{c}#1 \\ #2 \\ #3 \\ #4 \\ #5 \\ \end{array}\right]}$$ $$\newcommand{\mattwo}[4]{\left[\begin{array}{rr}#1 \amp #2 \\ #3 \amp #4 \\ \end{array}\right]}$$ $$\newcommand{\laspan}[1]{\text{Span}\{#1\}}$$ $$\newcommand{\bcal}{\cal B}$$ $$\newcommand{\ccal}{\cal C}$$ $$\newcommand{\scal}{\cal S}$$ $$\newcommand{\wcal}{\cal W}$$ $$\newcommand{\ecal}{\cal E}$$ $$\newcommand{\coords}[2]{\left\{#1\right\}_{#2}}$$ $$\newcommand{\gray}[1]{\color{gray}{#1}}$$ $$\newcommand{\lgray}[1]{\color{lightgray}{#1}}$$ $$\newcommand{\rank}{\operatorname{rank}}$$ $$\newcommand{\row}{\text{Row}}$$ $$\newcommand{\col}{\text{Col}}$$ $$\renewcommand{\row}{\text{Row}}$$ $$\newcommand{\nul}{\text{Nul}}$$ $$\newcommand{\var}{\text{Var}}$$ $$\newcommand{\corr}{\text{corr}}$$ $$\newcommand{\len}[1]{\left|#1\right|}$$ $$\newcommand{\bbar}{\overline{\bvec}}$$ $$\newcommand{\bhat}{\widehat{\bvec}}$$ $$\newcommand{\bperp}{\bvec^\perp}$$ $$\newcommand{\xhat}{\widehat{\xvec}}$$ $$\newcommand{\vhat}{\widehat{\vvec}}$$ $$\newcommand{\uhat}{\widehat{\uvec}}$$ $$\newcommand{\what}{\widehat{\wvec}}$$ $$\newcommand{\Sighat}{\widehat{\Sigma}}$$ $$\newcommand{\lt}{<}$$ $$\newcommand{\gt}{>}$$ $$\newcommand{\amp}{&}$$ $$\definecolor{fillinmathshade}{gray}{0.9}$$

We begin this section with a method for combining two functions together that have compatible domains and codomains.

Definition 8.51. If $$f:X\to Y$$ and $$g:Y\to Z$$ are functions, we define $$g\circ f:X\to Z$$ via $$(g\circ f)(x)=g(f(x))$$. The function $$g\circ f$$ is called the composition of $$f$$ and $$g$$.

It is important to notice that the function on the right is the one that “goes first.” Moreover, we cannot compose any two random functions since the codomain of the first function must agree with the domain of the second function. In particular, $$f\circ g$$ may not be a sensible function even when $$g\circ f$$ exists. Figure 8.4 provides a visual representation of function composition in terms of function diagrams.

Problem 8.52. Let $$X=\{1,2,3,4\}$$ and define $$f:X\to X$$ and $$g:X\to X$$ via $f=\{(1,1),(2,3),(3,3),(4,4)\}$ and $g=\{(1,1),(2,2),(3,1),(4,1)\}.$ For each of the following functions, draw the corresponding function diagram in the spirit of Figure 8.4 and identify the range.

1. $$g\circ f$$
2. $$f\circ g$$

The previous problem illustrates that $$f\circ g$$ and $$g\circ f$$ need not be equal even when both composite functions exist.

Example 8.53. Consider the inclusion map $$\iota:X\to Y$$ such that $$X$$ is a proper subset of $$Y$$ and suppose $$f:Y\to Z$$ is a function. Then the composite function $$f\circ \iota:X\to Z$$ is given by $f\circ \iota(x)=f(\iota(x))=f(x)$ for all $$x\in X$$. Notice that $$f\circ \iota$$ is simply the function $$f$$ but with a smaller domain. In this case, we say that $$f\circ \iota$$ is the restriction of $$f$$ to $$X$$, which is often denoted by $$f|_X$$.

Problem 8.54. Define $$f:\mathbb{R}\to \mathbb{R}$$ and $$g:\mathbb{R}\to \mathbb{R}$$ via $$f(x)=x^2$$ and $$g(x)=3x-5$$, respectively. Determine formulas for the composite functions $$f\circ g$$ and $$g\circ f$$.

Problem 8.55. Define $$f:\mathbb{R}\to \mathbb{R}$$ and $$g:\mathbb{R}\to \mathbb{R}$$ via $f(x)=\begin{cases} 5x+7, & \text{if }x< 0\\ 2x+1, & \text{if }x\geq 0 \end{cases}$ and $$g(x)=7x-11$$, respectively. Find a formula for the composite function $$g\circ f$$.

Problem 8.56. Define $$f:\mathbb{Z}/15\mathbb{Z}\to \mathbb{Z}/23\mathbb{Z}$$ and $$g:\mathbb{Z}/23\mathbb{Z}\to \mathbb{Z}/32\mathbb{Z}$$ via $$f([x]_{15})=[3x+5]_{23}$$ and $$g([x]_{23})=[2x+1]_{32}$$, respectively. Find a formula for the composite function $$g\circ f$$.

The following result provides some insight into where the identity map got its name.

Theorem 8.57. If $$f:X\to Y$$ is a function, then $$f\circ i_X = f = i_Y\circ f$$, where $$i_X$$ and $$i_Y$$ are the identity maps on $$X$$ and $$Y$$, respectively.

The next theorem tells us that function composition is associative.

Theorem 8.58. If $$f:X\to Y$$, $$g:Y\to Z$$, and $$h:Z\to W$$ are functions, then $$(h\circ g)\circ f = h\circ (g\circ f)$$.

Problem 8.59. In each case, give examples of finite sets $$X$$, $$Y$$, and $$Z$$, and functions $$f:X\to Y$$ and $$g:Y\to Z$$ that satisfy the given conditions. Drawing a function diagram is sufficient.

1. $$f$$ is surjective, but $$g\circ f$$ is not surjective.
2. $$g$$ is surjective, but $$g\circ f$$ is not surjective.
3. $$f$$ is injective, but $$g\circ f$$ is not injective.
4. $$g$$ is injective, but $$g\circ f$$ is not injective.

Problem 8.60. If $$f:X\to Y$$ and $$g:Y\to Z$$ are both surjective functions, then $$g\circ f$$ is also surjective.

Theorem 8.61. If $$f:X\to Y$$ and $$g:Y\to Z$$ are both injective functions, then $$g\circ f$$ is also injective.

Corollary 8.62. If $$f:X\to Y$$ and $$g:Y\to Z$$ are both bijections, then $$g\circ f$$ is also a bijection.

Problem 8.63. Assume that $$f:X\to Y$$ and $$g:Y\to Z$$ are both functions. Determine whether each of the following statements is true or false. If a statement is true, prove it. Otherwise, provide a counterexample.

1. If $$g\circ f$$ is injective, then $$f$$ is injective.
2. If $$g\circ f$$ is injective, then $$g$$ is injective.
3. If $$g\circ f$$ is surjective, then $$f$$ is surjective.
4. If $$g\circ f$$ is surjective, then $$g$$ is surjective.

Theorem 8.64. Let $$f:X\to Y$$ be a function. Then $$f$$ is injective if and only if there exists a function $$g:Y\to X$$ such that $$g\circ f=i_X$$, where $$i_X$$ is the identity map on $$X$$.

The function $$g$$ in the previous theorem is often called a left inverse of $$f$$.

Theorem 8.65. Let $$f:X\to Y$$ be a function. Then $$f$$ is surjective if and only if there exists a function $$g:Y\to X$$ such that $$f\circ g=i_Y$$, where $$i_Y$$ is the identity map on $$Y$$.

The function $$g$$ in the previous theorem is often called a right inverse of $$f$$.

Problem 8.66. Let $$X=\{a,b\}$$ and $$Y=\{1,2\}$$.

1. Provide an example of a function that has a left inverse but does not have a right inverse. Find the left inverse of your proposed function.
2. Provide an example of a function that has a right inverse but does not have a left inverse. Find the right inverse of your proposed function.

Problem 8.67. Define $$f:\mathbb{R}\to\mathbb{R}$$ via $$f(x)=x^2$$. Explain why $$f$$ does not have a left inverse nor a right inverse.

Problem 8.68. Define $$f:\mathbb{R}\to[0,\infty)$$ via $$f(x)=x^2$$ and $$g:[0,\infty)\to \mathbb{R}$$ via $$g(x)=\sqrt{x}$$.

1. Explain why $$f$$ does not have a left inverse.
2. Verify that $$g$$ is the right inverse of $$f$$ by computing $$f\circ g(x)$$.

Corollary 8.69. If $$f:X\to Y$$ and $$g:Y\to X$$ are functions satisfying $$g\circ f=i_X$$ and $$f\circ g=i_Y$$, then $$f$$ is a bijection.

In the previous result, the functions $$f$$ and $$g$$ “cancel" each other out. In this case, we say that $$g$$ is a two-sided inverse of $$f$$.

Definition 8.70. Let $$f:X\to Y$$ be a function. The relation $$f^{-1}$$ from $$Y$$ to $$X$$, called $$f$$ inverse, is defined via $f^{-1}=\{(f(x),x)\in Y\times X\mid x\in X\}.$

Notice that we called $$f^{-1}$$ a relation and not a function. In some circumstances $$f^{-1}$$ will be a function and sometimes it will not be. Given a function $$f$$, the inverse relation is simply the set of ordered pairs that results from reversing the ordered pairs in $$f$$. It is worth pointing out that we have only defined inverse relations for functions. However, one can easily adapt our definition to handle arbitrary relations.

Problem 8.71. Consider the function $$f$$ given in Example 8.2 (see Figure 8.1). List the ordered pairs in the relation $$f^{-1}$$ and draw the corresponding digraph. Is $$f^{-1}$$ a function?

Problem 8.72. Provide an example of a function $$f:X\to Y$$ such that $$f^{-1}$$ is a function. Drawing a function diagram is sufficient.

Problem 8.73. Suppose $$X\subseteq \mathbb{R}$$ and $$f:X\to \mathbb{R}$$ is a function. What is the relationship between the graph of the function $$f$$ and the graph of the inverse relation $$f^{-1}$$?

Theorem 8.74. Let $$f:X\to Y$$ be a function. Then $$f^{-1}:Y\to X$$ is a function if and only if $$f$$ is a bijection.

Problem 8.75. Suppose $$f:\mathbb{R}\to \mathbb{R}$$ is a function. Fill in the blank with the appropriate phrase.

The relation $$f^{-1}$$ is a function if and only if every horizontal line hits the graph of $$f$$ .

Explain why this statement is true.

Theorem 8.76. If $$f:X\to Y$$ is a bijection, then

1. $$f^{-1}\circ f=i_X$$, and
2. $$f\circ f^{-1}=i_Y$$.

Theorem 8.77. If $$f:X\to Y$$ is a bijection, then $$f^{-1}:Y\to X$$ is also a bijection.

Theorem 8.78. If $$f:X\to Y$$ and $$g:Y\to X$$ are functions such that $$g\circ f=i_X$$ and $$f\circ g=i_Y$$, then $$f^{-1}$$ is a function and $$g=f^{-1}$$.

The upshot of Theorems 8.76 and 8.78 is that if $$f^{-1}$$ is a function, then it is the only one satisfying the two-sided inverse property exhibited in Corollary 8.69 and Theorem 8.76. That is, inverse functions are unique when they exist. When the relation $$f^{-1}$$ is a function, we call it the inverse function of $$f$$.

Problem 8.79. Let $$X\subseteq\mathbb{R}$$ and suppose $$f:X\to\mathbb{R}$$ is a function. Explain the difference between $$f^{-1}(x)$$ and $$[f(x)]^{-1}$$. When does each exist?

Problem 8.80. Let $$X,Y\subseteq\mathbb{R}$$ and define $$f:X\to Y$$ via $$f(x)=e^x$$ and $$g:Y\to X$$ via $$g(x)=\ln(x)$$. Identify the largest possible choices for $$X$$ and $$Y$$ so that $$f$$ and $$g$$ are inverses of each other.

Theorem 8.81. If $$f:X\to Y$$ is a bijection, then $$(f^{-1})^{-1}=f$$.

In the previous theorem, we restricted our attention to bijections so that $$f^{-1}$$ would be a function, thus making $$(f^{-1})^{-1}$$ a sensible inverse relation in light of Definition 8.70. If we had defined inverses for arbitrary relations, then we would not have needed to require the function in Theorem 8.81 to be a bijection. In fact, we do not even need to require the relation to be a function. That is, if $$R$$ is a relation from $$X$$ to $$Y$$, then $$(R^{-1})^{-1}=R$$, as expected. Similarly, the next result generalizes to arbitrary relations.

Theorem 8.82. If $$f:X\to Y$$ and $$g:Y\to Z$$ are both bijections, then $$(g\circ f)^{-1}=f^{-1}\circ g^{-1}$$.

The previous theorem is sometimes referred to as the “socks and shoes theorem". Do you see how it got this name?

This page titled 8.3: Compositions and Inverse Functions is shared under a CC BY-SA 4.0 license and was authored, remixed, and/or curated by Dana Ernst via source content that was edited to the style and standards of the LibreTexts platform; a detailed edit history is available upon request.