You are on page 1of 3

Stirlings Formula

Stirlings Formula gives a good approximation for n! in terms of elementary functions.


Before stating the formula, we introduce the following notation: if f (n) is a function
and g(n) is a function, then we write
f (n) g(n)

f (n)
= 1.
n g(n)
lim

The statement f (n) g(n) is read f


(n) is asymptotic to g(n) as n . For example,

2
2
one verifies that n (n + 1) and 1 + n n. Here is Stirlings Formula:
Stirlings Formula

n! nn en 2n.

The following graph shows a plot of the function h(n) = n!/nn en 2n, confirming
Stirlings
Formula: h(n) 1 as n . It turns out that h(n) is decreasing so
nn en 2n always underestimates n! by a small amount.
1.04

1.03

1.02

1.01

10

20

30

40

50

60

70

Figure 1 : Stirlings Formula


The proof of Stirlings Formula is beyond the scope of this course. Instead of proving
the formula, we rather give a proof of a weaker statement: we show that for every
positive integer n,
nn en < n! < (n + 1)n+1 en .
(1)
This does not prove Stirlings Formula,
but it gives motivation for the nn en term in

the formula. The proof of the 2n part of the formula is more difficult.

First Proof To prove (1), we just have to show (by taking logarithms):
n log n n < log(n!) < (n + 1) log(n + 1) n.
Since n! = n (n 1) (n 2) 2 1,
log(n!) = log 1 + log 2 + . . . + log n.
The sum on the right can be estimated by integrals: lets show that
Z n+1
log 1 + log 2 + . . . + log n <
log x dx.
1

To see this, note that the integral represents the area under the curve y = log x (the
red curve in the left plot below) for 1 x n+1, whereas the sum log 1+log 2+. . .+
log n represents adding up the areas of rectangles with height log k for k = 1, 2, . . . , n
(see green step function in the left plot below). Now we can work out the integral:
Z n+1
in+1
log x dx = x log x x + 1
= (n + 1) log(n + 1) n.
1

Therefore log(n!) < (n + 1) log(n + 1) n. Were going to do the same thing to prove
log(n!) > n log n n: we claim that
Z n
log 1 + log 2 + . . . + log n >
log x dx.
0

This is shown in the figure on the right, with the red curve representing log x and the
rectangles representing log(1) + log(2) + . . . + log(n).

2.0

2.0

1.5

1.5

1.0

1.0

0.5

0.5

0.0

0.0
2

Figure 2 : Approximating log(n!)


Therefore log(n!) >

Rn
0

log xdx = n log n n, which completes the proof of (1).


2

Second Proof We prove (1) by induction. Before we do this, we need a very


important inequality concerning e: for all k 2

1 k 1
1 k1
< < 1
.
k
e
k

(2)

To see why this is true, we note that


ex > 1 x

and

ex > 1 + x

for any non-zero real number x draw the graphs of these functions to see why this
is true. If we put x = k1 , then we get from ex > 1 x:
1

e k > 1

1
k

1
1 k
> 1
e
k

which proves the left inequality in (2). If we put x =


1

e k1 > 1 +
This implies
1

e k1 < 1

1
k

1
,
k1

then we get from ex > 1+x:

1
.
k1
1
1 k1
< 1
e
k

which proves the right inequality.


Now we prove (1) by induction. For n = 1, (1) is clearly true since 1/e < 1 < 4/e
(remember that e 2.718...). Suppose that we have proved (1) with n = k 1, in
other words, suppose we have proved:
(k 1)k1 e(k1) < (k 1)! < k k e(k1) .
Then, multiplying through by k, we get
k(k 1)k1 e(k1) < k! < k k+1 e(k1) .
This is the same as

1 k1
1 k+1
k k
k+1 k
k e 1
e < k! < (k + 1) e 1
e .
k
k+1
By (2), the square-bracketed term on the left is larger than 1 and the square-bracketed
term on the right is less than 1. So we get
k k ek < k! < (k + 1)k+1 ek .
This proves (1), by induction.

You might also like