Skip to main content

Section 6.2 Functions with Rules Described in Words

Nearly all of the functions we have seen so far have had sets of numbers for their domain and codomain and have had rules defined by formulas. In this section, which include functions whose domain and codomain are sets of other discrete objects such as graphs and bit strings.

Subsection 6.2.A Floor and Ceiling

As a first example of functions with rules described in words, we consider the floor and ceiling functions which take a real (decimal) number input and find a nearby integer to output.

Definition 6.2.1 Floor and ceiling.

Β 
  1. For a real number \(x\text{,}\) the floor of \(x\text{,}\) denoted \(\lfloor x \rfloor\text{,}\) is the result of rounding \(x\) down to the nearest integer less than or equal to \(x\text{.}\) Officially, \(\lfloor x \rfloor=k\) where \(k\) is the greatest integer such that \(k\le x\text{.}\) For example, \(\lfloor 2.4 \rfloor = 2\) and \(\lfloor -2.4 \rfloor = -3\text{.}\) This name comes from the fact that we look down to see the floor of a room. Notice that the floor is the first integer at or to the left of the number on the real number line.
    Figure 6.2.2. Calculating the floor by looking left on the real number line.
  2. For a real number \(x\text{,}\) the ceiling of \(x\text{,}\) denoted \(\lceil x \rceil\text{,}\) is the result of rounding \(x\) up to the nearest integer greater than or equal to \(x\text{.}\) Officially, \(\lceil x \rceil =k\) where \(k\) is the least integer such that \(k\ge x\text{.}\) For example, \(\lceil 2.4 \rceil = 3\) and \(\lceil -2.4 \rceil = -2\text{.}\) This name comes from the fact that we look up to see the ceiling of a room. Notice that the ceiling is the first integer at or to the right of the number on the real number line.
    Figure 6.2.3. Calculating the ceiling by looking right on the real number line.
Note that floor and ceiling are in the same level as parentheses in the order of operations DefinitionΒ 2.1.20. Let’s look at an example.

Example 6.2.4 Floor and ceiling calculations.

Β 
  1. Evaluate \(\lfloor \frac{10}{3} \rfloor\) and \(\lfloor ^-\frac{10}{3} \rfloor\text{.}\)
    Solution.
    Since \(\frac{10}{3} = 3.333\ldots\text{,}\) we round down to get \(\lfloor \frac{10}{3} \rfloor=3\text{.}\)
    Since \(^-\frac{10}{3} = -3.333\ldots\text{,}\) we round down (to a more negative number) to get -4.
  2. Evaluate \(\lfloor 17 \rfloor\) and \(\lceil 17 \rceil\text{.}\)
    Solution.
    Because 17 is an integer, we do not have to round at all. Therefore, \(\lfloor 17 \rfloor = 17\) and \(\lceil 17 \rceil = 17\text{.}\)
Try working with floor and ceiling.

Activity 6.2.A Floor and ceiling.

Β 
  1. Evaluate \(\lfloor 1.4 \rfloor\) and \(\lceil 1.4 \rceil\text{.}\)
  2. Evaluate \(\lfloor -15.82 \rfloor\) and \(\lceil -15.82 \rceil\text{.}\)
  3. Evaluate \(\lfloor 308 \rfloor\) and \(\lceil 308 \rceil\text{.}\)
  4. Professor DorΓ©e expects 40 students to attend a talk. She wants to cans of sparkling water so each student can get one, then how many 12-packs of cans should she buy? What if there are \(n\) students? Your answer should involve \(n\) and floor or ceiling.
  5. Give an example of a real number \(x\) that is not an integer where \(\lceil 2x \rceil = 2 \lceil x \rceil\text{.}\) Give a counterexample to the conjecture that \(\lceil 2x \rceil = 2 \lceil x \rceil\) for all real numbers \(x\text{.}\)
  6. Does there exist a real number \(x\) where \(\lfloor x \rfloor = 6\text{?}\) Is it unique? How many real numbers \(x\) have \(\lfloor x \rfloor = 6\text{?}\) Describe all real numbers \(x\) such that \(\lfloor x \rfloor = 6\text{.}\)
  7. Consider a real number \(x\) such that \(\lfloor x \rfloor = 6\text{.}\) What is/are the possible value(s) of \(\lceil x \rceil\text{?}\)
  8. When is \(\lfloor x \rfloor = \lceil x \rceil\) for a real number \(x\text{?}\)
  9. If \(x\) is a real number such that \(\lfloor x \rfloor \neq \lceil x \rceil\text{,}\) then how are \(\lfloor x \rfloor\) and \(\lceil x \rceil\) related? State your answer in the form of a conjecture. Be as specific as possible.
We can define functions using floor and ceiling.

Example 6.2.6 Floor as a function.

The function
\begin{equation*} \fn{floor}:\mathbb{R} \to \mathbb{Z} \end{equation*}
is defined by \(\fn{floor}(x) = \lfloor x \rfloor\text{.}\)
  1. Identify the domain and codomain of the function \(\str{floor}\text{.}\)
    Solution.
    The domain of the function \(\str{floor}\) is \(\mathbb{R}\) and the codomain is \(\mathbb{Z}\text{.}\)
  2. Give an example of a real number \(x\) such that \(\fn{floor}(x) = 11\text{.}\) Now find a different real number \(s\) such that \(\fn{floor}(s)=11\text{.}\)
    Solution.
    Note that \(\fn{floor}(11) = \lfloor 11 \rfloor = 11\) and so one example is \(x=11\text{.}\) Another example is \(x = 11.38\) because \(\fn{floor}(11.38) = \lfloor 11.38 \rfloor = 11\text{.}\)
  3. Describe all real numbers \(x\) such that \(\fn{floor}(x)=11\text{.}\)
    Solution.
    Any real number \(x\) that is 11 or larger, but not as larger as 12 will have \(\fn{floor}(x)=11\text{.}\) We can describe these real numbers using the inequality \(11 \le x \lt 12\) or the interval \([11,12)\text{.}\)

Subsection 6.2.B Number-theoretic Functions

Let’s look at examples of functions with rules defined in words that come from number theory ChapterΒ 4. Here is a first example.

Example 6.2.7 Number of divisors.

The function
\begin{equation*} \fn{countdiv}: \mathbb{Z}^+ \to \mathbb{Z}^+ \end{equation*}
is defined by \(\fn{countdiv}(n)=\) the number of (positive) divisors of \(n\text{.}\)
  1. Evaluate \(\fn{countdiv}(4)\text{.}\)
    Solution.
    The divisors of four are: 1, 2, and 4. Since there are three divisors, \(\fn{countdiv}(4)=3\text{.}\)
  2. Find an integer \(n\) such that \(\fn{countdiv}(n) = 4\text{.}\) Is it unique? Explain.
    Solution.
    The integer six has four divisors: 1, 2, 3, and 6. Therefore \(\fn{coundiv}(6)=4\text{.}\) It is not unique because, for example, the integer ten also has four divisors: 1, 2, 5, and 10 and so \(\fn{countdiv}(10)=4\) as well.
  3. Describe all integers with \(\fn{countdiv}(n) = 4\text{.}\)
    Solution.
    By our work in SubsectionΒ 4.4.B, there are two possible prime factorizations of a number having four positive divisors: \(p^3\) or \(pq\) where \(p\) and \(q\) are distinct primes. (If we made a divisor table, it would be \(1 \times 4\) or \(2 \times 2\text{.}\))
  4. Give a counterexample to the statement: for every positive integer \(a\) and \(b\text{,}\) if \(a\lt b\text{,}\) then \(\fn{countdiv}(a) \lt \fn{countdiv}(b)\text{.}\) It follows that the function \(\fn{countdiv}\) is not increasing.
    Solution.
    We want an example that shows the statement is false, meaning it is a broken promise. A counterexample is \(a=6\) and \(b=7\) because \(6 \lt 7\) but \(\fn{countdiv}(6)=4\) and \(\fn{countdiv}(7) = 2\text{,}\) so \(\fn{countdiv}(6) \ge \fn{countdiv}(7)\text{.}\)
Practice with number-theoretic functions.

Activity 6.2.B Evaluating number-theoretic functions.

Β 
  1. The function
    \begin{equation*} \fn{twopart}: \mathbb{N} \to \mathbb{N} \end{equation*}
    defined by \(\fn{twopart}(n)\) is the highest power of two that divides \(n\text{.}\) Note that \(1 = 2^0\) is a power of two. Evaluate \(\fn{twopart}(24)\text{,}\) \(\fn{twopart}(30)\text{,}\) and \(\fn{twopart}(31)\text{.}\)
  2. The function
    \begin{equation*} \pi: \mathbb{N} \to \mathbb{N} \end{equation*}
    defined by \(\pi(n)=\) the number of primes less than or equal to \(n\text{.}\) Note that the function \(\pi\) has nothing to do with the real number \(\pi\text{.}\) Evaluate \(\pi(6)\) and \(\pi(20)\text{.}\)

Subsection 6.2.C Graph-theoretic Functions

Let’s look at examples of functions with rules defined in words that come from graph theory ChapterΒ 3. Here is a first example.

Example 6.2.9 Count vertices of degree three.

Let \(\mathbb{G}_{10}\) denote the set of all graphs with ten vertices. The function
\begin{equation*} \fn{deg3}: \mathbb{G}_{10} \to \mathbb{N} \end{equation*}
is defined by \(\fn{deg3}(G) =\) the number of vertices of \(G\) that have degree 3.
  1. Identify the domain and codomain of \(\fn{deg3}\text{.}\)
    Solution.
    The domain is \(\mathbb{G}_{10}\) and the codomain is \(\mathbb{N}\text{.}\)
  2. Evaluate \(\fn{deg3}(K_{3,7})\) where \(K_{3,7}\) is the complete bipartite graph defined in DefinitionΒ 3.2.12.
    Solution.
    The complete bipartite graph \(K_{3,7}\) has three (black) vertices of degree seven and seven (white) vertices of degree three, so \(\fn{deg3}(K_{3,7})=7\text{.}\)
  3. Evaluate \(\fn{deg3}(C_{10})\) where \(C_{10}\) is the cycle defined in DefinitionΒ 3.2.12.
    Solution.
    The cycle \(C_{10}\) has ten vertices of degree two and, therefore, no vertices of degree three, so \(\fn{deg3}(C_{10})=0\text{.}\)
  4. Evaluate \(\fn{deg3}(W_9)\) where \(W_9\) is the wheel defined in ExampleΒ 3.2.25.
    Solution.
    The wheel \(W_9\) has one hub vertex of degree nine and nine outer vertices of degree three, so \(\fn{deg3}(W_9)=9\text{.}\)
  5. Evaluate \(\fn{deg3}(L_{2 \times 5})\) where \(L_{2 \times 5}\) is the ladder defined in ExampleΒ 3.2.25.
    Solution.
    The ladder \(L_{2 \times 5}\) has four corner vertices of degree two and the other \(10-4=6\) inner vertices have degree three, so \(\fn{deg3}(L_{2 \times 5})=6\text{.}\)
  6. It turns out we can draw a graph \(G\) with ten vertices such that \(\fn{deg3}(G) = n\) for \(n=0,1,2,3,4,5,6,7,8,9\text{,}\) and 10 and so the image of \(\fn{deg3}\) is \(\{0,1,2,3,4,5,6,7,8,9,10\}\text{.}\) Draw a graph \(G\) with ten vertices such that \(\fn{deg3}(G) = 2\text{.}\) (Challenge yourself to draw the others.)
    Solution.
    One such graph is drawn in FigureΒ 6.2.10.
    Figure 6.2.10. A graph with exactly two vertices of degree three from ExampleΒ 6.2.9.
Try working with functions that involve graphs.

Activity 6.2.C Graph-theoretic functions.

Throughout this activity, \(\mathbb{G}\) denotes the set of all graphs.
  1. The function
    \begin{equation*} \fn{comp}: \mathbb{G} \to \mathbb{G} \end{equation*}
    is defined by \(\fn{comp}(G)=\overline{G}\text{,}\) the graph theoretic complement of the graph \(G\text{.}\) Evaluate (draw) \(\fn{comp}(W_4)\) for the wheel graph \(W_4\text{.}\)
  2. The function
    \begin{equation*} c: \mathbb{G} \to \mathbb{N} \end{equation*}
    is defined by \(c(G)=\) the the number of edges in of the longest path in \(G\text{.}\) Evaluate \(c(C_5)\) for the cycle \(C_5\) and \(c(K_{1,4})\) for the complete bipartite graph (star) \(K_{1,4}\text{.}\)
  3. The function
    \begin{equation*} \fn{isplanar}: \mathbb{G} \to \{0,1\} \end{equation*}
    is defined by
    \begin{equation*} \fn{isplanar}(G) = \left\{ \begin{array}{cl} 0 \amp \text{ if } G\text{ is planar } \\ 1 \amp \text{ if } G\text{ is not planar } \end{array} \right.\text{.} \end{equation*}
  4. Evaluate \(\fn{isplanar}(C_5)\) and \(\fn{isplanar}{K_5}\) for the cycle \(C_5\) and the complete graph \(K_5\text{.}\) Hint: \(K_5\) is not planar.

Subsection 6.2.D Functions Involving Bit Strings

Next, let’s look at functions defined on bit strings. We defined bit strings, the length of a bit string, and the weight of a bit string in DefinitionΒ 2.4.1. We start by establishing the notation for the empty string and for sets of bit strings.

Definition 6.2.12 Sets of bit strings.

Β 
  1. The symbol
     1 
    The lowercase Greek letter lambda, denoted \(\lambda\text{,}\) is similar to the English letter \(\str{l}\text{.}\)
    \(\lambda\) represents the empty bit string. It has length and weight 0.
  2. The set of all bit strings is the set
    \begin{equation*} \mathbb{B} = \{ \lambda, \bs{0}, \bs{1}, \bs{00}, \bs{01}, \bs{10}, \bs{11}, \bs{000}, \bs{001}, \bs{010}, \bs{011}, \bs{100}, \bs{101}, \bs{110}, \bs{111}, \bs{0000}, \bs{0001}, \bs{0010}, \bs{0011}, \ldots \}\text{.} \end{equation*}
  3. The set of all non-empty bit strings is the set \(\mathbb{B}\) without \(\lambda\text{,}\) namely
    \begin{equation*} \mathbb{B}^* = \{\bs{0}, \bs{1}, \bs{00}, \bs{01}, \bs{10}, \bs{11}, \bs{000}, \bs{001}, \bs{010}, \bs{011}, \bs{100}, \bs{101}, \bs{110}, \bs{111}, \bs{0000}, \bs{0001}, \bs{0010}, \bs{0011}, \ldots \}\text{.} \end{equation*}
  4. For any non-negative integer \(n\text{,}\) the set of all bit strings of length \(n\) is \(\mathbb{B}_n\text{.}\) For example, \(\mathbb{B}_0 = \{\lambda\}\text{,}\) \(\mathbb{B}_1 = \{\bs{0}, \bs{1}\}\text{,}\) \(\mathbb{B}_2 = \{\bs{00}, \bs{01}, \bs{10}, \bs{11}\}\) and
    \begin{equation*} \mathbb{B}_3 = \{\bs{000}, \bs{001}, \bs{010}, \bs{011},\bs{100}, \bs{101}, \bs{110}, \bs{111}\}\text{.} \end{equation*}
Let’s look at an example of a function on bit strings.

Example 6.2.13 Weight function on bit strings.

Consider the function
\begin{equation*} \fn{wgt}: \mathbb{B} \to \mathbb{Z} \end{equation*}
defined by \(\fn{wgt}(b) =\) weight of the bit string \(b\text{.}\)
  1. What are the domain and codomain of the function \(\fn{wgt}\text{?}\)
    Solution.
    The domain is the set of all bit strings, \(\mathbb{B}\text{,}\) and the codomain is the set of all integers, \(\mathbb{Z}\text{.}\)
  2. Evaluate \(\fn{wgt}(\bs{001})\text{,}\) \(\fn{wgt}(\bs{1111})\text{,}\) and \(\fn{wgt}(\lambda)\text{.}\)
    Solution.
    The weight of a bit string is the number of \(\bs{1}\) s in the bit string. Since \(\bs{001}\) has one \(\bs{1}\text{,}\) \(\fn{wgt}(\bs{001})=1\text{.}\) Since \(\bs{1111}\) has four \(\bs{1}\) s, \(\fn{wgt}(\bs{1111})=4\text{.}\) Since \(\lambda\) has no \(\bs{1}\) s, \(\fn{wgt}(\lambda)=0\text{.}\)
  3. Describe all bit strings \(b\) such that \(\fn{wgt}(b)=0\text{.}\)
    Solution.
    For a bit string to have weight 0, it cannot contain any \(\bs{1}\) s. That is, it must be empty or entirely \(\bs{0}\) s. We can list such strings as \(\lambda, \bs{0}, \bs{00}, \bs{000}, \bs{0000}, \ldots\text{.}\)
  4. For a positive integer \(n\text{,}\) describe a bit string \(b\) such that \(\fn{wgt}(b) = n\text{.}\)
    Solution.
    We are looking for a bit string \(b\) that has weight \(n\) or, equivalently, that contains \(n\) \(\bs{1}\) s. The simplest example is
    \begin{equation*} b = \underbrace{\bs{11}\ldots\bs{1}}_{n}\text{,} \end{equation*}
    the bit string with \(n\) 1s. Other answers are possible, such as
    \begin{equation*} b = \bs{0}\underbrace{\bs{11}\ldots\bs{1}}_{n }\bs{0} \end{equation*}
  5. What is the image of the function \(\fn{wgt}\text{?}\)
    Solution.
    It is not possible to have a negative weight. We saw in (d) and (c) that any non-negative integer is the weight of some bit strings. Therefore, the image of \(\str{wgt}\) is \(\mathbb{N}\text{.}\)
It is your turn to practice with functions on bit strings.

Activity 6.2.D Functions on bit strings.

Β 
  1. The function
    \begin{equation*} l:\mathbb{B} \to \mathbb{Z} \end{equation*}
    defined by \(l(b) =\) the length of the bit string \(b\text{.}\) Evaluate \(l(\bs{0})\) and \(l(\bs{1011})\text{.}\)
  2. The function
    \begin{equation*} \fn{lastbit}:\mathbb{B}^* \to \mathbb{B} \end{equation*}
    defined by \(\fn{lastbit}(b) =\) the last bit in the bit string \(b\text{.}\) Evaluate \(\fn{lastbit}(\bs{0})\) and \(\fn{lastbit}(\bs{1011})\text{.}\)
  3. The function
    \begin{equation*} \fn{append}: \mathbb{B}\to \mathbb{B}^* \end{equation*}
    defined by \(\fn{append}(b)=b\bs{1}\text{,}\) literally the string \(b\) with a \(\bs{1}\) added to the right. Evaluate \(\fn{append}(\bs{0})\) and \(\fn{append}(\bs{1011})\text{.}\)
  4. The function
    \begin{equation*} \fn{reverse}:\mathbb{B}\to \mathbb{B} \end{equation*}
    defined by \(\fn{reverse}(b)=\overleftarrow{b}\text{,}\) where \(\overleftarrow{b}\) means the bit string \(b\) written in reverse order. Evaluate \(\fn{reverse}(\bs{0})\) and \(\fn{reverse}(\bs{1011})\text{.}\)
  5. The function
    \begin{equation*} f:\mathbb{B}^*\to \mathbb{B} \end{equation*}
    defined by
    \begin{equation*} f(b)= \left\{ \begin{array}{ll} b \amp \text{ if the last bit of the bit string } b \text{ is } \bs{0} \\ b \text{ without its last bit } \amp \text{ if the last bit of the bit string } b \text{ is } \bs{1} \end{array} \right.\text{.} \end{equation*}
    Evaluate \(f(\bs{0})\) and \(f(\bs{1011})\text{.}\)
  6. Define a simple-to-describe function \(g:\mathbb{B}^*\to \mathbb{B}^*\) such that \(g(\bs{1011}) = \bs{0100}\text{,}\) \(g(\bs{110})= \bs{001}\text{,}\) and \(g(\bs{000011}) = \bs{111100}\text{.}\)
  7. Define a simple-to-describe function \(h:\mathbb{B}^*\to \mathbb{B}^*\) such that \(g(\bs{1011}) = \bs{10111}\text{,}\) \(g(\bs{110})= \bs{1100}\text{,}\) and \(g(\bs{000011}) = \bs{0000110}\text{.}\) Hint: even.

Subsection 6.2.E Exercises

Subsubsection Exercises for 6.2.A Floor and Ceiling

1. Practice.

In this exercise, evaluate without using technology.
  1. Evaluate \(\lfloor 14.5 \rfloor\text{,}\) \(\lfloor 14 \rfloor\text{,}\) and \(\lfloor -14.5 \rfloor\text{.}\)
  2. Evaluate \(\lceil 14.5 \rceil\text{,}\) \(\lceil 14 \rceil\text{,}\) and \(\lceil -14.5 \rceil\text{.}\)
  3. Evaluate \(\left\lfloor \frac{7}{3} \right\rfloor\) and \(\left\lceil \frac{7}{3} \right\rceil\text{.}\)
Check.
  1. 14, 14, -15
  2. Hint: Now round up (to the right on the number line).
  3. Hint: \(\frac{7}{3} = 2.\overline{3}\)

3. Practice.

The function
\begin{equation*} \fn{ceil}: \mathbb{R} \to \mathbb{Z} \end{equation*}
is defined by \(\fn{ceil}(x) = \lceil x \rceil\text{.}\)
  1. Identify the domain and codomain of the function \(\str{ceil}\text{.}\)
  2. Evaluate \(\fn{ceil}(60.7)\text{,}\) \(\fn{ceil}(60)\text{,}\) and \(\fn{ceil}(61)\text{.}\)
  3. Give an example of a real number \(x\) such that \(\fn{ceil}(x) = 11\text{.}\) Now find a different real number \(s\) such that \(\fn{ceil}(x)=11\text{.}\)
  4. Describe all real numbers \(x\) such that \(\fn{ceil}(x)=11\text{.}\) Answer using an inequality and also using interval notation.
Check.
  1. The domain is \(\mathbb{R}\) and the codomain is \(\mathbb{Z}\text{.}\)
  2. Hint: They are not all the same answer.
  3. Hint: You can use \(x=11\) but then you need a different second example.
  4. Hint: The interval is \((11,12]\text{.}\)

4. Understand.

Each of the following statements is false. Find a counterexample.
  1. For any real number \(x\text{,}\) we have \(10 \lceil x \rceil = \lceil 10x \rceil\text{.}\)
  2. For any real numbers \(x\) and \(y\text{,}\) if \(x > y\text{,}\) then \(\lfloor x \rfloor > \lfloor y \rfloor\text{.}\)

5. Understand.

Β 
  1. Give an example of real numbers \(x\) and \(y\) that are not integers such that \(\lfloor x +y \rfloor = \lfloor x \rfloor + \lfloor y \rfloor\text{.}\)
  2. Give a counterexample to the conjecture that \(\lfloor x +y \rfloor = \lfloor x \rfloor + \lfloor y \rfloor\) for all real numbers \(x\) and \(y\text{.}\)
  3. Give an example of real numbers \(x\) and \(y\) that are not integers such that \(\lceil xy \rceil = \lceil x \rceil \lceil y \rceil\text{.}\)
  4. Give a counterexample to the conjecture that \(\lceil xy \rceil = \lceil x \rceil \lceil y \rceil\) for all real numbers \(x\) and \(y\text{.}\)
Check.
  1. Hint: Make sure the decimal parts of \(x\) and \(y\) do not add up to more than 1.
  2. Hint: A counterexample should have \(\lfloor x+y \rfloor \neq \lfloor x \rfloor + \lfloor y \rfloor\text{.}\)
  3. Hint: One possible example is \(x = 2.9\) and \(y = 2.9\text{.}\) Either use a different example or show how to check that this example works.
  4. Hint: A counterexample should have \(\lceil xy \rceil \neq \lceil x \rceil \lceil y \rceil\text{.}\)

6. Understand.

Β 
  1. Give an example of a real number \(x\) where
    \begin{equation*} \lfloor -x \rfloor \neq -\lfloor x \rfloor\text{.} \end{equation*}
  2. Make a conjecture about how \(\lfloor -x \rfloor\) can be simplified to an expression with the negative sign on the outside.

7. Understand.

The function
\begin{equation*} h: \mathbb{N} \to \mathbb{N} \end{equation*}
is defined by \(h(n) = \left\lfloor \frac{n+1}{3} \right\rfloor\text{.}\)
  1. Explain why \(\left\lfloor \frac{n+1}{3} \right\rfloor\) is always a nonnegative integer.
  2. Identify the domain and codomain of the function \(h\text{.}\)
  3. Evaluate \(h(4)\text{,}\) \(h(5)\text{,}\) and \(h(6)\text{.}\)
  4. Draw the dot diagram for \(h\) showing at least \(n=0,1,2,3,4,5,6\text{.}\)
Check.
  1. Hint: The floor function always produces an integer. Explain why it is greater than or equal to zero.
  2. Hint: They are the same set.
  3. 1, 2, 2
  4. Hint: Make sure your domain and codomain are correct.

9. Explore.

Β 
  1. Calculate \(20 \fn{ div } 7\) and \(20 \fn{ mod } 7\) by hand.
  2. Write a formula for \(a \fn{ div } n\) in terms of \(a\) and \(n\text{.}\) Use \(\frac{a}{n}\text{,}\) not \(a \div n\text{,}\) in your formula. Hint: Your answer should involve floor or ceiling.
  3. Use your answer to 9.(b) to write a formula for \(a \fn{ mod } n\) in terms of \(a\) and \(n\text{.}\)

10. Explore.

The function
\begin{equation*} r: \mathbb{R} \to \mathbb{R} \end{equation*}
is defined by \(r(x)= \lfloor x + 0.5\rfloor\text{.}\)
  1. Evaluate \(r(2)\text{,}\) \(r(2.4)\text{,}\) \(r(2.6)\text{,}\) and \(r(2.5)\text{.}\)
  2. Evaluate \(r(-1)\text{,}\) \(r(-1.3)\text{,}\) \(r(-1.7)\text{,}\) and \(r(-2.5)\text{.}\)
  3. Describe the effect of the function \(r\) in words.
Check.
  1. Hint: \(r(2.4)=2\)
  2. Hint: \(r(-1.3) = -1\)
  3. Hint: Summarize the effect of the function \(r\text{.}\)

Subsubsection Exercises for 6.2.B Number-theoretic Functions

11. Practice.

Β 
  1. The function \(g(n)=\) the largest integer less than or equal to \(\sqrt{n}\text{.}\) Evaluate \(g(17)\text{,}\) \(g(30)\text{,}\) and \(g(9)\text{.}\) Show work.
  2. The function
    \begin{equation*} \fn{fivepart}: \mathbb{N} \to \mathbb{N} \end{equation*}
    is defined by \(\fn{fivepart}(n)\) is the highest power of five that divides \(n\text{.}\) Note that \(1 = 5^0\) is a power of five. Evaluate \(\fn{fivepart}(30)\text{,}\) \(\fn{fivepart}(24)\text{,}\) and \(\fn{fivepart}(75)\text{.}\) Show work
  3. The function
    \begin{equation*} f:\mathbb{Z}^+ \to \mathbb{Z}^+ \end{equation*}
    defined by \(f(n)=\) the number of distinct positive primes that divide \(n\text{.}\) Evaluate \(f(12)\text{,}\) \(f(16)\text{,}\) \(f(30)\text{,}\) and \(f(1)\text{.}\) Show work.
Check.
  1. Hint: \(g(17) = 4\text{.}\)
  2. Hint: \(\fn{fivepart}(30)=5\text{.}\)
  3. Hint: \(f(12) = 2\text{.}\)

12. Practice.

Consider the function
\begin{equation*} t: \mathbb{Z}^+ \to \mathbb{Z} \end{equation*}
defined by
\begin{equation*} t(n)= \left\{ \begin{array}{cl} 2 \amp \text{ if } 2 \mid n \land 5 \mid n \\ 1 \amp \text{ if } 2 \mid n \oplus 5 \mid n \\ 0 \amp \text{ if } 2 \nmid n \land 5 \nmid n \end{array} \right.\text{.} \end{equation*}
Recall \(\land\) means β€œand” whereas \(\oplus\) means β€œxor”, the exclusive or.
  1. Evaluate \(t(20)\) and \(t(6)\text{.}\) Show work.
  2. Describe the image of \(t\text{.}\)
  3. How many integers \(n\) between 1 and 20 have \(t(n) = 0\text{?}\) List them.

13. Practice.

Consider the function
\begin{equation*} \fn{gplt}:\mathbb{Z}^+ \to \mathbb{N} \end{equation*}
defined by
\begin{equation*} \fn{gplt}(n)=\left\{\begin{array}{cl} 0 \amp \text{ if } n=1 \\ \text{ the largest prime less than or equal to } n \amp \text{ if } n \ge 2 \end{array} \right.\text{.} \end{equation*}
The \(\str{gplt}\) stands for β€œgreatest prime less than”.
  1. Evaluate \(\fn{gplt}(16)\text{.}\) Show work.
  2. Make a table showing the values of \(\fn{gplt}(n)\) for \(n=1,2,3,\ldots 20\text{.}\)
  3. Draw the dot diagram for the function \(\fn{gplt}\) showing \(\fn{gplt}(n)\) for \(n=1,2,3,\ldots 20\text{.}\)
Check.
  1. Hint: \(\fn{gplt}(16)=13\text{.}\)
  2. Hint: The entries in the second row of your table should all be primes.
  3. Hint: Make sure the domain and codomain are correct.

14. Understand.

In ExampleΒ 6.2.7, we defined the function
\begin{equation*} \fn{countdiv}: \mathbb{Z}^+ \to \mathbb{Z}^+ \end{equation*}
is defined by \(\fn{countdiv}(n)=\) the number of (positive) divisors of \(n\text{.}\)
  1. Make a table showing the values of \(\fn{countdiv}(n)\) for \(n = 1, 2, 3, 4, 5, 6, 7, 8, 9, 10\text{.}\)
  2. What’s the name for a number \(n\) with \(\fn{countdiv}(n) = 2\text{?}\)
  3. Find a value of \(n\) such that \(\fn{countdiv}(n) = 5\text{.}\) Now find another.
  4. What can you say about \(n\) if \(\fn{countdiv}(n)\) is odd? Hint: Lockers Puzzle ActivityΒ 4.1.A.
Check.
  1. Hint: The numbers in the second row of the table should include one 1, four 2s, two 3s, and three 4s.
  2. It is prime.
  3. Hint: One example is 16.
  4. Hint: Typically divisors come in pairs so \(\fn{countdiv}(n)\) is usually even. If it is odd, then some divisor must be paired with itself.

15. Understand.

Recall from DefinitionΒ 4.5.10 that Euler’s phi function
\begin{equation*} \phi: \mathbb{Z}^+ \to \mathbb{Z}^+ \end{equation*}
is defined by \(\phi(n)=\) the number of integers between 1 and \(n\) that are coprime to \(n\text{.}\)
  1. Identify the domain and codomain of \(\phi\text{.}\)
  2. Evaluate \(\phi(12)\text{.}\) Show work.
  3. Describe all integers \(n\) such that \(\phi(n)=n-1\text{.}\)
  4. Give a counterexample to the conjecture: for all positive integers \(a\) and \(b\text{,}\) if \(a \lt b\text{,}\) then \(\phi(a) \lt \phi(b)\text{.}\)
Check.
  1. Hint: They are the same set.
  2. Hint: \(\phi(12) = 4\text{.}\)
  3. Hint: The only integer smaller than \(n\) that divides \(n\) is 1.
  4. Hint: Try using a prime for \(b\text{.}\)

16. Understand.

The function
\begin{equation*} \fn{oddless}:\mathbb{N} \to \mathbb{N} \end{equation*}
is defined by \(\fn{oddless}(n) =\) the number of positive odd integers less than or equal to \(n\text{.}\)
  1. List the positive odd integers less than or equal to five.
  2. Evaluate \(\fn{oddless}(5)\) and \(\fn{oddless}(6)\text{.}\)
  3. Draw the dot diagram for the function \(\fn{oddless}\) showing \(\fn{oddless}(n)\) for \(n=0,1,2,3,4,5,6\text{.}\)
  4. Write a formula for the rule for \(\fn{oddless}\text{.}\) Hint: The floor or ceiling is involved.
Check.
  1. Hint: There are three positive odd integers less than or equal to five.
  2. Hint: \(\fn{oddless}(5)=3\text{.}\)
  3. Hint: Include appropriate … in your dot diagram.
  4. Hint: For inspiration, look at the function in Exercise 7.

17. Recap.

Do you know …
  1. How to read definitions of functions involving divisors, primes, and other number-theoretic quantities?
  2. How \(\fn{countdiv}(n)\text{,}\) \(\pi(n)\text{,}\) and \(\phi(n)\) are defined? (These are famous functions.)

19. Explore.

The function
\begin{equation*} g: \mathbb{Z}^+ \to \mathbb{Z} \end{equation*}
is defined by \(g(n) = \lfloor \fn{log}(n) \rfloor + 1\text{.}\)
  1. Evaluate \(g(1000)\) without using a calculator.
  2. Evaluate \(g(6)\text{,}\) \(g(67)\text{,}\) \(g(678)\text{,}\) and \(g(6789)\text{.}\) Use technology (calculator or Internet search) to evaluate the necessary logs.
  3. Describe what \(g\) is counting.

Subsubsection Exercises for 6.2.C Graph-theoretic Functions

20. Practice.

Let \(\mathbb{G}_{10}\) denote the set of all graphs with ten vertices. The function
\begin{equation*} \fn{cleaf}: \mathbb{G}_{10} \to \mathbb{N} \end{equation*}
is defined by \(\fn{cleaf}(G)\) is the number of leaves (degree 1 vertices) in the graph \(G\text{.}\)
  1. Evaluate \(\fn{cleaf}(P_{10})\text{,}\) \(\fn{cleaf}(K_{1,9})\text{,}\) and \(\fn{cleaf}(C_{10})\) for the path \(P_{10}\text{,}\) the complete bipartite graph (star) \(K_{1,9}\text{,}\) and the cycle \(C_{10}\text{.}\)
  2. Draw a graph \(G\) with ten vertices and \(\fn{cleaf}(G)=0\text{.}\)
  3. Draw a graph \(G\) with ten vertices and \(\fn{cleaf}(G)=5\text{.}\)
Check.
  1. Hint: \(\fn{cleaf}(P_{10})=2\) and \(\fn{cleaf}(K_{1,9})=9\text{.}\)
  2. Hint: Try a cycle.
  3. Hint: Try a tree or a robot, as we saw in ActivityΒ 3.5.C.

21. Practice.

Let \(\mathbb{G}_{10}\) denote the set of all graphs with ten vertices. The function
\begin{equation*} \chi: \mathbb{G}_{10} \to \mathbb{N} \end{equation*}
is defined by \(\chi(G)\) is the chromatic number of the graph \(G\text{,}\) as defined in DefinitionΒ 3.3.5.
  1. Identify the domain and codomain of \(\chi\text{.}\)
  2. Evaluate \(\chi(C_{10})\) and \(\chi(K_{10})\) for the cycle \(C_{10}\) and the complete graph \(K_{10}\text{.}\)
  3. Draw graph \(G\) with ten vertices and \(\chi(G)=3\text{.}\)
Check.
  1. The domain is \(\mathbb{G}_{10}\) and the codomain is \(\mathbb{N}\text{.}\)
  2. Hint: Alternate colors around the cycle. In the complete graph, every vertex needs to be its own color.
  3. Hint: Include at least one 3-cycle in your graph, but be careful that you do not have any \(K_4\) subgraphs.

22. Practice.

Let \(\mathbb{G}\) denote the set of all graphs. The function
\begin{equation*} c: \mathbb{G} \to \mathbb{N} \end{equation*}
is defined by \(c(G)=\) the number of edges in the longest path in \(G\text{,}\) as we saw in ActivityΒ 6.2.C.
  1. Identify the domain and codomain of \(c\text{.}\)
  2. Evaluate \(c(K_{2,3})\) for the complete bipartite graph \(K_{2,3}\text{.}\) Be careful: A path cannot repeat a vertex.
  3. Draw a graph \(G\) with \(c(G)=3\text{.}\)
  4. Evaluate \(c(T)\) where \(T\) is the tree in FigureΒ 6.2.37.
Figure 6.2.37. The tree for Exercise 22 and Exercise 27.

23. Understand.

Let \(\mathbb{G}_{10}\) denote the set of all graphs with ten vertices. The function
\begin{equation*} \Delta:\mathbb{G}_{10} \to \mathbb{N} \end{equation*}
is defined by \(\Delta(G)\) is the maximum degree of any vertex in \(G\text{,}\) as defined in DefinitionΒ 3.1.9.
  1. Identify the domain and codomain of \(\Delta\text{.}\)
  2. Evaluate \(\Delta(P_{10})\) and \(\Delta(K_{2,5})\) for the path \(P_{10}\) and the complete bipartite graph \(K_{2,5}\text{.}\)
  3. Draw a graph \(G\) with ten vertices and \(\Delta(G)=3\text{.}\)
  4. Describe the image of \(\Delta\text{.}\)
Check.
  1. Hint: They are not the same set.
  2. Hint: The degree sequence of \(P_{10}\) is \(2, 2, 1, 1, 1, 1, 1, 1, 1, 1\) and the degree sequence of \(K{2,5}\) is \(5,5,2,2,2,2,2\text{.}\)
  3. Hint: One possible example is a wheel.
  4. Hint: In a group of ten people, what is the maximum number of handshakes each person would do (if only shaking hands with someone else once)?

24. Understand.

Let \(\mathbb{G}\) denote the set of all graphs. The function \(k: \mathbb{Z}^+ \to \mathbb{G}\) by \(k(n) = K_{n,n+1}\text{,}\) the complete bipartite graph.
  1. Identify the domain and codomain of \(k\text{.}\)
  2. Evaluate \(k(3)\) by name and draw your answer.
  3. Is there a positive integer \(n\) such that \(k(n)=P_3\text{,}\) the path? Explain. Hint: Be careful.
Check.
  1. Hint: They are not the same set.
  2. Hint: It is \(K_{3,4}\text{.}\)
  3. Hint: Yes. Think about alternative ways to draw \(P_3\text{.}\)

25. Understand.

Let \(\mathbb{G}\) denote the set of all graphs. The function
\begin{equation*} g: \mathbb{G} \to \mathbb{N} \end{equation*}
is defined by \(g(G) =\) the number of vertices in the smallest cycle subgraph in \(G\text{,}\) if \(G\) contains any cycles, and 0 if \(G\) is acyclic.
  1. Evaluate \(g(K_5)\) and \(g(P_5)\) for the complete graph \(K_5\) and the path \(P_5\text{.}\)
  2. Give an example of a graph \(G\) with \(g(G) = 4\text{.}\)
  3. Give an example of a graph \(G\) with \(g(G) = 0\text{.}\)

27. Explore.

Let \(\mathbb{T}\) denote the set of all trees as defined in DefinitionΒ 3.4.33 and let \(\mathbb{T}_3\) denote the set of all trees with at least three vertices. The function
\begin{equation*} \fn{prune}: \mathbb{T}_3 \to \mathbb{T} \end{equation*}
is defined by \(\fn{prune}(T)=\) the graph we get when we remove all leaves and their corresponding edges from \(T\text{.}\)
  1. Evaluate \(\fn{prune}(P_5)\) and \(\fn{prune}(K_{1,6})\) where \(P_5\) is the path and \(K_{1,6}\) is the complete bipartite graph (star). You may draw the answer or state its standard name.
  2. Evaluate \(\fn{prune}(T)\) where \(T\) is the tree drawn in FigureΒ 6.2.37. Draw your answer.
  3. What is the name of a graph where \(\fn{prune}(T)\) is a path? Hint: Answer is in Exercise 20 from SectionΒ 3.4.

Subsubsection Exercises for 6.2.D Functions Involving Bit Strings

28. Practice.

In ActivityΒ 6.2.D, we evaluated the function
\begin{equation*} \fn{reverse}: \mathbb{B} \to \mathbb{B} \end{equation*}
defined by \(\fn{reverse}(b) = \overleftarrow{b}\) where \(\overleftarrow{b}\) means the bit string \(b\) written in reverse order.
  1. Evaluate \(\fn{reverse}(\bs{001}), \fn{reverse}(\bs{101001})\text{,}\) and \(\fn{reverse}(\lambda)\text{.}\)
  2. Find a bit string \(b\) such that \(\fn{reverse}(b) = \bs{1100}\text{.}\)
  3. Describe the fixed points of the function \(\fn{reverse}\text{.}\) That means, describe all bit strings \(b\) such that \(\fn{reverse}(b) =b\text{.}\) Hint: There is a name for such strings.
Check.
  1. Hint: \(\fn{reverse}(\bs{001})=\bs{100}\text{.}\)
  2. Hint: There is only one correct answer.
  3. Hint: The same name is used for words that read the same forward and backwards.

29. Practice.

In ActivityΒ 6.2.D, we saw the function
\begin{equation*} \fn{lastbit}:\mathbb{B}^* \to \mathbb{B} \end{equation*}
defined by \(\fn{lastbit}(b) =\) the last bit in the bit string \(b\text{.}\)
  1. Evaluate \(\fn{lastbit}(\bs{0101})\text{.}\)
  2. Find a different bit string \(b\) such that \(\fn{lastbit}(b)=\fn{lastbit}(\bs{0101})\text{.}\)
  3. Identify the domain and codomain of the function \(\fn{lastbit}\text{.}\)
  4. Describe the image of the function \(\fn{lastbit}\text{.}\)
  5. Give an example of a bit string that is in the codomain but not in the image.
Check.
  1. \(\displaystyle \bs{1}\)
  2. Hint: They are not the same set.
  3. Hint: It is a finite set.
  4. Hint: Use a bit string of length two.

30. Practice.

In ActivityΒ 6.2.D, we saw the function
\begin{equation*} \fn{append}: \mathbb{B}\to \mathbb{B}^* \end{equation*}
defined by \(\fn{append}(b)=b\bs{1}\text{,}\) literally the string \(b\) with a \(\bs{1}\) added to the right.
  1. Evaluate \(\fn{append}(\bs{0101})\text{.}\)
  2. Give an example of a bit string \(b\) such that \(\fn{append}(b)= \bs{0101}\text{.}\)
  3. Identify the domain and codomain of the function \(\fn{append}\text{.}\)
  4. Describe the image of the function \(\fn{append}\text{.}\)
  5. Give an example of a bit string that is in the codomain but not in the image.
Check.
  1. \(\displaystyle \bs{01011}\)
  2. Hint: There is only one correct answer.
  3. The domain is \(\mathbb{B}\) and the codomain is \(\mathbb{B}^*\text{.}\)
  4. Hint: No bit string in the image ends in \(\bs{0}\text{.}\)
  5. Hint: Any bit string that ends in \(\bs{0}\) works.

31. Understand.

Consider the function
\begin{equation*} \fn{runzero}: \mathbb{B} \to \mathbb{N} \end{equation*}
defined by \(\fn{runzero}(b) =\) the longest number of consecutive \(\bs{0}\) s in the bit string \(b\text{.}\)
  1. Identify the domain and codomain of the function \(\fn{runzero}\text{.}\)
  2. Evaluate \(\fn{runzero}(\bs{10100010011})\text{,}\) \(\fn{runzero}(\bs{0010})\) and \(\fn{runzero}(\bs{11111})\text{.}\)
  3. List all bit strings of length 6 with \(\fn{runzero}(b) = 4\text{.}\)
  4. Given a natural number \(n\text{,}\) describe a general bit string \(b\) such that \(\fn{runzero}(b) = n\text{.}\) Your answer should involve \(n\text{.}\)
Check.
  1. Hint: They are different sets.
  2. Hint: \(\fn{runzero}(\bs{10100010011})=3\text{.}\)
  3. Hint: There are exactly five such bit strings. Make sure you are not including bit strings with longer runs of zeros.

32. Understand.

Consider the function \(h: \mathbb{N} \to \mathbb{B}\) by \(f(n)=\) the bit string consisting of \(n\) \(\bs{0}\) s followed by \(n\) \(\bs{1}\) s.
  1. Identify the domain and codomain of the function \(h\text{.}\)
  2. Evaluate \(h(3)\text{,}\) \(h(2)\) and \(h(0)\text{.}\)
  3. Give an example of a bit string \(b\) for which there is no value of \(n\) such that \(f(n)=b\text{.}\)

33. Understand.

The function
\begin{equation*} h: \mathbb{B}^* \to \mathbb{B} \end{equation*}
defined by
\begin{equation*} h(b) = \left\{ \begin{array}{cl} b \amp \text{ if the last bit of the bit string } b \text{ is \bs{0}} \\ b \text{ without its last bit } \amp \text{ if the last bit of the bit string } b \text{ is \bs{1}} \end{array} \right. \end{equation*}
  1. Evaluate \(h(\bs{1011})\) and \(h(\bs{1010})\text{.}\)
  2. Find two different bit strings, \(b\) and \(c\text{,}\) such that \(h(b) = h(c)\text{.}\)
  3. For a bit string \(c\text{,}\) describe a bit string \(b\) such that \(h(b) = c\text{.}\)
Check.
  1. \(h(\bs{1011})=\bs{101}\text{,}\) \(h(\bs{1010})=\bs{1010}\)
  2. Hint: Try an example where \(b\) ends in \(\bs{0}\) and \(c\) ends in \(\bs{1}\text{.}\)
  3. Hint: Your answer needs to work for all bit strings \(c\text{.}\)

34. Understand.

For this problem, let \(\mathbb{A}\) be the set of all strings of uppercase letters \(\str{A}-\str{Z}\text{,}\) including the empty string \(\lambda\text{,}\) and let \(\mathbb{A}^*\) be the set of all nonempty strings of uppercase letters \(\str{A}-\str{Z}\text{.}\)
  1. Define \(\fn{trim}:\mathbb{A}^* \to \mathbb{A}\) by \(\fn{trim}(s) =\) the string \(s\) without its first character. Identify the domain and codomain of \(\fn{trim}\) and evaluate \(\fn{trim}(\str{HAIR})\) and \(\fn{trim}(\str{X})\text{.}\)
  2. Define \(\fn{countE}:\mathbb{A}^* \to \mathbb{Z}\) by \(\fn{countE}(s) =\) the number of occurrences of \(\str{E}\) in the string \(s\text{.}\) Identify the domain and codomain of \(\fn{countE}\) and evaluate \(\fn{countE}(\str{STEEP})\text{,}\) \(\fn{countE}(\str{STEP})\text{,}\) and \(\fn{countE}(\str{STOP})\text{.}\)
  3. Define \(\fn{isE}:\mathbb{A}^* \to \{\text{ yes } , \text{ no } \}\) by
    \begin{equation*} \fn{isE}(s) = \left\{ \begin{array}{cl} \text{ yes } \amp \text{ if \str{E} is in } s \\ \text{ no } \amp \text{ if \str{E} is not in } s \end{array} \right.\text{.} \end{equation*}
    Identify the domain and codomain of \(\fn{isE}\) and evaluate \(\fn{isE}(\str{STEEP})\) and \(\fn{isE}(\str{DOG})\text{.}\)

36. Explore.

Β 
  1. Define a simple-to-describe function \(f:\mathbb{B}^*\to \mathbb{B}^*\) such that \(f(\bs{1011}) = \bs{10111}\text{,}\) \(f(\bs{110})= \bs{1100}\text{,}\) and \(f(\bs{000011}) = \bs{0000111}\text{.}\)
  2. Define a simple-to-describe function \(g:\mathbb{B}\to \mathbb{B}\) such that \(g(\bs{1011}) = 111\text{,}\) \(g(\bs{110})= 11\text{,}\) and \(g(\bs{0000}) = \lambda\text{.}\)
  3. Define a simple-to-describe function \(h:\mathbb{B}^*\to \mathbb{Z}\) such that \(h(\bs{1011}) = 2\text{,}\) \(h(\bs{110})= 1\text{,}\) and \(h(\bs{000011}) = -2\text{.}\) Hint: count \(\bs{0}\)s and \(\bs{1}\)s.