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

Exercise 1.2.4-6

proved in Lean solution written

Rating20
Markersrecommended
KindK2, decide: say whether a claim holds from the written solution
SectionSection 1.2.4 of Volume 1. Companion chapter: Integer functions and elementary number theory

The task

Decide which of three equations hold for every positive real xx: (a) ⌊⌊x⌋⌋=⌊x⌋\lfloor \sqrt{\lfloor x \rfloor} \rfloor = \lfloor \sqrt x \rfloor, (b) ⌈⌈x⌉⌉=⌈x⌉\lceil \sqrt{\lceil x \rceil} \rceil = \lceil \sqrt x \rceil, (c) ⌈⌊x⌋⌉=⌈x⌉\lceil \sqrt{\lfloor x \rfloor} \rceil = \lceil \sqrt x \rceil.

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

For equation (a) use the characterization ⌊y⌋=m\lfloor y \rfloor = m if and only if m≤y<m+1m \le y < m + 1 (Exercise 1.2.4-3), and square the inequalities.

Hint 2

Equation (b) is the mirror image of (a) for ceilings. For (c), try an xx a little above a perfect square.

Solution

Show the solution

(a) is true. Let m=⌊x⌋m = \lfloor \sqrt x \rfloor. This is a nonnegative integer with m≤x<m+1m \le \sqrt x < m + 1, so m2≤x<(m+1)2m^2 \le x < (m + 1)^2. Since m2m^2 is an integer, m2≤xm^2 \le x is the same as m2≤⌊x⌋m^2 \le \lfloor x \rfloor (1.2.4-3(b)). Since (m+1)2(m+1)^2 is an integer, x<(m+1)2x < (m+1)^2 is the same as ⌊x⌋<(m+1)2\lfloor x \rfloor < (m + 1)^2 (1.2.4-3(a)). So m2≤⌊x⌋<(m+1)2m^2 \le \lfloor x \rfloor < (m + 1)^2, and taking square roots gives m≤⌊x⌋<m+1m \le \sqrt{\lfloor x \rfloor} < m + 1. Hence ⌊⌊x⌋⌋=m\lfloor \sqrt{\lfloor x \rfloor} \rfloor = m.

(b) is true. Let m=⌈x⌉m = \lceil \sqrt x \rceil. Since x>0x > 0, m≥1m \ge 1, and m−1<x≤mm - 1 < \sqrt x \le m, so (m−1)2<x≤m2(m - 1)^2 < x \le m^2. Since m2m^2 is an integer, x≤m2x \le m^2 is the same as ⌈x⌉≤m2\lceil x \rceil \le m^2. Since (m−1)2(m - 1)^2 is an integer, (m−1)2<x(m - 1)^2 < x is the same as (m−1)2<⌈x⌉(m - 1)^2 < \lceil x \rceil (1.2.4-3(d)). So (m−1)2<⌈x⌉≤m2(m - 1)^2 < \lceil x \rceil \le m^2, and taking square roots gives m−1<⌈x⌉≤mm - 1 < \sqrt{\lceil x \rceil} \le m. Hence ⌈⌈x⌉⌉=m\lceil \sqrt{\lceil x \rceil} \rceil = m.

(c) is false. Take x=1.5x = 1.5. Then ⌈⌊1.5⌋⌉=⌈1⌉=1\lceil \sqrt{\lfloor 1.5 \rfloor} \rceil = \lceil \sqrt 1 \rceil = 1, but ⌈1.5⌉=2\lceil \sqrt{1.5} \rceil = 2, since 1.5=1.2247…\sqrt{1.5} = 1.2247\ldots.

Check

A run with exact arithmetic over x=k/100x = k/100 for 1≤k<50001 \le k < 5000 shows that (a) and (b) hold each time and that (c) fails first at x=0.01x = 0.01, where the left side is ⌈0⌉=0\lceil \sqrt 0 \rceil = 0 and the right side is 11. A single counterexample, as above, is enough for (c).

Remarks

The proofs of (a) and (b) work for ⌊g(x)⌋\lfloor g(x) \rfloor and ⌈g(x)⌉\lceil g(x) \rceil whenever gg is continuous and increasing and g(x)g(x) is an integer only for an integer xx. The square root has this property: if x\sqrt x is an integer, then so is xx. Exercise 1.2.4-34 treats the logarithm in the same way.

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

In Lean

proved The statement and its proof are in Lean. The kernel accepts the proof, and it uses the standard axioms only.

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

Something is wrong? Report it.