taocp

This site has no text of the book. Keep your own copy of TAOCP next to it. See what is checked.

Exercise · Volume 1 · 1.2.4-38

Exercise 1.2.4-38

not stated yet in Lean solution written

RatingM26
MarkersM (mathematical)
KindK1, prove: show that a stated fact is true from the written solution
SectionSection 1.2.4 of Volume 1. Companion chapter: Integer functions and elementary number theory

The task

Prove the summation formula for ∑0≤k<y⌊x+k/y⌋\sum_{0 \le k < y} \lfloor x + k/y \rfloor with real xx and y>0y > 0, and deduce the case y=ny = n.

The exact wording is in your copy of the book.

Hints

Open one hint at a time. Try the exercise again after each.

Hint 1

Put x=⌊x⌋+fx = \lfloor x \rfloor + f with 0≤f<10 \le f < 1. Pull out the integer part.

Hint 2

What are the possible values of ⌊f+k/y⌋\lfloor f + k/y \rfloor for 0≤k<y0 \le k < y? Count the kk for which it is 11.

Solution

Show the solution

Let N=⌈y⌉N = \lceil y \rceil. The integers kk with 0≤k<y0 \le k < y are 0,1,…,N−10, 1, \ldots, N - 1. Write x=⌊x⌋+fx = \lfloor x \rfloor + f with 0≤f<10 \le f < 1.

Step 1. ⌊x+k/y⌋=⌊x⌋+⌊f+k/y⌋\lfloor x + k/y \rfloor = \lfloor x \rfloor + \lfloor f + k/y \rfloor. For 0≤k<y0 \le k < y the fraction satisfies 0≤k/y<10 \le k/y < 1, so 0≤f+k/y<20 \le f + k/y < 2, and ⌊f+k/y⌋\lfloor f + k/y \rfloor is 00 or 11. It is 11 if and only if f+k/y≥1f + k/y \ge 1, that is k≥(1−f)yk \ge (1 - f)y.

Step 2. The number (1−f)y(1 - f)y lies in (0,y](0, y], so c=⌈(1−f)y⌉c = \lceil (1 - f)y \rceil satisfies 1≤c≤N1 \le c \le N. The integers kk in {0,…,N−1}\{0, \ldots, N-1\} with k≥ck \ge c are c,…,N−1c, \ldots, N - 1, which is N−cN - c values. Hence ∑0≤k<y⌊x+ky⌋=N⌊x⌋+N−⌈(1−f)y⌉=N(⌊x⌋+1)+⌊(f−1)y⌋.\sum_{0 \le k < y} \Bigl\lfloor x + \frac ky \Bigr\rfloor = N\lfloor x \rfloor + N - \lceil (1-f)y \rceil = N(\lfloor x \rfloor + 1) + \lfloor (f - 1)y \rfloor.

Step 3. Now the right side. Since ⌊x+1⌋=⌊x⌋+1\lfloor x + 1 \rfloor = \lfloor x \rfloor + 1 and x=⌊x⌋+fx = \lfloor x \rfloor + f, xy+⌊x+1⌋(N−y)=⌊x⌋y+fy+(⌊x⌋+1)N−⌊x⌋y−y=(⌊x⌋+1)N+(f−1)y.xy + \lfloor x + 1 \rfloor (N - y) = \lfloor x \rfloor y + fy + (\lfloor x \rfloor + 1)N - \lfloor x \rfloor y - y = (\lfloor x \rfloor + 1)N + (f - 1)y. The first part is an integer, so the floor of the whole is (⌊x⌋+1)N+⌊(f−1)y⌋(\lfloor x \rfloor + 1)N + \lfloor (f-1)y \rfloor. This equals the result of Step 2. □\square

The case y=ny = n. Then N=nN = n and N−y=0N - y = 0, so the sum ∑k=0n−1⌊x+k/n⌋\sum_{k=0}^{n-1} \lfloor x + k/n \rfloor equals ⌊nx⌋\lfloor nx \rfloor.

Check

Take x=0.7x = 0.7, n=3n = 3: ⌊0.7⌋+⌊1.033⌋+⌊1.367⌋=0+1+1=2=⌊2.1⌋\lfloor 0.7 \rfloor + \lfloor 1.033 \rfloor + \lfloor 1.367 \rfloor = 0 + 1 + 1 = 2 = \lfloor 2.1 \rfloor. For a non-integer yy take x=0.7x = 0.7, y=2.5y = 2.5: the terms are k=0,1,2k = 0, 1, 2 giving 0,1,10, 1, 1 with sum 22, and ⌊1.75+1⋅0.5⌋=⌊2.25⌋=2\lfloor 1.75 + 1 \cdot 0.5 \rfloor = \lfloor 2.25 \rfloor = 2. A run over x=i/13x = i/13 and y=j/5y = j/5 gives no exception.

Remarks

The special case is Hermite's identity. It makes the floor function a replicative function (Exercise 1.2.4-39). Exercises 1.2.4-37 and 1.2.4-44 use it.

The book's answer takes another route: it reduces to 0≤x<10 \le x < 1 and follows how both sides change as xx grows.

This solution is checked, and a person has not reviewed it yet. The source.

In Lean

not stated yet The exercise is not stated in Lean yet.

The status is computed from the Lean build. The node of the map.

Something is wrong? Report it.