Stirling's approximation gives an approximate value for the factorial function
or the gamma function
for
.
The approximation can most simply be derived for
an integer by approximating the
sum over the terms of the factorial with an integral,
so that
|
(1)
| |||
|
(2)
| |||
|
(3)
| |||
|
(4)
| |||
|
(5)
| |||
|
(6)
|
The equation can also be derived using the integral definition of the factorial,
|
(7)
|
Note that the derivative of the logarithm of the integrand can be written
|
(8)
|
The integrand is sharply peaked with the contribution important only near . Therefore, let
where
,
and write
|
(9)
| |||
|
(10)
|
Now,
|
(11)
| |||
|
(12)
|
so
|
(13)
| |||
|
(14)
| |||
|
(15)
|
Taking the exponential of each side then gives
|
(16)
| |||
|
(17)
|
Plugging into the integral expression for then gives
|
(18)
| |||
|
(19)
|
Evaluating the integral gives
|
(20)
| |||
|
(21)
|
(Wells 1986, p. 45). The factor is sometimes called the Stirling
constant. Taking the logarithm of both sides then
gives
|
(22)
| |||
|
(23)
|
This is Stirling's series with only the first term retained and, for large ,
it reduces to Stirling's approximation
|
(24)
|
Taking successive terms of ,
where
is the floor function, gives the sequence 1, 2,
4, 10, 26, 64, 163, 416, 1067, 2755, ... (OEIS A055775).
For positive integers , Stirling's approximation can be extended to the double
inequality
|
(25)
|
(Robbins 1955, Feller 1968).
Gosper has noted that a better approximation to (i.e., one which approximates the terms in Stirling's
series instead of truncating them) is given by
|
(26)
|
Considering
a real number so that
,
the equation (26) also gives a much closer approximation to
the factorial of 0,
, yielding
instead of 0 obtained with the conventional
Stirling approximation.