Next, we introduce two important functions in discrete mathematics, namely, the floor and ceiling functions. Letx be a real number. The floor function rounds x down to the closest integer less than or equal tox, and the ceiling function rounds x up to the closest integer greater than or equal tox. These functions are often used when objects are counted. They play an important role in the analysis of the number of steps used by procedures to solve problems of a particular size.
FIGURE 8 The Graph of f (n) = 2n + 1 from Z to Z.
(3, 9) (–3, 9)
(2, 4)
(1, 1) (–1, 1)
(0, 0) (–2, 4)
FIGURE 9 The Graph of f (x) = x2from Z to Z.
DEFINITION 12 The floor function assigns to the real numberx the largest integer that is less than or equal to x. The value of the floor function at x is denoted by x. The ceiling function assigns to the real numberx the smallest integer that is greater than or equal to x. The value of the ceiling function atx is denoted by x.
Remark: The floor function is often also called the greatest integer function. It is often denoted by[x].
EXAMPLE 26 These are some values of the floor and ceiling functions:
12 = 0, 12 = 1, −12 = −1, −12 = 0, 3.1 = 3, 3.1 = 4, 7 = 7, 7 = 7. ▲ We display the graphs of the floor and ceiling functions in Figure 10. In Figure 10(a) we display the graph of the floor functionx. Note that this function has the same value throughout the interval[n, n + 1), namely n, and then it jumps up to n + 1 when x = n + 1. In Figure 10(b) we display the graph of the ceiling functionx. Note that this function has the same value throughout the interval(n, n + 1], namely n + 1, and then jumps to n + 2 when x is a little larger thann + 1.
The floor and ceiling functions are useful in a wide variety of applications, including those involving data storage and data transmission. Consider Examples 27 and 28, typical of basic calculations done when database and data communications problems are studied.
EXAMPLE 27 Data stored on a computer disk or transmitted over a data network are usually represented as a string of bytes. Each byte is made up of 8 bits. How many bytes are required to encode 100 bits of data?
Solution:To determine the number of bytes needed, we determine the smallest integer that is at least as large as the quotient when 100 is divided by 8, the number of bits in a byte. Consequently,
100/8 = 12.5 = 13 bytes are required. ▲
EXAMPLE 28 In asynchronous transfer mode (ATM) (a communications protocol used on backbone networks), data are organized into cells of 53 bytes. How many ATM cells can be transmitted in 1 minute over a connection that transmits data at the rate of 500 kilobits per second?
Solution:In 1 minute, this connection can transmit 500,000 · 60 = 30,000,000 bits. Each ATM cell is 53 bytes long, which means that it is 53· 8 = 424 bits long. To determine the number
(a) y =[x]
3 2 1
–2 –3 –1 –2
–3 1 2 3
–1
(b) y =[x]
3 2 1
–2 –3 –1 –2
–3 1 2 3
–1
FIGURE 10 Graphs of the (a) Floor and (b) Ceiling Functions.
TABLE 1 Useful Properties of the Floor and Ceiling Functions.
(n is an integer,x is a real number) (1a) x = n if and only if n ≤ x < n + 1 (1b) x = n if and only if n − 1 < x ≤ n (1c) x = n if and only if x − 1 < n ≤ x (1d) x = n if and only if x ≤ n < x + 1 (2) x − 1 < x ≤ x ≤ x < x + 1 (3a) −x = −x
(3b) −x = −x
(4a) x + n = x + n (4b) x + n = x + n
of cells that can be transmitted in 1 minute, we determine the largest integer not exceeding the quotient when 30,000,000 is divided by 424. Consequently, 30,000,000/424 = 70,754 ATM cells can be transmitted in 1 minute over a 500 kilobit per second connection. ▲
Table 1, withx denoting a real number, displays some simple but important properties of the floor and ceiling functions. Because these functions appear so frequently in discrete mathematics, it is useful to look over these identities. Each property in this table can be established using the definitions of the floor and ceiling functions. Properties (1a), (1b), (1c), and (1d) follow directly from these definitions. For example, (1a) states thatx = n if and only if the integer n is less than or equal tox and n + 1 is larger than x. This is precisely what it means for n to be the greatest integer not exceedingx, which is the definition of x = n. Properties (1b), (1c), and (1d) can be established similarly. We will prove property (4a) using a direct proof.
Proof:Suppose thatx = m, where m is a positive integer. By property (1a), it follows that m ≤ x < m + 1.Adding n to all three quantities in this chain of two inequalities shows that m + n ≤ x + n < m + n + 1. Using property (1a) again, we see that x + n = m + n = x + n.
This completes the proof. Proofs of the other properties are left as exercises.
The floor and ceiling functions enjoy many other useful properties besides those displayed in Table 1. There are also many statements about these functions that may appear to be correct, but actually are not. We will consider statements about the floor and ceiling functions in Examples 29 and 30.
A useful approach for considering statements about the floor function is to letx = n + , wheren = x is an integer, and , the fractional part of x, satisfies the inequality 0 ≤ < 1.
Similarly, when considering statements about the ceiling function, it is useful to writex = n − , wheren = x is an integer and 0 ≤ < 1.
EXAMPLE 29 Prove that ifx is a real number, then 2x = x + x +12.
Solution:To prove this statement we letx = n + , where n is an integer and 0 ≤ < 1. There are two cases to consider, depending on whether is less than, or greater than or equal to 12. (The reason we choose these two cases will be made clear in the proof.)
We first consider the case when 0≤ < 12. In this case, 2x = 2n + 2 and 2x = 2n because 0≤ 2 < 1. Similarly, x +12 = n + (12+ ), so x +12 = n, because 0 < 12 + < 1.
Consequently,2x = 2n and x + x +12 = n + n = 2n.
Next, we consider the case when 12 ≤ < 1. In this case, 2x = 2n + 2 = (2n + 1) + (2 − 1). Because 0 ≤ 2 − 1 < 1, it follows that 2x = 2n + 1. Because
x + 12 = n + (12+ ) = n + 1 + ( − 12) and 0 ≤ −12 < 1, it follows that x +12 = n + 1. Consequently, 2x = 2n + 1 and x + x +12 = n + (n + 1) = 2n + 1. This
con-cludes the proof. ▲
EXAMPLE 30 Prove or disprove thatx + y = x + y for all real numbers x and y.
Solution:Although this statement may appear reasonable, it is false. A counterexample is sup-plied byx = 12 andy = 12. With these values we find thatx + y = 12+21 = 1 = 1, but
x + y = 12 + 12 = 1 + 1 = 2. ▲
There are certain types of functions that will be used throughout the text. These include polynomial, logarithmic, and exponential functions. A brief review of the properties of these functions needed in this text is given in Appendix 2. In this book the notation logx will be used to denote the logarithm to the base 2 ofx, because 2 is the base that we will usually use for logarithms. We will denote logarithms to the baseb, where b is any real number greater than 1, by logbx, and the natural logarithm by ln x.
Another function we will use throughout this text is the factorial functionf : N → Z+, denoted byf (n) = n!. The value of f (n) = n! is the product of the first n positive integers, so f (n) = 1 · 2 · · · (n − 1) · n [and f (0) = 0! = 1].
EXAMPLE 31 We have f (1) = 1! = 1, f (2) = 2! = 1 · 2 = 2, f (6) = 6! = 1 · 2 · 3 · 4 · 5 · 6 = 720, and f (20) = 1 · 2 · 3 · 4 · 5 · 6 · 7 · 8 · 9 · 10 · 11 · 12 · 13 · 14 · 15 · 16 · 17 · 18 · 19 · 20 =
2,432,902,008,176,640,000. ▲
Example 31 illustrates that the factorial function grows extremely rapidly as n grows.
The rapid growth of the factorial function is made clearer by Stirling’s formula, a result from higher mathematics that tell us thatn! ∼√
2πn(n/e)n. Here, we have used the notationf (n) ∼ g(n), which means that the ratio f (n)/g(n) approaches 1 as n grows without bound (that is, limn→∞f (n)/g(n) = 1). The symbol ∼ is read “is asymptotic to.” Stirling’s formula is named after James Stirling, a Scottish mathematician of the eighteenth century.
JAMES STIRLING (1692–1770) James Stirling was born near the town of Stirling, Scotland. His family strongly supported the Jacobite cause of the Stuarts as an alternative to the British crown. The first information known about James is that he entered Balliol College, Oxford, on a scholarship in 1711. However, he later lost his scholarship when he refused to pledge his allegiance to the British crown. The first Jacobean rebellion took place in 1715, and Stirling was accused of communicating with rebels. He was charged with cursing King George, but he was acquitted of these charges. Even though he could not graduate from Oxford because of his politics, he remained there for several years. Stirling published his first work, which extended Newton’s work on plane curves, in 1717. He traveled to Venice, where a chair of mathematics had been promised to him, an appointment that unfortunately fell through. Nevertheless, Stirling stayed in Venice, continuing his mathematical work. He attended the University of Padua in 1721, and in 1722 he returned to Glasgow. Stirling apparently fled Italy after learning the secrets of the Italian glass industry, avoiding the efforts of Italian glass makers to assassinate him to protect their secrets.
In late 1724 Stirling moved to London, staying there 10 years teaching mathematics and actively engaging in research. In 1730 he published Methodus Differentialis, his most important work, presenting results on infinite series, summations, interpolation, and quadrature. It is in this book that his asymptotic formula forn! appears. Stirling also worked on gravitation and the shape of the earth; he stated, but did not prove, that the earth is an oblate spheroid. Stirling returned to Scotland in 1735, when he was appointed manager of a Scottish mining company. He was very successful in this role and even published a paper on the ventilation of mine shafts. He continued his mathematical research, but at a reduced pace, during his years in the mining industry. Stirling is also noted for surveying the River Clyde with the goal of creating a series of locks to make it navigable. In 1752 the citizens of Glasgow presented him with a silver teakettle as a reward for this work.