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-44

Exercise 1.2.4-44

not stated yet in Lean solution written

RatingM24
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

Show that the double sum ∑k≥0∑1≤j<b⌊(n+jbk)/bk+1⌋\sum_{k \ge 0}\sum_{1 \le j < b}\lfloor (n + jb^k)/b^{k+1} \rfloor equals nn for n≥0n \ge 0 and integer b≥2b \ge 2, and find its value for n<0n < 0.

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

Use Exercise 1.2.4-35 to replace n/bkn/b^k by ⌊n/bk⌋\lfloor n/b^k \rfloor inside the floor.

Hint 2

For the sum over jj, use Hermite's identity (Exercise 1.2.4-38) with the term j=0j = 0 added and then removed.

Hint 3

The result for each kk is a difference of two consecutive values of ⌊n/bk⌋\lfloor n/b^k \rfloor. The sum over kk telescopes.

Solution

Show the solution

Fix k≥0k \ge 0 and put d=⌊n/bk⌋d = \lfloor n/b^k \rfloor. Since bk+1=b⋅bkb^{k+1} = b \cdot b^k, ⌊n+jbkbk+1⌋=⌊n/bk+jb⌋=⌊d+jb⌋\Bigl\lfloor \frac{n + jb^k}{b^{k+1}} \Bigr\rfloor = \Bigl\lfloor \frac{n/b^k + j}{b} \Bigr\rfloor = \Bigl\lfloor \frac{d + j}{b} \Bigr\rfloor by Exercise 1.2.4-35 (with x=n/bkx = n/b^k, m=jm = j and divisor bb).

By Hermite's identity (Exercise 1.2.4-38) with x=d/bx = d/b and the integer bb in place of nn, ∑j=0b−1⌊db+jb⌋=⌊d⌋=d.\sum_{j=0}^{b-1}\Bigl\lfloor \frac db + \frac jb \Bigr\rfloor = \lfloor d \rfloor = d. The term j=0j = 0 is ⌊d/b⌋\lfloor d/b \rfloor, so ∑j=1b−1⌊(d+j)/b⌋=d−⌊d/b⌋\sum_{j=1}^{b-1}\lfloor (d + j)/b \rfloor = d - \lfloor d/b \rfloor. By Exercise 1.2.4-35 again, ⌊d/b⌋=⌊n/bk+1⌋\lfloor d/b \rfloor = \lfloor n/b^{k+1} \rfloor. So the inner sum for index kk is ⌊nbk⌋−⌊nbk+1⌋.\Bigl\lfloor \frac n{b^k} \Bigr\rfloor - \Bigl\lfloor \frac n{b^{k+1}} \Bigr\rfloor.

Sum over k=0,…,K−1k = 0, \ldots, K - 1. The sum telescopes and gives n−⌊n/bK⌋n - \lfloor n/b^K \rfloor.

Case n≥0n \ge 0. For bK>nb^K > n the last floor is ⌊n/bK⌋=0\lfloor n/b^K \rfloor = 0. All terms with larger kk are 00 too, so the infinite sum is nn.

Case n<0n < 0. For bK>∣n∣b^K > |n| the quotient satisfies −1<n/bK<0-1 < n/b^K < 0, so ⌊n/bK⌋=−1\lfloor n/b^K \rfloor = -1. Then all terms with k≥Kk \ge K are −1−(−1)=0-1 - (-1) = 0, the sum is finite, and it equals n−(−1)=n+1n - (-1) = n + 1. □\square

Check

Take b=3b = 3, n=10n = 10. For k=0k = 0: j=1,2j = 1, 2 give ⌊11/3⌋+⌊12/3⌋=3+4=7\lfloor 11/3 \rfloor + \lfloor 12/3 \rfloor = 3 + 4 = 7. For k=1k = 1: ⌊13/9⌋+⌊16/9⌋=1+1=2\lfloor 13/9 \rfloor + \lfloor 16/9 \rfloor = 1 + 1 = 2. For k=2k = 2: ⌊19/27⌋+⌊28/27⌋=0+1=1\lfloor 19/27 \rfloor + \lfloor 28/27 \rfloor = 0 + 1 = 1. Later terms are 00. The total is 7+2+1=107 + 2 + 1 = 10. For n=−4n = -4, b=2b = 2: the value is −3=n+1-3 = n + 1. A run over 0≤n<2000 \le n < 200 and −200≤n<0-200 \le n < 0 with 2≤b≤52 \le b \le 5 confirms nn and n+1n + 1.

Remarks

For b=2b = 2 the inner sum has one term, ⌈⌊n/2k⌋/2⌉\lceil \lfloor n/2^k \rfloor / 2 \rceil, and the identity says that these terms add up to nn. The proof uses only Exercises 1.2.4-35 and 1.2.4-38.

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.