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

Exercise 1.2.5-5

proved in Lean solution written

Rating15
KindK3, find a value: compute a number, a set or a closed form from the written solution
SectionSection 1.2.5 of Volume 1. Companion chapter: Permutations and factorials

The task

Use Stirling's approximation with the extra factor 1+1/(12n)1 + 1/(12n) to estimate 8!8!.

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 n=8n = 8 in the formula. First compute the value without the factor, then multiply by the factor.

Hint 2

Use 2π⋅8=4π\sqrt{2\pi \cdot 8} = 4\sqrt{\pi} and (8/e)8=224e−8(8/e)^8 = 2^{24} e^{-8}.

Solution

Show the solution

For n=8n = 8 the plain Stirling value is

16π (8/e)8=4π⋅224e−8=7.08982⋅16 777 216⋅0.000335463≈39902.4.\sqrt{16\pi}\,(8/e)^8 = 4\sqrt{\pi}\cdot 2^{24} e^{-8} = 7.08982 \cdot 16\,777\,216 \cdot 0.000335463 \approx 39902.4.

The factor is 1+112⋅8=1+196=1.01041671 + \frac{1}{12 \cdot 8} = 1 + \frac{1}{96} = 1.0104167. The estimate is

39902.4⋅1.0104167≈40318.0.39902.4 \cdot 1.0104167 \approx 40318.0.

The exact value is 8!=403208! = 40320. The error is about 22, a relative error of 0.005%0.005\%. The plain formula was low by 418418, which is 1.04%1.04\%.

Check

Python with 15 digits gives 39902.395439902.3954 for the plain value and 40318.045440318.0454 for the refined value. The relative error of the refined value is 4.8×10−54.8 \times 10^{-5}, much smaller than the term 1/(12n)=0.01041/(12n) = 0.0104 that it adds. The next correction term in Stirling's series is 1/(288n2)=5.4×10−51/(288 n^2) = 5.4 \times 10^{-5}, which is close to the error.

Remarks

The relative error of the plain formula is about 1/(12n)1/(12n), and the factor 1+1/(12n)1 + 1/(12n) removes this term. The next term of the series is +1/(288n2)+1/(288 n^2). The full proof of Stirling's formula is in Section 1.2.11.2.

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.