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.7-8

Exercise 1.2.7-8

stated in Lean solution written

RatingHM18
MarkersHM (needs higher mathematics)
KindK3, find a value: compute a number, a set or a closed form from the written solution
SectionSection 1.2.7 of Volume 1. Companion chapter: Harmonic numbers

The task

Compare ∑k=1nHk\sum_{k=1}^{n} H_k of eq. (8) with ∑k=1nln⁡k\sum_{k=1}^{n}\ln k and estimate the difference as a function of nn.

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

Write the first sum in closed form with eq. (8), and the second as ln⁡n!\ln n!.

Hint 2

Insert eq. (3) for HnH_n and Stirling's formula for ln⁡n!\ln n!, and collect the terms by their order in nn.

Solution

Show the solution

By eq. (8), ∑k=1nHk=(n+1)Hn−n\sum_{k=1}^{n} H_k = (n+1)H_n - n, and ∑k=1nln⁡k=ln⁡n!\sum_{k=1}^{n}\ln k = \ln n!. Let DnD_n be the difference. Use

Hn=ln⁡n+γ+12n−112n2+O(n−4),ln⁡n!=nln⁡n−n+12ln⁡(2πn)+112n+O(n−3).H_n = \ln n + \gamma + \frac{1}{2n} - \frac{1}{12n^2} + O(n^{-4}), \qquad \ln n! = n\ln n - n + \frac12\ln(2\pi n) + \frac{1}{12n} + O(n^{-3}).

Then

(n+1)Hn=nln⁡n+γn+12−112n+ln⁡n+γ+12n+O(n−2).(n+1)H_n = n\ln n + \gamma n + \frac12 - \frac{1}{12n} + \ln n + \gamma + \frac{1}{2n} + O(n^{-2}).

Subtract nn and ln⁡n!\ln n!:

Dn=(n+1)Hn−n−ln⁡n!=γn+12ln⁡n+(γ+12−12ln⁡2π)+1n(−112+12−112)+O(n−2).D_n = (n+1)H_n - n - \ln n! = \gamma n + \frac12\ln n + \left(\gamma + \frac12 - \frac12\ln 2\pi\right) + \frac{1}{n}\left(-\frac{1}{12} + \frac12 - \frac{1}{12}\right) + O(n^{-2}).

The terms nln⁡nn\ln n and −n+n-n + n cancel. So

Dn=γn+12ln⁡n+(γ+12−12ln⁡2π)+13n+O(n−2).D_n = \gamma n + \frac12\ln n + \left(\gamma + \frac12 - \frac12\ln 2\pi\right) + \frac{1}{3n} + O(n^{-2}).

The constant is γ+12−12ln⁡2π=0.1582771…\gamma + \frac12 - \frac12\ln 2\pi = 0.1582771\ldots, since γ=0.5772157…\gamma = 0.5772157\ldots and 12ln⁡2π=0.9189385…\frac12\ln 2\pi = 0.9189385\ldots.

Check

Python computes DnD_n exactly and subtracts γn+12ln⁡n+0.1582771…\gamma n + \frac12\ln n + 0.1582771\ldots. The remainders are 0.0325120.032512, 0.0033250.003325 and 0.000832810.00083281 for n=10n = 10, 100100 and 400400. They are close to 13n=0.03333\frac{1}{3n} = 0.03333, 0.0033330.003333 and 0.000833330.00083333.

Remarks

The sum ∑k≤n(Hk−ln⁡k)\sum_{k \le n}(H_k - \ln k) is the sum of the errors of the approximation Hk≈ln⁡kH_k \approx \ln k. It grows like γn\gamma n, since each term is near γ\gamma.

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

In Lean

stated The statement is in Lean and it builds. The proof is not in Lean yet.

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

Something is wrong? Report it.