This articles explores some basic properties of the integer functions commonly known as floor and ceil. Most of the statements may seem trivial or obvious, but I, for one, have a tendency to forget just how exact you can be when it comes to expressions/equations where floor or ceil functions appear.
First, the definitions:
⌊x⌋=max{n∈Z∣n≤x} = the greatest integer less than or equal to x,
⌈x⌉=min{n∈Z∣n≥x} = the least integer greater than or equal to x,
for every real number x.
Equality
What can we say about x and n if n=⌊x⌋ or n=⌈x⌉? First of all, we obviously have n=x if and only if x is an integer. Let us now consider the floor function ⌊⋅⌋. With x some real number we have ⌊x⌋≤x, easily seen from the definition. Now let n=⌊x⌋ and assume x−1≥n which is equivalent to n+1≤x. But then n cannot be the greatest integer less than or equal to x so we have a contradiction. Since x was chosen arbitrarily we have x−1<⌊x⌋ for all x. Similar considerations can be made for the ceil function ⌈⋅⌉ and we get the important inequalities:
x−1<⌊x⌋≤x≤⌈x⌉<x+1.
At the same time, we have the right-going implications of the following statements (x is a real number and n an integer):
Let us show the fourth left-going implication. Assume x≤n<x+1 and set k=⌈x⌉. We then have x≤k<x+1 from which we get n<x+1≤k+1 and k<x+1≤n+1, so n=k=⌈x⌉. The remaining three left-going implication can be proved in much the same way.
From the statements above we can show some useful equalities:
n=⌊−x⌋⇔−x−1<n≤−x⇔x≤−n<x+1⇔−n=⌈x⌉,
so ⌊−x⌋=−⌈x⌉ for all x, and
⌊x⌋≤x<⌊x⌋+1⇔⌊x⌋+k≤x+k<⌊x⌋+k+1⇔⌊x⌋+k=⌊x+k⌋,
so ⌊x⌋+k=⌊x+k⌋ for all integer k. Naturally, the similar ⌈x⌉+k=⌈x+k⌉ also holds.
Inequalities
We now consider what can be said when inequalities are involved. Let x be some real number and n an integer. We then have the following:
x<nn<xx≤nn≤x⟺⌊x⌋<n,⟺n<⌈x⌉,⟺⌈x⌉≤n,⟺n≤⌊x⌋.
All we need to show these are ⌊x⌋≤x<⌊x⌋+1 and ⌈x⌉−1<x≤⌈x⌉ from the previous section, and the fact that n<m+1 is equivalent to n≤m when m and n are integers. Consider, for instance, the third statement from above. If x≤n then we have ⌈x⌉−1<x≤n, which implies ⌈x⌉≤n. On the other hand, if ⌈x⌉≤n then x≤n because x≤⌈x⌉. The remaining statements are shown in a similar manner.
Some Increasing Functions
Certain functions have special properties when used together with floor and ceil. Such a function
f:R→R must be continuous and monotonically increasing and whenever f(x) is integer we must have that x is integer. An example could be f(x)=x. Note that being continuous and monotonically increasing ensures a well-defined inverse f−1. One of the requirements can then be formulated as
f−1(y) must be integer for all integer y.
Similar derivations can be shown for ⌈⋅⌉ and we have
⌊f(x)⌋=⌊f(⌊x⌋)⌋and⌈f(x)⌉=⌈f(⌈x⌉)⌉,
for this class of functions. For f(x)=x we thus have
⌊x⌋=⌊⌊x⌋⌋and⌈x⌉=⌈⌈x⌉⌉.
Fractions
The result of the previous section also applies to f(x)=(x+n)/m for integer m,n and m>0. The positivity of m ensures that f is monotonically increasing and f−1(y)=my−n is clearly integer for integer y. We now have
When applying floor or ceil to rational numbers, one can be derived from the other. Since (q−1)m+1≤n≤qm can be rewritten as qm≤n+m−1≤(q+1)m−1 we get
⌈mn⌉=⌊mn+m−1⌋,
and similarly
⌊mn⌋=⌈mn−m+1⌉.
Logarithms
Let logbx be the logarithm of x, base b (x≥1, b>0, b=1). We first set f(x)=logbx for integer b, base 2 or 10 being the most common. Again, we can apply the theorem from earlier; f is continuous and monotonically increasing and f−1(y)=by is integer for integer y≥0, so we have
⌊logbx⌋=⌊logb⌊x⌋⌋and⌈logbx⌉=⌈logb⌈x⌉⌉,
for integer b≥2 and x≥1.
We conclude with some straightforward, but quite useful, statements: