On a log scale, n! and the Stirling approximation nearly coincide, and the relative error shrinks like 12n1. Where π enters is only sketched at the idea level.
n!≈2πn(en)n
Examples & Exercises
Compute the relative error of Stirling's formula at n=10 and compare with 1201. (A numerical check, not a proof.)
10!∣S(10)−10!∣≈0.008296≈1201
n=10: the two curves overlap on the log scale.Show proof
10!=3628800. S(10)=20π(e10)10≈3598695.62.
The relative error =36288003628800−3598695.62≈0.008296.
12⋅101=1201≈0.008333 — matching the claim. (This is a numerical check, not a proof of the error formula.)
Explain the picture comparing ln(n!)=∑k=1nlnk with ∫1nlnxdx. (Idea level.)
k=1∑nlnk≈∫1nlnxdx=nlnn−n+1
The sum of the bars and the area under the curve are close.Show proof
ln(n!)=∑k=1nlnk is the total area of bars under the graph of y=lnx.
The integral ∫1nlnxdx=nlnn−n+1 is the area under the curve — close to the bar sum.
The gap grows like 21ln(2πn), and that correction produces the 2πn. The rigorous derivation is omitted — idea level.