A function has three parts, a set of inputs, a set of outputs, and a rule that relates the elements of the set of inputs to the elements of the set of outputs in such a way that each input is assigned exactly one output.
Although for brevity, functions are often identified by a one-letter name, such as \(f\text{,}\) many common functions are identified by multi-letter names. We will see that \(\gcd\) that we saw in the previous chapter is actually an example of a function. Many others you can find on the keys of your calculator, for example: \(\cos\text{,}\)\(\exp\text{,}\)\(\ln\text{,}\)\(\log\text{,}\)\(\sin\text{,}\)\(\tan\text{,}\) and so on.
We give an introduction to functions in the video in Figure 7.1. It is followed by a more detailed discussion.
We give the definition of a function and its domain and codomain. We also introduce a convenient short notation for specifying the domain and codomain of a function.
Definition7.2.
Let \(A\) and \(B\) be nonempty sets.
A function\(f\) from \(A\) to \(B\) assigns exactly one element of \(B\) to each element of \(A\text{.}\) We denote a function \(f\) from \(A\) to \(B\) by \(f \colon A \to B\) and we write \(f(a) = b\) if \(b\) is the unique element of \(B\) that is assigned to the element \(a \in A\) by \(f\text{.}\)
We read \(f:A\to B\) as “the function \(f\) from \(A\) to \(B\text{.}\)” We read \(f(a) = b\) as “\(f\) of \(a\) is \(b\)” or “\(f\) evaluated at \(a\) is \(b\text{.}\)”
The set \(A\) is called the domain of \(f\text{,}\) and the set \(B\) is called the codomain of \(f\text{.}\)
Suppose that \(f(a)=b\text{.}\) Then the element \(b\) is the image of the element \(a\) under the function \(f\text{,}\) and the element \(a\) is a preimage of the element \(b\) under the function \(f\text{.}\)
Checkpoint7.3.Definition of Functions.
Complete the following: Let \(A\) and \(B\) be nonempty sets. A function from \(A\) to \(B\) assigns
select
two elements
each element
no element
half of the elements
exactly one element
some element
of \(B\) to
select
two elements
each element
no element
half of the elements
exactly one element
some element
of \(A\text{.}\)
The set \(A\) is called the
select
range
image
subset
codomain
domain
superset
preimage
function
of the function and the set \(B\) is called the
select
range
image
subset
codomain
domain
superset
preimage
function
of the function.
\(n\)
\(\mathrm{studentid}(n)\)
Aaron
\(1006\)
Alice
\(1001\)
Bob
\(1002\)
Eve
\(1003\)
James
\(1005\)
Nathan
\(1007\)
Oscar
\(1004\)
Sandi
\(1008\)
Figure7.4.The function \(\mathrm{studentid}:N\to I\) defined by a table. The domain is the set \(N=\{\mathsf{Aaron},\mathsf{Alice},\mathsf{Bob},\mathsf{Eve},\mathsf{James},\mathsf{Nathan},\mathsf{Oscar},\mathsf{Sandi}\}\text{.}\) of names of the students in MAT 112. The codomain is the set \(I=\{1001,1002,1003,1004,1005,1006,1007,1008\}\) of student identification numbers defined by a table.
Example7.5.A function from student names to student IDs.
In Figure 7.4 we define a function \(\mathrm{studentid}:N\to I\) that assigns an identification number in the set \(I\) to each student in the set \(S\text{.}\) The set \(N\) of student names is the domain of the function \(\mathrm{studentid}\) and the set \(I\) of student identification numbers is the codomain of \(\mathrm{studentid}\text{.}\)
We have \(\mathrm{studentid}(Alice)=1001\text{.}\) So \(1001\) is the image of Alice under the function \(\mathrm{studentid}\text{.}\) Alice is the preimage of \(1001\) under the function \(\mathrm{studentid}\text{.}\)
\(i\)
\(\mathrm{grade}(i)\)
\(1001\)
\(\mathsf{B}\)
\(1002\)
\(\mathsf{C}\)
\(1003\)
\(\mathsf{D}\)
\(1004\)
\(\mathsf{F}\)
\(1005\)
\(\mathsf{A}\)
\(1006\)
\(\mathsf{A}\)
\(1007\)
\(\mathsf{A}\)
\(1008\)
\(\mathsf{A}\)
Figure7.6.The function \(\mathrm{grade}:I\to G\) where
be the identification numbers of the students in MAT 112. The teacher of MAT 112 posts the table from Figure 7.6 on her door, so that the students can look up their grades their without posting the students names.
The set \(I\) of student identification numbers is the domain of the function \(\mathrm{grade}\) and the set \(G=\{\mathsf{A},\mathsf{B},\mathsf{C},\mathsf{D},\mathsf{F}\}\) is the codomain of \(\mathrm{grade}\text{.}\)
We have \(\mathrm{grade}(1001)=\mathsf{B}\text{.}\) Which means that the grade of the student with the identification number \(1001\) is \(\mathsf{B}\text{.}\) So the image of \(1001\) under the function \(\mathrm{grade}\) is \(\mathsf{B}\) and \(1001\) is a preimage of \(\mathsf{B}\) under the function \(\mathrm{grade}\text{.}\)
The images of the elements under a function can be specified in different ways. If we can write down all of the elements of the domain of a function, the function can be specified by explicitly giving the images of the elements of the domain. This can, for example, be done with a diagram or a table.
For example the function \(k\) in Figure 7.8 is given by a diagram and by a table.
\(x\)
\(k(x)\)
\(0\)
\(2\)
\(1\)
\(4\)
\(2\)
\(8\)
\(3\)
\(8\)
\(4\)
\(4\)
(b)\(k\) given by a table
Figure7.8.Two ways of specifying a function \(k\) from the set \(\Z_5~=~\{0,1,2,3,4\}\) to the set \(\{2,4,8\}\) by a diagram and by a table
Functions can also be specified by an algebraic rule. For a function \(g\text{,}\) we may specify that \(g(x)\) is equal to an algebraic expression in the variable \(x\text{.}\) For example, in Figure 7.9, the function \(g\) is given by a diagram in (a), by a table in (b), and by an algebraic rule in (c).
\(x\)
\(g(x)\)
\(0\)
\(0\)
\(1\)
\(1\)
\(2\)
\(4\)
\(3\)
\(4\)
\(4\)
\(1\)
(b)\(g\) given by a table
Figure7.9.Three ways of specifying a function \(g\) from the set \(\Z_5\) to the set \(\Z_5\)where \(\Z_5=\{0,1,2,3,4\}\text{.}\)
Example7.10.A function given by an algebraic rule.
The function \(s:\N\to\N\) given by \(s(n):=n^2\) is the function that assigns to each natural number \(n\) its square \(n^2\text{.}\) (Note that we are using \(:=\) because we are defining the output of the function \(s\text{.}\))
We have \(s(1)=1^2=1\text{,}\)\(s(2)=2^2=4\text{,}\)\(s(3)=3^2=9\) and so on. Thus the image of 1 is 1, the image of 2 is 4, and the image of 3 is 9. A preimage of 1 is 1, a preimage of 4 is 2, and a preimage of 9 is 3. The number 2 does not have a preimage, since it is not a square of a natural number.
We give an example of a function, under which each element in the codomain has (infinitely) many preimages.
Example7.11.Infinitely many preimages.
Let \(\N\) be the set of natural numbers and \(\Z_5=\{0,1,2,3,4\}\text{.}\) Consider the function \(m:\N\to\Z_5\) given by \(m(a):=a\fmod 5\text{.}\) We have \(m(1)=1\text{,}\)\(m(2)=2\text{,}\)\(m(3)=3\text{,}\)\(m(4)=4\text{,}\)\(m(5)=0\text{,}\)\(m(6)=1\text{,}\) and so on.
In the table below, we explicitly give the images under \(m\) for a few elements in the domain.
\(a\)
\(m(a)=a\fmod 5\)
\(0\)
\(0\)
\(1\)
\(1\)
\(2\)
\(2\)
\(3\)
\(3\)
\(4\)
\(4\)
\(5\)
\(0\)
\(6\)
\(1\)
\(7\)
\(2\)
\(8\)
\(3\)
\(9\)
\(4\)
\(10\)
\(0\)
\(11\)
\(1\)
\(12\)
\(2\)
\(13\)
\(3\)
\(14\)
\(4\)
\(15\)
\(0\)
\(16\)
\(1\)
\(17\)
\(2\)
\(\vdots\)
\(\vdots\)
Notice that the image of \(1\) is \(1\text{.}\) But the number \(1\) has many preimages. For example, the elements \(1\text{,}\)\(6\text{,}\)\(11\text{,}\) and \(16\) in \(\N\) are all preimages of the element \(1\) in \(\Z_5\text{.}\) There are infinitely many preimages of \(1\text{,}\) namely all numbers in the set \(\{a\mid a\in\N \text{ and } a\fmod 5=1\}\text{.}\)
A function can also be described by an algorithm.
Example7.12.A function given by an algorithm.
The greatest common divisor function takes each pair of natural numbers and assigns to it the natural number that is the greatest common divisor of the two numbers in the pair. So, the greatest common divisor function has domain \(\N\times\N\) and codomain \(\N\text{,}\) and we may write
The function \(\gcd\) is explicitly specified by the Euclidean Algorithm that has a pair of natural numbers as the input and provides a single natural number as the output.
Another way of representing a function is its graph. Instead of organizing the values in a table we consider them as elements of a Cartesian product. We give an introduction to graphs of functions in the video in Figure 7.13. It is followed by a more detailed discussion.
Definition7.14.Graph of a function.
The graph of the function \(f:A\to B\) is
\begin{equation*}
\left\{ (x,f(x)) \mid x \in B \right\} \subseteq A\times B.
\end{equation*}
In Example 7.15 we obtain a graphical representation a function by applying the graphical representation of Cartesian products from Section 6.3 to the graph of the function.
Example7.15.
Let \(f:\mathbb{Z}_{6}\to\mathbb{Z}_{5}\) be given by \(f(x)= 2^x \bmod 5\text{.}\)
The graph of \(h\) are the elements of the Cartesian product \(\mathbb{Z}_{10}\times\mathbb{Z}_5\) which are represented by the black pixels in the plot. We find that the graph of \(h\) is
\begin{equation*}
\{ (x,h(x)) \mid x \in A \} = \{
(0,2),
(1,0),(2,0),
(3,1),
(4,0),
(5,1),
(6,0),
(7,4),(8,4),(9,3)
\}.
\end{equation*}
Because the graph of \(h\) consists of the pairs \((x,h(x))\) where \(x\) is an element of the domain of \(h\text{,}\) we can read off the values \(h(x)\) easily.
In Example 7.17 observe how changing the plot of the graph of a function changes its graph.