1.2: Functions
- Page ID
- 84797
\( \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}\)You have probably encountered functions before. In introductory calculus, for instance, you typically deal with functions from \(\mathbb{R}\) to \(\mathbb{R}\) (e.g., the function \(f(x)=x^2\)). More generally, functions “send” elements of one set to elements of another set; these sets may or may not be sets of real numbers. We provide below a “good enough for government work” definition of a function.
Definition: Function
A function \(f\) from a set \(S\) to a set \(T\) is a “rule” that assigns to each element \(s\) in \(S\) a unique element \(f(s)\) in \(T\text{;}\) the element \(f(s)\) is called the image of \(s\) under \(f\). If \(f\) is a function from \(S\) to \(T\text{,}\) we write \(f: S \to T\text{,}\) and call \(S\) the domain of \(f\) and \(T\) the codomain of \(f\text{.}\) The range of \(f\) is
\begin{equation*} f(S)=\{f(s) \in T : s \in S\} \subseteq T. \end{equation*}
More generally, if \(U \subseteq S\text{,}\) the image of \(U\) in \(T\) under \(f\) is
\begin{equation*} f(U)=\{f(u)\in T : u\in U\}. \end{equation*}
If \(V \subseteq T\text{,}\) the preimage of \(V\) in \(S\) under \(f\) is the set
\begin{equation*} f^{\leftarrow}(V)=\{s\in S: f(s)\in V\}. \end{equation*}
Example \(\PageIndex{1}\)
Consider the function \(f: \mathbb{Z} \to \mathbb{R}\) defined by \(f(x)=x^2\text{.}\) The domain of \(f\) is \(\mathbb{Z}\) and the codomain of \(f\) is \(\mathbb{R}\text{;}\) the range of \(f\) is \(\{x^2\,:\,x\in \mathbb{Z}\}=\{0,1,4,9,\ldots\}\text{.}\) The image of \(\{-2,-1,1,2\}\) under \(f\) is the two-element set \(\{1,4\} \subseteq \mathbb{R} \text{,}\) and the preimage of \(\{4,25,\pi\}\) under \(f\) is the set \(\{\pm 2, \pm 5\}\text{.}\) (Do you see why \(\pm \sqrt{\pi}\) are not in this preimage?) What is the preimage of just \(\{\pi\}\) under \(f\text{?}\)
The following definitions will be very important in our future work.
Definition: One-to-one, Onto, and Bijection
Let \(S\) and \(T\) be sets, and \(f:S\to T\text{.}\)
-
Function \(f\) is one-to-one (1-1) if whenever \(s_1, s_2\in S\) with \(f(s_1)=f(s_2)\text{,}\) we have \(s_1=s_2\text{.}\) Equivalently, \(f\) is one-to-one if whenever \(s_1\neq s_2 \in S\text{,}\) then \(f(s_1)\neq f(s_2) \in T\text{.}\)
-
Function \(f\) is onto if for every \(t\in T\text{,}\) there exists an element \(s\in S\) such that \(f(s)=t\text{.}\) Equivalently, \(f\) is onto if \(f(S)=T\text{.}\)
-
Function \(f\) is a bijection if it is both one-to-one and onto.
Remark
We will often have to show functions are one-to-one or onto. Given a function \(f:S\to T\text{,}\) the following methods are recommended.
-
To prove that \(f\) is one-to-one: Let \(s_1,s_2 \in S\) with \(f(s_1)=f(s_2)\) and prove that then \(s_1=s_2\text{.}\)
Note: It is not sufficient to prove that if \(s_1=s_2\) in \(S\) then \(f(s_1)=f(s_2)\text{;}\) that holds true for ANY function from \(S\) to \(T\text{!}\) Be careful to assume and prove the correct facts.
-
To prove that \(f\) is not one-to-one: Identify two elements \(s_1 \neq s_2\) of \(S\) such that \(f(s_1)=f(s_2)\text{.}\)
-
To prove that \(f\) is onto: Let \(t\in T\) and prove that there exists an element \(s\in S\) with \(f(s)=t\text{.}\)
Note: It is not sufficient to prove that if \(s\in S\) then \(f(s)\) is in \(T\text{;}\) that holds true for ANY function from \(S\) to \(T\text{!}\) Again, be careful to assume and prove the correct facts.
-
To prove that \(f\) is not onto: Identify an element \(t\in T\) for which there is no \(s\in S\) with \(f(s)=t\text{.}\)
Example \(\PageIndex{2}\)
Consider the function \(f: \mathbb{R}^* \to \mathbb{R}^+\) defined by \(f(x)=x^2\text{.}\) Function \(f\) is not one-to-one: indeed, \(-1\) and \(1\) are in \(\mathbb{R}^*\) with \(f(-1)=1=f(1)\) in \(\mathbb{R}^+\text{.}\) However, \(f\) is onto: indeed, let \(t\in \mathbb{R}^+\text{.}\) Then \(\sqrt{t} \in \mathbb{R}^*\) with \(t=f(\sqrt{t})\text{,}\) so we're done.
Example \(\PageIndex{3}\)
Consider the function \(f: \mathbb{Z}^+ \to \mathbb{R}\) defined by \(f(x)=\dfrac{x}{2}\text{.}\) Function \(f\) is one-to-one: indeed, let \(s_1, s_2 \in \mathbb{Z}^+\) with \(f(s_1)=f(s_2)\text{.}\) Then \(\dfrac{s_1}{2}=f(s_1)=f(s_2)=\dfrac{s_2}{2}\text{;}\) multiplying both sides of the equation \(\dfrac{s_1}{2}=\dfrac{s_2}{2}\) by \(2\), we obtain \(s_1=s_2\text{.}\) However, \(f\) is not onto: for example, \(\pi \in \mathbb{R}\) but there is no positive integer \(s\) for which \(f(s)=\dfrac{s}{2}=\pi\text{.}\)
Recall that we can combine certain functions using composition:
Definition: Composition and Identity Function
If \(f:S\to T\) and \(g:T\to U\text{,}\) then the composition of \(f\) and \(g\) is the function \(g\circ f: S\to U\) defined by
\begin{equation*} (g\circ f)(s)=g(f(s)) \end{equation*}
for all \(s\in S\text{.}\) (More generally, you can compose functions \(f:S\to T\) and \(g:R\to U\) to form \(g\circ f:S\to U\text{,}\) as long as \(f(S)\subseteq R\text{.}\)) Also recall that given any set \(S\text{,}\) the identity function on \(S\) is the function \(1_S: S\to S\) defined by \(1_S(s)=s\) for every \(s\in S\text{.}\)
Definition: Inverse
Let \(f\) be a function from \(S\) to \(T\text{.}\) A function \(g\) from \(T\) to \(S\) is an inverse of \(f\) if \(g\circ f\) and \(f\circ g\) are the identity functions on \(S\) and \(T\text{,}\) respectively; that is, if for all \(s\in S\) and \(t\in T\text{,}\) \(g(f(s))=s\) and \(f(g(t))=t\text{.}\)
We say a function is invertible if it has an inverse.
We have the following useful theorems.
Theorem \(\PageIndex{1}\)
Function \(f:S\to T\) is invertible if and only if \(f\) is a bijection.
- Proof
-
Suppose \(f\) has inverse \(g\). Let \(t∈T\). Then \(f(g(t))=t\), so \(f\) is onto. Next, suppose \(s_1,s_2∈S\) with \(f(s_1)=f(s_2)\). Then
\(s_1=g(f(s_1))=g(f(s_2))=s_2\),
so \(f\) is one-to-one.
Conversely, suppose \(f\) is a bijection. Then for every \(t∈T\), there exists a unique element \(s_t∈S\) such that \(f(s_t)=t.\) It is then straighforward to show that the function \(g:T→S\) defined by
\(g(t)=t_s\) for every \(t∈T\)
is an inverse of \(f\).
Theorem \(\PageIndex{2}\)
Let \(f:S\to T\) be invertible. Then the inverse of \(f\) is unique; we denote the unique inverse of \(f\) by \(f^{-1}\text{.}\)
- Proof
-
Suppose \(f\) has inverses \(g\) and \(h\). Then for every \(t∈T\), \(f(g(t))=t=f(h(t))\). But since \(f\) is invertible, it's one-to-one, so we must have \(g(t)=h(t)\) for every \(t∈T\). Thus, \(g=h\), and so \(f\) cannot have two or more distinct inverses.
Theorem \(\PageIndex{3}\)
Let \(f:S\to T\) and \(g:T\to U\) be functions. If \(f\) and \(g\) are both 1-1 [resp., onto], then \(g\circ f: S\to U\) is 1-1 [resp., onto]. It follows that if \(f\) and \(g\) are both bijections, then \(g\circ f: S\to U\) is a bijection.
- Proof
-
Assume \(f\) and \(g\) are 1-1. Let \(s_1,s_2∈S\) with \((g \circ f)(s_1)=(g \circ f)(s_2)\). Then \(g(f(s_1))=g(f(s_2));\) since \(g\) is one-to-one, this shows that \(f(s_1)=f(s_2)\). Then since \(f\) is one-to-one, we must have \(s_1=s_2\). Thus, \(g \circ f\) is one-to-one.
The proof that \(g \circ f\) is onto if \(f\) and \(g\) are onto is left as an exercise for the reader.