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.11.1-3

Exercise 1.2.11.1-3

not stated yet in Lean solution written

RatingM15
MarkersM (mathematical)
KindK4, find an estimate: give an asymptotic form or a bound from the written solution
SectionSection 1.2.11.1 of Volume 1. Companion chapter: The O-notation

The task

Multiply (ln⁡n+γ+O(1/n))(\ln n+\gamma+O(1/n)) by (n+O(n))(n+O(\sqrt n)) and write the product with one OO.

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

Expand the product into four terms.

Hint 2

Bound each term, and compare the sizes of the error terms.

Solution

Show the solution

The product has four terms.

ln⁡n⋅n=nln⁡n\ln n\cdot n=n\ln n and γn\gamma n are the main terms.

ln⁡n⋅O(n)=O(nln⁡n)\ln n\cdot O(\sqrt n)=O(\sqrt n\ln n).

γ⋅O(n)=O(n)\gamma\cdot O(\sqrt n)=O(\sqrt n).

O(1/n)⋅n=O(1)O(1/n)\cdot n=O(1), and O(1/n)⋅O(n)=O(n−1/2)O(1/n)\cdot O(\sqrt n)=O(n^{-1/2}).

For n≥3n\ge3 all three of n\sqrt n, 11 and n−1/2n^{-1/2} are at most nln⁡n\sqrt n\ln n up to a constant, so by (7) their sum is O(nln⁡n)O(\sqrt n\ln n). Hence

nln⁡n+γn+O(nln⁡n).n\ln n+\gamma n+O(\sqrt n\ln n).

Check

Take n=106n=10^6 with the first factor HnH_n (its error is about 12n\frac1{2n}) and the second factor n+nn+\sqrt n. The product is 14 407 119.414\,407\,119.4, the two main terms give 14 392 726.214\,392\,726.2, and the difference is 14 393.214\,393.2. The bound nln⁡n=13 815.5\sqrt n\ln n=13\,815.5 times a constant near 1.041.04 covers it.

Remarks

The term γn\gamma n stays outside the OO, since γn\gamma n is larger than nln⁡n\sqrt n\ln n. This is the pattern of Eq. (10).

This solution is drafted, 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.