The Stirling's approximation [1] states that ∀n∈N+\forall n \in \mathbb{N}^+,

2πn(ne)ne112n+1≤n!≤2πn(ne)ne112n. \sqrt{2 \pi} \sqrt{n} \left( \frac{n}{e} \right)^n e^{ \frac{1}{ 12n + 1 } } \le n! \le \sqrt{2 \pi} \sqrt{n} \left( \frac{n}{e} \right)^n e^{ \frac{1}{ 12n } }.

As ∀x∈R,ex≥1+x\forall x \in R, e^x \ge 1 + x, and for 0<x<0.50 < x < 0.5, ex≤1+2xe^x \le 1 + 2 x, we get ∀n∈N+\forall n \in \mathbb{N}^+,

2πn(ne)n(1+112n+1)≤n!≤2πn(ne)n(1+16n). \sqrt{2 \pi} \sqrt{n} \left( \frac{n}{e} \right)^n \left( 1 + \frac{1}{ 12n + 1 } \right) \le n! \le \sqrt{2 \pi} \sqrt{n} \left( \frac{n}{e} \right)^n \left( 1 + \frac{1}{ 6n } \right).

Asymptotically,

n!=2πn(ne)n(1+Θ(1n)). n! = \sqrt{2 \pi} \sqrt{n} \left( \frac{n}{e} \right)^n \left( 1 + \Theta \left( \frac{1}{n} \right) \right).

In the remainder of the blog, we try to approach this estimation incrementally. First we have two trivial facts.

1. n!≤nnn! \le n^n.

2. n!≥(n/2)n/2n! \ge (n / 2)^{n / 2}.

Proof: Clearly this holds for even numbers. When nn is odd, ⌈n/2⌉=(n+1)/2\lceil n / 2 \rceil = (n + 1) / 2. There are (n+1)/2(n + 1) / 2 numbers in [n][n] that are ≥(n+1)/2\ge (n + 1) / 2.

n!≥∏i=(n+1)/2)ni≥((n+1)/2))(n+1)/2)≥(n/2)n/2 n! \ge \prod_{i = (n + 1) / 2)}^n i \ge \big( (n + 1) / 2) \big)^{ (n + 1) / 2) } \ge (n / 2)^{n / 2}

□\square

Somewhat unexpectedly, we can combine inequality (1) and (2) to obtain the asymptotical trend of log⁡n!\log n! up to some constant:

(n/2)log⁡2n−(n/2)≤log⁡2n!≤nlog⁡2n. (n / 2) \log_2 n - (n / 2) \le \log_2 n! \le n \log_2 n.

This implies that

log⁡2n!=Θ(nlog⁡n). \log_2 n! = \Theta( n \log n).

We proceed to get even sharper bounds.

3. n!≥nnexp⁡(n)=(n/e)nn! \ge \frac{n^n}{ \exp(n) } = (n / e)^n.

Proof: Using the Taylor expansion for exp⁡(x)\exp(x) for ∀x∈R\forall x \in \mathbb{R}, we get

exp⁡(x)=1+x+x22!+...+xnn!+... \exp(x) = 1 + x + \frac{x^2}{2!} + ... + \frac{x^n}{n!} + ...

Keeping only the nn-th term of the expansion, we have

n!≥xnexp⁡(x). n! \ge \frac{x^n}{\exp(x) }.

Taking x=nx = n maximizes the RHS.

□\square

4. n!≥e(n/e)nn! \ge e ( n / e)^n.

Proof: Using the Taylor expansion for exp⁡(x)\exp(x) for ∀x∈R\forall x \in \mathbb{R}, we get

exp⁡(x)=1+x+x22!+...+xnn!+... \exp(x) = 1 + x + \frac{x^2}{2!} + ... + \frac{x^n}{n!} + ...

Setting x=nx = n, we get

exp⁡(n)≥nn−1(n−1)!+nnn!=2nnn!, \exp(n) \ge \frac{n^{n - 1} }{ (n - 1)!} + \frac{ n^n }{n !} = 2 \frac{ n^n }{n !},

which finishes our proof.

□\square

Next we resort to calculus to get finer estimation.

5. n!≥e(n/e)nn! \ge e ( n / e)^n.

Proof: As the figure below shows, ∑i∈[n]ln⁡i\sum_{i \in [n] } \ln i is the sum of areas of a set of rectangles and it upper bounds the area under the curve y=log⁡ty = \log t:

∑i∈[n]ln⁡i≥∫1nln⁡t dt=tln⁡t∣1n−∫1n1 dt=nln⁡n−n+1. \sum_{i \in [n]} \ln i \ge \int_1^n \ln t \ dt = t \ln t \mid_1^n - \int_1^n 1 \ dt = n \ln n - n + 1.

Hence, n!≥e(n/e)nn! \ge e (n / e)^n.

□\square

6. n!≤en(n/e)nn! \le e \sqrt{n} (n / e)^n.

Proof: For a rectangle, its area can be decomposed into the curvilinear area under y=ln⁡ty = \ln t and a curvy triangle. To obtain an upper bound for ∑i∈[n]ln⁡i\sum_{i \in [n] } \ln i, we want to upper bound the areas of the curvy triangles.

How are we going to do that? Image that we put a wall at t=1t = 1, and line the curvy triangles up against the wall. By the figure, they take up at most half the area of the rectangle with width 11 and height ln⁡n\ln n. Then

∑i∈[n]ln⁡i≤∫1nln⁡t dt+12ln⁡n=nln⁡n−n+1+12ln⁡n. \sum_{i \in [n]} \ln i \le \int_1^n \ln t \ dt + \frac{1}{2} \ln n = n \ln n - n + 1 + \frac{1}{2} \ln n.

□\square

By inequality (4) and (5), we get

e(n/e)n≤n!≤en(n/e)n. e ( n / e)^n \le n! \le e \sqrt{n} (n / e)^n.

So

n!=Θ((n/e)n). n! = \Theta ( (n / e)^n ).

Indeed the approximation of en(n/e)ne \sqrt n (n / e)^n is quite sharp. If we compute its ratio with the near accurate estimation 2πn(n/e)n\sqrt{2 \pi} \sqrt n (n / e)^n, we see that the ratio is very close to 1:

en(n/e)n2πn(n/e)n=e2π≈1.084. \frac{ e \sqrt n (n / e)^n }{ \sqrt{2 \pi} \sqrt n (n / e)^n } = \frac{e }{\sqrt{ 2 \pi} } \approx 1.084.

Therefore, when nn is large, en(n/e)ne \sqrt n (n / e)^n is within 10%10\% of the real value of n!n!.

7. n!≤en(n/e)nn! \le e \sqrt{n} (n / e)^n.

The same inequality can be obtained in the following manner.

Proof: We lower bound the integral by the areas of trapezoids. The trapezoid between tt and t+1t + 1 has base heights ln⁡t\ln t and ln⁡(t+1)\ln (t + 1), and area 12(ln⁡t+ln⁡(t+1))\frac{1}{2} (\ln t + \ln (t + 1) ). Hence,

∑i=1nln⁡i=12∑t=1n−1(ln⁡t+ln⁡(t+1))+12ln⁡n≤∫1nln⁡t dt+12ln⁡n=nln⁡n−n+1+12ln⁡n \begin{aligned} \sum_{i = 1}^n \ln i &= \frac{1}{2} \sum_{t = 1}^{n - 1} (\ln t + \ln (t + 1) ) + \frac{1}{2} \ln n \\ &\le \int_1^n \ln t \ dt + \frac{1}{2} \ln n \\ &= n \ln n - n + 1 + \frac{1}{2} \ln n \end{aligned}

□\square

8. n!∈[e11/12n(ne)ne1/(12n+1),e12/13n(ne)ne1/(12n)]n! \in [e^{11 / 12} \sqrt{n} \left( \frac{n}{e} \right)^n e^{ 1 / (12n + 1)}, e^{12 / 13} \sqrt{n} \left( \frac{n}{e} \right)^n e^{1 / (12 n) }]

Proof: Let

Uk=∫kk+1ln⁡t dt,Lk=12(ln⁡k+ln⁡(k+1)). \begin{aligned} U_k &= \int_k^{k + 1} \ln t \ dt, \\ L_k &= \frac{1}{2} \left(\ln k + \ln (k + 1) \right). \end{aligned}

The estimation error in the previous section is determined by the gap between UkU_k and LkL_k, for k∈[n−1]k \in [n - 1]. To investigate it carefully, define ∀k∈[n−1]\forall k \in [n - 1],

ϵk≐Uk−Lk. \epsilon_k \doteq U_k - L_k .

Denote S=∑i∈[n]ln⁡iS = \sum_{i \in [n] } \ln i and S^=nln⁡n−n+1+12ln⁡n\hat S = n \ln n - n + 1 + \frac{1}{2} \ln n. The derivation in the previous section shows

S^−S=∑i=1n−1ϵk. \hat S - S = \sum_{i = 1}^{n - 1} \epsilon_k.

For a fixed kk, we can compute ϵk\epsilon_k in closed form:

ϵk=tln⁡t∣kk+1−t∣kk+1−12(ln⁡k+ln⁡(k+1))=ln⁡(k+1)k+1kk⋅1k12(k+1)12−1=ln⁡(k+1k)k+12−1=(2k+12)⋅ln⁡(k+1k)−1 \begin{aligned} \epsilon_k &= t \ln t \mid_k^{k + 1} - t \mid_k^{k + 1} - \frac{1}{2} \left( \ln k + \ln (k + 1) \right) \\ &= \ln \frac{ (k + 1)^{k + 1} }{ k^k } \cdot \frac{1}{ k^{\frac{1}{2} } (k + 1)^{\frac{1}{2} } } - 1 \\ &= \ln \left( \frac{k + 1}{k } \right)^{ k + \frac{1}{2} } - 1 \\ &= \left( \frac{2k + 1}{2} \right) \cdot \ln \left( \frac{k + 1}{k } \right)- 1 \\ \end{aligned}

Let x=12k+1x = \frac{1}{2k + 1}. As k+1=12((2k+1)+1)k + 1 = \frac{1}{2}( (2k + 1) + 1), and k=12((2k+1)−1)k = \frac{1}{2}( (2k + 1) - 1), we can write

ϵk=(2k+12)⋅ln⁡(1+kk)−1=12xln⁡1+x1−x−1. \epsilon_k = \left( \frac{2k + 1}{2} \right) \cdot \ln \left( \frac{1 + k }{k } \right)- 1 = \frac{1}{2 x} \ln \frac{1 + x}{1 - x} - 1.

Using the Taylor's expansions for y=ln⁡(1−x)y = \ln(1 -x) and y=ln⁡(1+x)y = \ln(1 + x), we have

ln⁡(1−x)=−(x+x22+x33+...)ln⁡(1+x)=−(−x+x22−x33+...) \ln(1 - x) = -(x + \frac{x^2}{2} + \frac{x^3}{3} + ...) \\ \ln(1 + x) = -(-x + \frac{x^2}{2} - \frac{x^3}{3} + ...) \\

and

ln⁡1+x1−x=2(x+x33+x55+x77+...). \ln \frac{1 + x}{1 - x} = 2 (x + \frac{x^3}{3} + \frac{x^5}{5} + \frac{x^7}{7} + ... ).

It follows that

ϵk=x23+x45+x67+... \epsilon_k = \frac{x^2}{3} + \frac{x^4}{5} + \frac{x^6}{7} + ...

We can upper bound ϵk\epsilon_k by

ϵk≤x23(1+x2+x4+...)=x2311−x2=131(2k+1)2−1=112(1k−1k+1). \begin{aligned} \epsilon_k &\le \frac{x^2}{3} ( 1 + x^2 +x^4 + ... ) \\ &= \frac{x^2}{3} \frac{1}{1 - x^2} \\ &= \frac{1}{3} \frac{1}{ (2k + 1)^2 - 1} \\ &= \frac{1}{12} \left(\frac{1}{k } - \frac{1}{k + 1} \right). \end{aligned}

Also, we can lower bound ϵk\epsilon_k by

ϵk≥x23(1+x2/3+x4/32+...)=x2311−x2/3=13(2k+1)2−1=112(k2+k+212)≥112(k+1+112)(k+112)=112(1k+112−1k+1+112). \begin{aligned} \epsilon_k &\ge \frac{x^2}{3} ( 1 + x^2 / 3 +x^4 / 3^2 + ... ) \\ &= \frac{x^2}{3} \frac{1}{1 - x^2 / 3} \\ &= \frac{1}{ 3(2k + 1)^2 - 1} \\ &= \frac{1}{ 12(k^2 + k + \frac{2}{12} ) } \\ &\ge \frac{1}{ 12(k + 1 + \frac{1}{12}) ( k + \frac{1}{12} ) } \\ &= \frac{1}{12} \left(\frac{1}{k + \frac{1}{12} } - \frac{1}{k + 1 + \frac{1}{12} } \right). \end{aligned}

Let A=∑k=1∞ϵkA = \sum_{k = 1}^\infty \epsilon_k and R=∑k=n∞ϵkR = \sum_{k = n}^\infty \epsilon_k. Then

S^−S=A−R  ⟹  S=S^−A+R  ⟹  S=nln⁡n−n+1+12ln⁡n−A+R  ⟹  n!=e1−An(ne)neR. \begin{aligned} \hat S - S &= A - R \\ \implies S &= \hat S - A + R \\ \implies S &= n \ln n - n + 1 + \frac{1}{2} \ln n - A + R \\ \implies n! &= e^{1 - A} \sqrt{n} \left( \frac{n}{e} \right)^n e^R. \end{aligned}

By previous inequalities, we know

A≥112∑k=1∞(1k+112−1k+1+112)=11211+112=113A≤112∑k=1∞(1k−1k+1)=112. \begin{aligned} A &\ge \frac{1}{12} \sum_{k = 1}^\infty \left( \frac{1}{k + \frac{1}{12} } - \frac{1}{k + 1 + \frac{1}{12} } \right) = \frac{1}{12} \frac{1}{1 + \frac{1}{12} } = \frac{1}{13} \\ A &\le \frac{1}{12} \sum_{k = 1}^\infty \left(\frac{1}{k } - \frac{1}{k + 1} \right) = \frac{1}{12}. \end{aligned}

Similarly, we can get 112n+1=1121n+112≤R≤112n\frac{1}{12n + 1 } = \frac{1}{12} \frac{1}{n + \frac{1}{12} } \le R \le \frac{1}{12n}. To finish our proof, we have

n!∈[e11/12n(ne)ne1/(12n+1),e12/13n(ne)ne1/(12n)] n! \in [e^{11 / 12} \sqrt{n} \left( \frac{n}{e} \right)^n e^{ 1 / (12n + 1)}, e^{12 / 13} \sqrt{n} \left( \frac{n}{e} \right)^n e^{1 / (12 n) }]

□\square

Reference

[1] H. Robbins, “A Remark on Stirling’s Formula,” The American Mathematical Monthly, vol. 62, no. 1, pp. 26–29, 1955