8.4  Floor, Distance to the Integers, and Step Functions

Number Systems: From N to R gave every element of an Archimedean field an integer part (Number Systems: From N to R, Proposition 4.2.4). Here the integer part becomes a function on all of R, one that jumps at every integer. From it we build the distance to the nearest integer and the step functions. Section 8.6 builds its strange functions from these pieces.

8.4.1. The floor and the ceiling

Nobody needs a definition to round 3.7 down to 3. The integer 3 is the one with 3≤3.7<3+1. Rounding up gives 4, and the part left over, 3.7−3=0.7, lies between 0 and 1.

For a number such as 2+3, with no decimal expansion handed to us, we need to know that the answer exists and is unique. Both facts are already proved:

Throughout, integers are read inside R, as in Number Systems. The embedding ιR respects sums, products and order and reflects order (Number Systems: From N to R, Theorem 4.2.2). So a sum, product or comparison of integers means the same in Z and in R.

The floor of x is the integer you reach by stepping down from x to the nearest integer at or below it.

Definition 8.4.1 (Floor, Ceiling, Fractional Part)

Let x∈R. The floor of x, written ⌊x⌋, is the unique m∈Z with m≤x<m+1. The ceiling of x is ⌈x⌉:=−⌊−x⌋. The number x−⌊x⌋ is the fractional part of x; it lies in [0,1).

Existence and uniqueness are Number Systems: From N to R, Proposition 4.2.4 for F=R. So x↦⌊x⌋ is a function R→R with values in Z, a real function in the sense of Definition 8.1.1. The fractional part lies in [0,1) because subtracting ⌊x⌋ from m≤x<m+1 gives 0≤x−⌊x⌋<1. For a rational x the floor is the integer part of Number Systems: From N to R, Proposition 3.2.5. Sets and Functions used the floor map as a school fact (Sets and Functions, Example (Maps from calculus) (b)). Now it rests on a proof.

Examples. ⌊3.7⌋=3, since 3≤3.7<4. ⌊5⌋=5, since 5≤5<6: at an integer the floor is the integer itself. ⌊−0.2⌋=−1, since −1≤−0.2<0. ⌈3.7⌉=−⌊−3.7⌋=−(−4)=4.

The graph of the floor is a staircase: on each [m,m+1) a horizontal segment at height m, with a filled dot at its left end and a hollow dot at its right end.

Diagram. Labels: x, y, scriptsize t

The figure shows the graph of ⌊x⌋ on [−2,3), with the dashed line y=x: the staircase never rises above the line and never falls a full unit below it, which is rule (a) below.

Warning. The floor is not “drop the decimals”. For x=−2.5, dropping the decimals gives −2, but −2≤−2.5 is false; the integer with m≤−2.5<m+1 is m=−3. For negative non-integers the floor is one below the truncation.

Quick check. Compute ⌊−7/2⌋, ⌈−7/2⌉ and ⌊7/2⌋+⌊−7/2⌋.

Solution. −4≤−7/2<−3, so ⌊−7/2⌋=−4. Next, 3≤7/2<4 gives ⌊7/2⌋=3, so ⌈−7/2⌉=−⌊7/2⌋=−3. Finally ⌊7/2⌋+⌊−7/2⌋=3−4=−1, not 0: the floor does not commute with negation.

Each of these floors was found the same way: name a candidate integer and verify the two inequalities. That is the whole method for floors.

Example (Method: pin the floor by its inequality)

How it goes. To show ⌊A⌋=m for a real expression A, use one of two forms.

  • First form. Check that m is an integer and that m≤A<m+1. Uniqueness in Definition 8.4.1 does the rest.
  • Second form. Check that m is an integer and that every j∈Z satisfies j≤A⟺j≤m. This form rests on rule (g) of Proposition 8.4.1, which turns j≤A into a statement about ⌊A⌋.
We know We want
an expression A; a candidate integer m m≤A<m+1 (first form), or ∀j∈Z:j≤A⟺j≤m (second form)

When to use it. Every identity with a floor on one side. The first form suits a candidate given by a formula; the second suits an A built from floors and divisions, where each step of the argument is an equivalence.

Common mistakes. One mistake is to drop the decimals, as in the warning above. Another is to forget that m must be an integer. For example, x−12≤x<(x−12)+1 holds for every real x, yet x−12 is ⌊x⌋ only when it is an integer.

Here are the rules for the floor that later chapters use. Most of them are one application of the method; rule (g) is discreteness of Z.

Proposition 8.4.1 (Rules for the Floor)

Let x,y∈R, n∈Z and k∈Z>0.

  • (a) x−1<⌊x⌋≤x, and ⌊x⌋=x if and only if x∈Z.
  • (b) ⌊x+n⌋=⌊x⌋+n.
  • (c) The floor is increasing: if x≤y, then ⌊x⌋≤⌊y⌋.
  • (d) ⌊x⌋+⌊y⌋≤⌊x+y⌋≤⌊x⌋+⌊y⌋+1.
  • (e) ⌊−x⌋=−⌊x⌋ if x∈Z, and ⌊−x⌋=−⌊x⌋−1 if x∉Z.
  • (f) ⌈x⌉ is the unique m∈Z with m−1<x≤m.
  • (g) For every j∈Z: j≤x⟺j≤⌊x⌋.
  • (h) ⌊⌊x⌋/k⌋=⌊x/k⌋.

Idea. Parts (a), (b), (d), (e) and (f) use the first form of Example (Method: pin the floor by its inequality): write down the candidate and check two inequalities. Part (g) is discreteness of Z: no integer lies strictly between ⌊x⌋ and ⌊x⌋+1. Part (c) is (g) applied once, and (h) needs a separate argument.

Proof. Write m:=⌊x⌋, so m∈Z and m≤x<m+1.

  • (a) The inequality m≤x is half of the definition, and subtracting 1 from x<m+1 gives x−1<m. If x∈Z, the integer x satisfies x≤x<x+1, so ⌊x⌋=x by the first form. Conversely, if ⌊x⌋=x, then x is an integer, because ⌊x⌋ is.

  • (b) The number m+n is an integer, and adding n to m≤x<m+1 gives m+n≤x+n<(m+n)+1. By the first form, ⌊x+n⌋=m+n.

  • (c) Let l:=⌊y⌋, and write s:=x−m and t:=y−l, both in [0,1). Then x+y=(m+l)+(s+t) with 0≤s+t<2. Case s+t<1. Then m+l≤x+y<(m+l)+1, so ⌊x+y⌋=m+l by the first form. Case s+t≥1. Then m+l+1≤x+y<(m+l+1)+1, so ⌊x+y⌋=m+l+1. In both cases m+l≤⌊x+y⌋≤m+l+1.

  • (d) If x∈Z, then −x∈Z, and (a) gives ⌊−x⌋=−x=−⌊x⌋. If x∉Z, then m≠x by (a), so m<x<m+1. Negating reverses both inequalities (Number Systems: From N to R, Proposition 2.4.3 (a)): −m−1<−x<−m. So the integer −m−1 satisfies −m−1≤−x<(−m−1)+1, and ⌊−x⌋=−m−1 by the first form.

  • (e) Let k′:=⌊−x⌋, so k′≤−x<k′+1. Negating gives −k′−1<x≤−k′, that is, ⌈x⌉=−k′ satisfies ⌈x⌉−1<x≤⌈x⌉. If also m′∈Z satisfies m′−1<x≤m′, then negating gives −m′≤−x<−m′+1, so −m′=⌊−x⌋=k′ by the definition of the floor, and m′=⌈x⌉.

  • (f) Let j∈Z. (⇐) If j≤m, then j≤m≤x. (⇒) We prove the contrapositive. If j≤m fails, then m<j, by totality of the order. Discreteness of Z (Number Systems: From N to R, Theorem 2.4.2 (c)) then gives m+1≤j. Then x<m+1≤j, so j≤x fails.

  • (g) Let x≤y. Then ⌊x⌋≤x≤y by (a), and ⌊x⌋∈Z, so (g) for y, with j=⌊x⌋, gives ⌊x⌋≤⌊y⌋. Hence the floor is increasing on R (Definition 8.2.1).

Rule (g) justifies the second form of the method. Suppose m∈Z and every j∈Z satisfies j≤A⟺j≤m. By (g), every j∈Z then satisfies j≤⌊A⌋⟺j≤m. The choice j=m gives m≤⌊A⌋, and the choice j=⌊A⌋ gives ⌊A⌋≤m. So m=⌊A⌋.

Part (h) is the rule behind dividing in stages: ⌊⌊17/3⌋/2⌋=⌊5/2⌋=2=⌊17/6⌋.

Idea (Scratch work). Start with the first form, candidate m:=⌊x/k⌋.

We know We want
x∈R, k∈Z>0; m≤x/k<m+1 m≤⌊x⌋/k<m+1
⌊x⌋≤x, k>0 upper half: ⌊x⌋/k≤x/k<m+1; done
m≤x/k, that is, mk≤x lower half: mk≤⌊x⌋
mk∈Z rule (g) turns mk≤x into mk≤⌊x⌋

Both halves go through. But the lower half is just rule (g) again, and every step is an equivalence. The second form writes it as one chain, with no candidate to guess.

Proof.

  • (h) Let j∈Z. Multiplying by k>0 and by 1/k>0 preserves ≤, and jk∈Z. Hence j≤⌊x⌋k⟺jk≤⌊x⌋⟺jk≤x⟺j≤xk⟺j≤⌊x/k⌋, where the second and the last equivalence are (g), applied to x with the integer jk and to x/k with j. So the integer ⌊x/k⌋ satisfies the second form for A=⌊x⌋/k, and ⌊⌊x⌋/k⌋=⌊x/k⌋.

Applied to x/k and l∈Z>0, it gives ⌊⌊x/k⌋/l⌋=⌊x/(kl)⌋.

Quick check. Compute ⌊⌊7.5⌋/2⌋ and ⌊7.5/2⌋.

Solution. ⌊7.5⌋=7, and ⌊7/2⌋=3 since 3≤3.5<4. On the other side 7.5/2=3.75 and ⌊3.75⌋=3. The two agree, as (h) says with k=2.

8.4.2. Distance to the nearest integer

The fractional part x−⌊x⌋ measures how far x sits above the integer below it. Often we want the distance to any integer: 0.9 is far above 0 but close to 1. That is a distance to a set, so we define it as an infimum and then show that it is attained.

The distance from x to Z is how far x must move to land on an integer.

Definition 8.4.2 (Distance to the Integers)

For x∈R, the distance from x to Z is dist(x,Z):=inf{|x−n|:n∈Z}.

The set is non-empty (take n=0) and bounded below by 0, so the infimum exists (Proposition 8.3.1).

Proposition 8.4.2 (Distance to the Integers)

Let x,y∈R, m:=⌊x⌋ and t:=x−m.

  • (a) dist(x,Z)=min{t,1−t}, and it is a minimum: dist(x,Z)=|x−n| for n=m or n=m+1, and |x−n|≥dist(x,Z) for every n∈Z.
  • (b) 0≤dist(x,Z)≤12; dist(x,Z)=0 if and only if x∈Z; dist(x,Z)=12 if and only if x−12∈Z.
  • (c) dist(x+1,Z)=dist(x,Z) and dist(−x,Z)=dist(x,Z).
  • (d) dist(x,Z)≤|x|; dist(x+y,Z)≤dist(x,Z)+dist(y,Z); and |dist(x,Z)−dist(y,Z)|≤|x−y|.

Idea. Every integer is at most m or at least m+1, so the nearest integer is m or m+1, at distance t or 1−t. Parts (b)–(d) follow, using a nearest integer as a witness.

Proof.

  • (a) We have 0≤t<1. Let n∈Z. If n≤m, then n≤m≤x, so |x−n|=x−n≥x−m=t. Otherwise m<n, so m+1≤n by discreteness (Number Systems: From N to R, Theorem 2.4.2 (c)), and n>x, so |x−n|=n−x≥m+1−x=1−t. In both cases |x−n|≥min{t,1−t}. The value min{t,1−t} is itself in the set: |x−m|=t and |x−(m+1)|=1−t. A lower bound of a set that belongs to the set is its infimum, and its minimum.

  • (b) By (a), dist(x,Z)≥0. The two numbers t and 1−t add up to 1, so the smaller is at most 12. Since 1−t>0, the minimum is 0 exactly when t=0, that is, when ⌊x⌋=x, that is, when x∈Z (Proposition 8.4.1 (a)). The minimum is 12 exactly when t≥12 and 1−t≥12, that is, when t=12; then x−12=m∈Z. Conversely, if x−12=k∈Z, then k≤x<k+1, so m=k and t=12.

  • (c) For every n∈Z, |(x+1)−n|=|x−(n−1)| and |−x−n|=|x−(−n)|. As n runs through Z, so do n−1 and −n. So the three sets in the definitions of dist(x+1,Z), dist(−x,Z) and dist(x,Z) are equal, and so are their infima.

  • (d) The first inequality is the term n=0 of the set. For the others, use (a) to choose k,l∈Z with |x−k|=dist(x,Z) and |y−l|=dist(y,Z). By the triangle inequality (Number Systems: From N to R, Proposition 4.1.3 (e)), dist(x+y,Z)≤|(x+y)−(k+l)|≤|x−k|+|y−l|, which is subadditivity. Similarly dist(x,Z)≤|x−l|≤|x−y|+|y−l|=|x−y|+dist(y,Z). Exchanging x and y gives dist(y,Z)−dist(x,Z)≤|x−y|, and the two bounds together are |dist(x,Z)−dist(y,Z)|≤|x−y|.

Uses: Number Systems: From N to R, Proposition 4.1.3 (b) (|−x|=|x|), (d) (|x|≤r as two bounds).

The graph is a row of tents: it rises with slope 1 from 0 at each integer to 12 at each half-integer, and falls back with slope −1.

Diagram. Labels: x, y, scriptsize t, scriptsize tfrac 12

The figure shows dist(x,Z) on [−2,2]. The last inequality of (d) says that no tent is steeper than slope 1: moving x by h changes the height by at most |h|.

Rule (c) says that shifting by 1 changes nothing. For instance, dist(0.3,Z), dist(1.3,Z) and dist(−0.7,Z) are all 0.3. Functions with such a shift have a name.

Definition 8.4.3 (Periodic Function)

Let f:D→R with D⊆R, and let p∈R with p≠0. The number p is a period of f if, for every x∈D, both x+p and x−p lie in D and f(x+p)=f(x). The function f is periodic if it has a period.

The periods of f are closed under negation and under non-zero sums. Let p,q be periods and x∈D. The domain condition for −p is the one for p. With z:=x−p∈D, we get f(x−p)=f(z)=f(z+p)=f(x). If p+q≠0, then x±(p+q)∈D in two steps, and f(x+p+q)=f(x+q)=f(x). By induction on k≥1 (Sets and Functions, Theorem 3.2.1), kp is a period, since kp+p=(k+1)p≠0; by negation so is −kp. So if 1 is a period, every non-zero integer is one.

Examples. The fractional part x↦x−⌊x⌋ on R has period 1, by Proposition 8.4.1 (b) with n=1: (x+1)−⌊x+1⌋=x−⌊x⌋. The distance x↦dist(x,Z) has period 1, by Proposition 8.4.2 (c). A constant function on R has every p≠0 as a period. The identity on R has none, since x+p≠x.

Quick check. Is 12 a period of x↦dist(x,Z)?

Solution. No. A period 12 would give dist(0+12,Z)=dist(0,Z). But dist(0,Z)=0, since 0∈Z, while dist(12,Z)=12 by Proposition 8.4.2 (b), since 12−12=0∈Z.

8.4.3. Step functions

On a bounded interval the floor changes value only finitely often. On [0,3] it is 0 on (0,1), 1 on (1,2) and 2 on (2,3). It jumps at 1, 2 and 3, and is constant in between. Functions of this shape are the simplest after the constants.

A step function is constant between finitely many cut points, and may take any values at the cut points.

Definition 8.4.4 (Step Function)

Let a,b∈R with a<b. A function φ:[a,b]→R is a step function if there exist n∈Z>0 and points a=x0<x1<⋯<xn=b such that, for each i∈{1,…,n}, φ is constant on the open interval (xi−1,xi). The points x0,…,xn form a partition of [a,b] adapted to φ, and the intervals (xi−1,xi) are its open pieces.

In words: finitely many cut points, constant on each open piece, and nothing required at the cut points themselves. Adding cut points keeps a partition adapted, since a constant function stays constant on a smaller interval; so an adapted partition is never unique.

Examples. A constant function on [a,b] is a step function, with the partition a,b. So is 1[0,1/2] on [0,1] (Sets and Functions, Definition 2.3.2), with the partition 0,12,1: it is 1 on (0,12) and 0 on (12,1), and its value 1 at the cut point 12 is allowed.

The floor on any [a,b] is a step function. The integers j with a<j<b satisfy ⌊a⌋<j≤⌊b⌋, by rules (a) and (g) of Proposition 8.4.1. So they form a subset of the finite set {⌊a⌋+1,…,⌊b⌋} (Sets and Functions, Definition 4.1.2). A subset of a finite set is finite (Sets and Functions, Proposition 4.1.6), so there are finitely many such j. Take as cut points a, b and these integers, in increasing order. On an open piece (xi−1,xi), let u<v be two of its points. Then ⌊v⌋≤v<xi, and ⌊v⌋≤u: otherwise the integer ⌊v⌋ would lie in (u,v], inside the open piece, where no integer is. So ⌊v⌋≤⌊u⌋ by Proposition 8.4.1 (g), and ⌊u⌋≤⌊v⌋ by (c). The floor is constant on the piece.

Non-example. The identity x↦x on [0,1] is not a step function. Every partition has a first open piece (x0,x1) with x0<x1, and the identity takes two different values on it, at x0+13(x1−x0) and x0+23(x1−x0). The clause that fails is “constant on each open piece”.

Quick check. Which of these functions on [0,1] are step functions: 1[0,1/2]; the indicator of {1/n:n∈Z>0}?

Solution. The first is, with the partition 0,12,1, as in the examples. The second is not. Take any partition 0=x0<x1<⋯<xn=1. By Number Systems: From N to R, Proposition 4.2.3 there is n′∈Z>0 with 1/n′<x1. The point 1/n′ lies in the first open piece (0,x1), and the indicator is 1 there. The midpoint c of 1/(n′+1) and 1/n′ also lies in (0,x1). It is not of the form 1/k, since larger denominators give smaller reciprocals (Number Systems: From N to R, Proposition 3.2.2 (b)). For k≤n′, 1/k≥1/n′>c, and for k≥n′+1, 1/k≤1/(n′+1)<c. So the indicator is 0 at c, and it is not constant on (0,x1).

Combining two step functions point by point gives a step function again. The only work is to find one partition that serves both. For instance, 1[0,1/2]+1[0,1/3] on [0,1] needs the merged cut points 0,13,12,1; neither partition alone is adapted to it.

Proposition 8.4.3 (Step Functions Are Closed Under the Operations)

Let φ,ψ:[a,b]→R be step functions and c∈R. Then φ+ψ, φψ, cφ, max(φ,ψ) and |φ| (Definition 8.1.2) are step functions.

Idea. Merge the two partitions. Every open piece of the merged partition sits inside an open piece of each old one, so both φ and ψ are constant there, and so is anything computed from their values point by point.

Proof. Let P and Q be the sets of cut points of partitions adapted to φ and to ψ, and let R:=P∪Q. Then R is finite, contains a and b, and lies in [a,b]. So listing it in increasing order gives a partition a=r0<r1<⋯<rN=b. Each open piece (ri−1,ri) lies inside an open piece of P and inside an open piece of Q, because no point of P or Q lies strictly between consecutive points of R. So φ takes one value α and ψ one value β on (ri−1,ri). The five functions take the values α+β, αβ, cα, max(α,β) and |α| there. Hence each is constant on every open piece of R, and R is adapted to all five.

Second readingMerging two partitions

R is finite and can be listed. P and Q are finite. Since Q∖P⊆Q, it is finite (Sets and Functions, Proposition 4.1.6). Then R=P∪(Q∖P) is a disjoint union of finite sets, finite by Sets and Functions, Proposition 4.1.5. Repeatedly removing the minimum (Sets and Functions, Proposition 3.3.8) lists it in increasing order.

Each piece of R lies in a piece of P. Let r<r′ be consecutive in R. Let p be the largest point of P with p≤r and p′ the least with p′≥r′; both exist, since a,b∈P and P is finite. No point q of P lies in (p,p′). If q≤r, it would be a point of P at most r and larger than p. If q≥r′, it would be a point of P at least r′ and smaller than p′. If r<q<r′, it would be a point of R between the consecutive points r and r′. So p,p′ are consecutive in P, and (r,r′)⊆(p,p′). The same holds for Q.

Remark (Looking ahead). Integration, Series, and Function Spaces builds a function that is continuous everywhere and differentiable nowhere by adding up the tents dist(2kx,Z)/2k, each a smaller copy of the graph above.

8.4.4. Exercises

A. Check your understanding

Exercise (A1)

Compute:

  • (a) ⌊−0.01⌋;
  • (b) ⌈2⌉;
  • (c) ⌊2.999⌋+⌈−2.999⌉;
  • (d) dist(−2.7,Z);
  • (e) dist(13/4,Z).

Solution.

  • (a) −1≤−0.01<0, so ⌊−0.01⌋=−1.

  • (b) ⌈2⌉=−⌊−2⌋=−(−2)=2, since −2∈Z (Proposition 8.4.1 (a)).

  • (c) 2≤2.999<3, so ⌊2.999⌋=2, and ⌈−2.999⌉=−⌊2.999⌋=−2. The sum is 0.

  • (d) ⌊−2.7⌋=−3, so t=−2.7−(−3)=0.3, and dist(−2.7,Z)=min{0.3,0.7}=0.3 (Proposition 8.4.2 (a)). The nearest integer is −3.

  • (e) ⌊13/4⌋=3, so t=1/4, and dist(13/4,Z)=min{1/4,3/4}=1/4.

Exercise (A2)

True or false for all real x, y? Give a reason or a counterexample.

  • (a) ⌊2x⌋=2⌊x⌋.
  • (b) ⌊x⌋⌊y⌋≤⌊xy⌋.
  • (c) dist(2x,Z)≤2dist(x,Z).

Solution.

  • (a) False: for x=12, ⌊1⌋=1 but 2⌊12⌋=0.

  • (b) False: for x=y=−12, ⌊x⌋⌊y⌋=(−1)(−1)=1, but ⌊xy⌋=⌊14⌋=0.

  • (c) True: subadditivity in Proposition 8.4.2 (d), with y=x, gives dist(x+x,Z)≤dist(x,Z)+dist(x,Z).

B. Practice

Exercise (B1: Prove or disprove)

Prove each true statement for all real x, and refute each false one with a counterexample. In (c), prove it for all x≥0.

  • (a) ⌊2x⌋=⌊x⌋+⌊x+12⌋.
  • (b) ⌈x⌉−⌊x⌋=1.
  • (c) ⌊⌊x⌋⌋=⌊x⌋ for x≥0.
  • (d) ⌊x⌋+⌊−x⌋=0.

Solution.

  • (a) True. Let m:=⌊x⌋ and t:=x−m∈[0,1). Case t<12. Then 2x=2m+2t with 0≤2t<1, so 2m≤2x<2m+1 and ⌊2x⌋=2m. Also x+12=m+(t+12) with 12≤t+12<1, so ⌊x+12⌋=m. Both sides are 2m. Case t≥12. Then 1≤2t<2, so ⌊2x⌋=2m+1. Also 1≤t+12<32, so ⌊x+12⌋=m+1. Both sides are 2m+1. Each floor was found by the first form of Example (Method: pin the floor by its inequality).

  • (b) False: for x=0, ⌈0⌉−⌊0⌋=0. (For x∉Z it is true, by Proposition 8.4.1 (e).)

  • (c) True, by the second form. Since 0≤x, 0≤⌊x⌋ by Proposition 8.4.1 (g), so both square roots exist. First, for u,v≥0: u≤v⟺u2≤v. Indeed, if u≤v, then u2≤(v)2=v by Lemma 1.5.1 (a) with n=2, with equality when u=v. If u>v, then u2>v by the same part. Now let j∈Z. If j≥0, j≤⌊x⌋⟺j2≤⌊x⌋⟺j2≤x⟺j≤x, the middle step by Proposition 8.4.1 (g), since j2∈Z. If j<0, then j lies below both square roots, which are ≥0, so both sides hold. Rule (g) rewrites j≤x as j≤⌊x⌋. So every j∈Z satisfies j≤⌊x⌋⟺j≤⌊x⌋, and the second form gives ⌊⌊x⌋⌋=⌊x⌋.

  • (d) False: for x=12, ⌊12⌋+⌊−12⌋=0+(−1)=−1. It holds exactly for x∈Z, by Proposition 8.4.1 (e).

Exercise (B2: Counting multiples)

Let N,k∈Z>0. Prove that the number of multiples of k in {1,…,N} is ⌊N/k⌋.

Solution. The multiples of k are the numbers jk with j∈Z. Since k>0, jk≥1 holds exactly when j≥1: for j≥1, jk≥k≥1, and for j≤0, jk≤0. Also jk≤N⟺j≤N/k⟺j≤⌊N/k⌋. The first step multiplies or divides by k>0, which keeps the direction of ≤. The second step is rule (g) of Proposition 8.4.1. So the multiples of k in {1,…,N} are exactly jk with j∈{1,…,⌊N/k⌋}; here ⌊N/k⌋≥0, since N/k>0, and the set is empty when ⌊N/k⌋=0. The map j↦jk from {1,…,⌊N/k⌋} onto this set is injective, since jk=j′k and k≠0 give j=j′. So it is a bijection, and the set has ⌊N/k⌋ elements (Sets and Functions, Definition 4.1.2). This number of elements is unique (Sets and Functions, Corollary 4.1.4).

Exercise (B3)

Show that φ(x):=⌊2x⌋−2⌊x⌋ is a step function on [0,2], and give an adapted partition and the values on its open pieces.

Solution. Take the partition 0,12,1,32,2. On each open piece both floors are constant, by the first form of Example (Method: pin the floor by its inequality):

  • on (0,12): 2x∈(0,1) and x∈(0,1), so φ=0−0=0;
  • on (12,1): 2x∈(1,2), x∈(0,1), so φ=1−0=1;
  • on (1,32): 2x∈(2,3), x∈(1,2), so φ=2−2=0;
  • on (32,2): 2x∈(3,4), x∈(1,2), so φ=3−2=1.

So φ is constant on each open piece, as Definition 8.4.4 requires. At the cut points, φ(0)=0, φ(12)=1, φ(1)=0, φ(32)=1, φ(2)=0.

C. Going deeper

Exercise (C1: A sum of floors)

Let n∈Z>0. Prove that for every x∈R, ∑k=0n−1⌊x+kn⌋=⌊nx⌋.

Solution (Hint 1). Compare the left side at x and at x+1/n: which terms survive the shift?

Solution (Hint 2). Let F(x) be the left side minus the right side. Show that 1/n is a period of F and that F=0 on [0,1/n).

Solution. Let F(x):=∑k=0n−1⌊x+k/n⌋−⌊nx⌋ for x∈R.

Step 1: 1/n is a period of F. Shifting the index gives ∑k=0n−1⌊x+k+1n⌋=∑k=1n−1⌊x+kn⌋+⌊x+1⌋, and ⌊x+1⌋=⌊x⌋+1 by rule (b) of Proposition 8.4.1. Since ⌊x⌋ is the term k=0 of the sum at x, the left side of the identity grows by exactly 1 from x to x+1/n. So does the right side: ⌊n(x+1/n)⌋=⌊nx+1⌋=⌊nx⌋+1. Hence F(x+1/n)=F(x) for every x, and 1/n is a period of F on R (Definition 8.4.3).

Step 2: F=0 on [0,1/n). For 0≤x<1/n and 0≤k≤n−1, 0≤x+k/n<1/n+(n−1)/n=1, so each ⌊x+k/n⌋=0. Also 0≤nx<1, so ⌊nx⌋=0.

Step 3: every x. Let j:=⌊nx⌋ and y:=x−j/n. From j≤nx<j+1, dividing by n, 0≤y<1/n. If j≠0, then j/n is a period of F, since integer multiples of a period are periods; so F(x)=F(y+j/n)=F(y)=0. If j=0, then x=y and F(x)=0 by Step 2. This proves the identity.

Uses: Sets and Functions, Definition 3.3.1 (shifting the index).

What a complete answer needs. (10 points)

  • 3: shows that both sides increase by exactly 1 under x↦x+1/n, naming Proposition 8.4.1 (b) for each side.
  • 2: checks that both sides vanish on [0,1/n), with the bound x+(n−1)/n<1.
  • 3: reduces an arbitrary x to [0,1/n) by a multiple j/n of the period, with j=⌊nx⌋ (or another integer chosen so that the remainder lands in [0,1/n)).
  • 2: uses that integer multiples of a period (including negative ones) are periods, or iterates the shift in both directions.

A direct count also earns full marks. Write t=x−⌊x⌋. The terms with t+k/n≥1 equal ⌊x⌋+1, and the others equal ⌊x⌋. Such a proof earns the 3, 2, 3 and 2 points for, in order: the count, each term’s inequality, ⌊nx⌋, and the comparison.

Slips that lose the step (0 points for it): shifting only forward, although x<0 needs a backward shift; treating ⌊x+1⌋ as ⌊x⌋.

Exercise (C2: Multiplying the distance)

Let n∈Z>0.

  • (a) Prove that dist(nx,Z)≤ndist(x,Z) for every x∈R.
  • (b) Prove that equality holds whenever dist(x,Z)≤1/(2n).
  • (c) Find x with strict inequality for n=2.

Hint: if |y−k|≤12 for an integer k, then dist(y,Z)=|y−k|.

Solution.

  • (a) By induction on n≥1 (Sets and Functions, Theorem 3.2.1, with base 1). For n=1 both sides are dist(x,Z). If dist(nx,Z)≤ndist(x,Z), then subadditivity (Proposition 8.4.2 (d)) gives dist((n+1)x,Z)≤dist(nx,Z)+dist(x,Z)≤(n+1)dist(x,Z).

  • (b) First the hint. Let |y−k|≤12 with k∈Z, and let j∈Z with j≠k. Then |j−k|≥1 by discreteness (Number Systems: From N to R, Theorem 2.4.2 (c)). The reverse triangle inequality (Number Systems: From N to R, Proposition 4.1.3 (f)) gives |y−j|≥|j−k|−|y−k|≥1−12=12≥|y−k|. So |y−k| is the least of the numbers |y−j|, j∈Z, and equals dist(y,Z).

    Now let dist(x,Z)≤1/(2n). By Proposition 8.4.2 (a) there is k∈Z with |x−k|=dist(x,Z); put t:=x−k. Then nx=nk+nt with nk∈Z and |nx−nk|=n|t|≤12. By the hint, dist(nx,Z)=n|t|=ndist(x,Z).

    Uses: Number Systems: From N to R, Proposition 4.1.3 (b) (|nt|=n|t|, as n>0).

  • (c) x=12: dist(1,Z)=0<1=2dist(12,Z). Here dist(x,Z)=12>14=1/(2n), so (b) does not apply. Exercise A2 (c) gave the inequality only; (b) adds where it is an equality.