Skip to main content
Contents Index
Search Book
Search Results:
No results.
Readability settings Prev Up Next
\(\require{cancel}
\newcommand{\nth}[1][n]{{#1}^{\mathrm{th}}}
\newcommand{\bbrac}[1]{\bigl(#1\bigr)}
\newcommand{\Bbrac}[1]{\Bigl(#1\Bigr)}
\newcommand{\correct}{\boldsymbol{\checkmark}}
\newcommand{\incorrect}{\boldsymbol{\times}}
\newcommand{\inv}[2][1]{{#2}^{-{#1}}}
\newcommand{\leftsub}[3][1]{\mathord{{}_{#2\mkern-#1mu}#3}}
\newcommand{\N}{\mathbb{N}}
\newcommand{\Z}{\mathbb{Z}}
\newcommand{\Q}{\mathbb{Q}}
\newcommand{\R}{\mathbb{R}}
\newcommand{\I}{\mathbb{I}}
\newcommand{\abs}[1]{\left\lvert #1 \right\rvert}
\DeclareMathOperator{\sqrtop}{sqrt}
\newcommand{\lgcnot}{\neg}
\newcommand{\lgcand}{\wedge}
\newcommand{\lgcor}{\vee}
\newcommand{\lgccond}{\rightarrow}
\newcommand{\lgcbicond}{\leftrightarrow}
\newcommand{\lgcimplies}{\Rightarrow}
\newcommand{\lgcequiv}{\Leftrightarrow}
\newcommand{\lgctrue}{\mathrm{T}}
\newcommand{\lgcfalse}{\mathrm{F}}
\newcommand{\boolnot}[1]{{#1}'}
\newcommand{\boolzero}{\mathbf{0}}
\newcommand{\boolone}{\mathbf{1}}
\newcommand{\setdef}[2]{\left\{\mathrel{}#1\mathrel{}\middle|\mathrel{}#2\mathrel{}\right\}}
\newcommand{\inlinesetdef}[2]{\{\mathrel{}#1\mathrel{}\mid\mathrel{}#2\mathrel{}\}}
\let\emptyword\emptyset
\renewcommand{\emptyset}{\varnothing}
\newcommand{\relcmplmnt}{\smallsetminus}
\newcommand{\union}{\cup}
\newcommand{\intersection}{\cap}
\newcommand{\cmplmnt}[1]{{#1}^{\mathrm{c}}}
\newcommand{\disjunion}{\sqcup}
\newcommand{\cartprod}{\times}
\newcommand{\words}[1]{{#1}^\ast}
\newcommand{\length}[1]{\abs{#1}}
\newcommand{\powsetbare}{\mathcal{P}}
\newcommand{\powset}[1]{\powsetbare(#1)}
\newcommand{\funcdef}[4][\to]{#2\colon #3 #1 #4}
\newcommand{\ifuncto}{\hookrightarrow}
\newcommand{\ifuncdef}[3]{\funcdef[\ifuncto]{#1}{#2}{#3}}
\newcommand{\sfuncto}{\twoheadrightarrow}
\newcommand{\sfuncdef}[3]{\funcdef[\sfuncto]{#1}{#2}{#3}}
\newcommand{\funcgraphbare}{\Delta}
\newcommand{\funcgraph}[1]{\funcgraphbare(#1)}
\newcommand{\nmathrel}[1]{\mathrel{\not #1}}
\newcommand{\relset}[3]{#1_{{} #2 #3}}
\newcommand{\gtset}[2]{\relset{#1}{\gt}{#2}}
\newcommand{\posset}[1]{\gtset{#1}{0}}
\newcommand{\geset}[2]{\relset{#1}{\ge}{#2}}
\newcommand{\nnegset}[1]{\geset{#1}{0}}
\newcommand{\neqset}[2]{\relset{#1}{\neq}{#2}}
\newcommand{\nzeroset}[1]{\neqset{#1}{0}}
\newcommand{\ltset}[2]{\relset{#1}{\lt}{#2}}
\newcommand{\leset}[2]{\relset{#1}{\le}{#2}}
\newcommand{\natnumlt}[1]{\ltset{\N}{#1}}
\DeclareMathOperator{\id}{id}
\newcommand{\inclfunc}[2]{\iota_{#1}^{#2}}
\newcommand{\projfunc}[1]{\rho_{#1}}
\DeclareMathOperator{\proj}{proj}
\newcommand{\funcres}[2]{\left.{#1}\right\rvert_{#2}}
\newcommand{\altfuncres}[2]{\left.{#1}\right\rvert{#2}}
\DeclareMathOperator{\res}{res}
\DeclareMathOperator{\flr}{flr}
\newcommand{\floor}[1]{\lfloor {#1} \rfloor}
\newcommand{\funccomp}{\circ}
\newcommand{\funcinvimg}[2]{\inv{#1}\left({#2}\right)}
\newcommand{\card}[1]{\left\lvert #1 \right\rvert}
\DeclareMathOperator{\cardop}{card}
\DeclareMathOperator{\ncardop}{\#}
\newcommand{\EngAlphabet}{\{ \mathrm{a}, \, \mathrm{b}, \, \mathrm{c}, \, \dotsc, \, \mathrm{y}, \, \mathrm{z} \}}
\newcommand{\ShortEngAlphabet}{\{ \mathrm{a}, \, \mathrm{b}, \, \dotsc, \, \mathrm{z} \}}
\newcommand{\eqclass}[1]{\left[#1\right]}
\newcommand{\partorder}{\preceq}
\newcommand{\partorderstrict}{\prec}
\newcommand{\npartorder}{\npreceq}
\newcommand{\subgraph}{\preceq}
\newcommand{\subgraphset}[1]{\mathcal{S}(#1)}
\newcommand{\connectedsubgraphset}[1]{\mathcal{C}(#1)}
\newcommand{\permcomb}[3]{{#1}(#2,#3)}
\newcommand{\permcombalt}[3]{{#1}^{#2}_{#3}}
\newcommand{\permcombaltalt}[3]{{\leftsub{#2}{#1}}_{#3}}
\newcommand{\permutation}[2]{\permcomb{P}{#1}{#2}}
\newcommand{\permutationalt}[2]{\permcombalt{P}{#1}{#2}}
\newcommand{\permutationaltalt}[2]{{\permcombaltalt{P}{#1}{#2}}}
\newcommand{\combination}[2]{\permcomb{C}{#1}{#2}}
\newcommand{\combinationalt}[2]{\permcombalt{C}{#1}{#2}}
\newcommand{\combinationaltalt}[2]{{\permcombaltalt{C}{#1}{#2}}}
\newcommand{\choosefuncformula}[3]{\frac{#1 !}{#2 ! \, #3 !}}
\DeclareMathOperator{\matrixring}{M}
\newcommand{\uvec}[1]{\mathbf{#1}}
\newcommand{\zerovec}{\uvec{0}}
\newcommand{\lt}{<}
\newcommand{\gt}{>}
\newcommand{\amp}{&}
\definecolor{fillinmathshade}{gray}{0.9}
\newcommand{\fillinmath}[1]{\mathchoice{\colorbox{fillinmathshade}{$\displaystyle \phantom{\,#1\,}$}}{\colorbox{fillinmathshade}{$\textstyle \phantom{\,#1\,}$}}{\colorbox{fillinmathshade}{$\scriptstyle \phantom{\,#1\,}$}}{\colorbox{fillinmathshade}{$\scriptscriptstyle\phantom{\,#1\,}$}}}
\)
Section 10.4 Composition of functions
composition function
a function
\(A \to C \) created from functions
\(\funcdef{f}{A}{B} \) and
\(\funcdef{g}{B}{C} \) by
\(a \mapsto g\bbrac{f(a)} \)
\(g \funccomp f \)
the composition of functions
\(\funcdef{f}{A}{B} \) and
\(\funcdef{g}{B}{C} \text{,}\) so that
\(\funcdef{g \funccomp f}{A}{C} \) by
\((g \funccomp f)(a) = g\bbrac{f(a)} \)
Figure 10.4.1. A Venn diagram of a function composition.
Example 10.4.2 . A composition of two functions.
Consider the functions
\begin{align*}
f \colon \R \amp \to \nnegset{\R},
\amp g \colon \nnegset{\R} \amp \to \nnegset{\R},\\
x \amp \mapsto x^2,
\amp x \amp \mapsto \sqrt{x},
\end{align*}
Then we have
\begin{align*}
g \funccomp f \colon \R \amp \to \nnegset{\R}, \\
x \amp \mapsto \sqrt{x^2} = \abs{x}.
\end{align*}
Example 10.4.4 . Comparing composition order.
Consider functions
\begin{align*}
f \colon \N \amp \to \N, \amp g \colon \N \amp \to \N, \\
n \amp \mapsto n^2, \amp n \amp \mapsto n + 1.
\end{align*}
Then, both \(\funcdef{f \funccomp g}{\N}{\N} \) and \(\funcdef{g \funccomp f}{\N}{\N} \) are defined. But they are not equal, as
\begin{align*}
(f \funccomp g)(n) \amp = (n+1)^2 = n^2+2n+1, \amp
(g \funccomp f)(n) \amp = n^2+1.
\end{align*}
Example 10.4.5 . An undefined composition.
Consider functions
\begin{align*}
\sqrtop \colon \N \amp \to \R, \amp \flr \colon \R \amp \to \Z, \\
n \amp \mapsto \sqrt{n}, \amp x \amp \mapsto \floor{x}.
\end{align*}
Then, \(\funcdef{\flr \funccomp \sqrtop}{\N}{\Z} \) is defined, with
\begin{equation*}
(\flr \funccomp \sqrtop)(n) = \floor{\sqrt{n}} \text{.}
\end{equation*}
But \(\sqrtop \funccomp \flr \) is not defined, as the codomain of \(\flr \) does not match the domain of \(\sqrtop \text{.}\) In particular, \(\flr \) will sometimes return a negative output, and we cannot use such an output as an input in \(\sqrtop \text{.}\)
Checkpoint 10.4.6 . Properties of compositions.
Consider functions
\(\funcdef{f}{A}{B} \) and
\(\funcdef{g}{B}{C} \text{.}\)
(a)
If
\(g \funccomp f \) is injective, are either or both of
\(f,g \) necessarily injective?
(b)
Answer the same question as above with βinjectiveβ replaced by βsurjectiveβ.
(c)
Demonstrate that if both
\(f \) and
\(g \) are bijective, then the composition
\(g \funccomp f \) is also bijective.
Of course, we can compose any number of functions.
Example 10.4.7 . A composition of three functions.
Let us reconsider the function defined by algorithm in
ExampleΒ 10.1.5 . As the function description involved a multi-step algorithm, we should be able to break the steps involved into their own functions, then recreate the original functions as a composition.
First, define \(\funcdef{\operatorname{abs}}{\powset{\Z}}{\powset{\N}} \) by
\begin{equation*}
\operatorname{abs}(X) = \setdef{\abs{x}}{x \in X} \text{.}
\end{equation*}
Next, define
\(\funcdef{\min}{\powset{\N}}{\N} \) so that
\(\min(X) \) outputs the minimum number in input set
\(X \text{,}\) and outputs
\(0 \) in case
\(X = \emptyset \text{.}\)
Finally, define
\(\funcdef{f}{\N}{\N} \) by
\(f(n) = 2 n + 1 \text{.}\)
Each of these functions represents one step in the algorithm defining the function in
ExampleΒ 10.1.5 , but to recreate that function we need to compose the functions in the correct order: write
\(\varphi = f \funccomp \min \funccomp \operatorname{abs} \text{,}\) so that
\begin{equation*}
\varphi(X) = 2 \min\bbrac{\operatorname{abs}(X)} + 1
\end{equation*}
computes the same result for an input set
\(X \) as the algorithm described in
ExampleΒ 10.1.5 .