We know from Euler's gamma function that the factorial of a number can be expressed as follows:
Where n≥0, and n is a real number.
Figure 1 below shows the graph of [1.01], when n=10. Its area is factorial ten, of course (because this is an exact formula, not an approximation),
An observation of the graph shows it is skewed to the left, and so is not symmetrical.
Let us call the curve we are integrating f(x), so:
By differentiating, equating to zero and solving, we obtain the value of n, for x. Differentiating again, gives a negative value at n (for positive n), indicating that when x=n, f(x) is maximum.
Let us transform the curve, f(x) by moving it n to the left. We do this so its maximum is at 0, and we are more able to compare f(x) with the Gaussian Integral.
In Figure 2, the cyan (light blue) curve is the Gaussian curve, and the fuchsia (pink) curve is the gamma(11). While we can see the two curves are similar, their absolute differences are quite great. For instance, at x=10, the gamma is about 23,000 at this point and the Gaussian is about 3,000. However, the maximum of both curves is nearly half a million, so the values at x=10 are relatively small.
(The Gaussian Integral appears here simply because I do not know how to integrate the gamma function, except for some values, and I wish eventually to use the Gaussian to find Stirling's formula.)
To transform the curve, let u=x+n and, noting du=dx, we can substitute for x in [1.01], to obtain [1.03] below. Also, let us call the integral, I, for easy reference, so:
Because we have moved the curve, we have changed the limits on the integral, because when x=0, u=−n.
We can factorise (u+n)n by taking out the n giving nn·(1+u/n)n, and separate the variable and constant parts of e (e−(u+n)=e−u·e−n):
We can take the constants out of the integral, and we have:
We wish to simplify the integral by (eventually) exponentiating (1+u/n)n, so we take logarithms base e:
We can use Maclaurin's Series to expand the logarithm:
Hence, substituting this in [1.06], we obtain:
Now we can exponentiate [1.08], and substitute in [1.05], renaming the integral I2. We have changed the limits (from ∞ to n), because our substitution requires |u|<n
We can now simplify the integral:
Noting that the integral:
is a Gaussian Integral with the indicated definite sum, but the limits of the Gaussian are infinity. That is, for I2, [1.10], as n tends to infinity, I2 tends I, which is n! So,
We therefore claim that as n tends to infinity, factorial n tends to the value below, which is Stirling's Approximation:
It is possible to obtain greater accuracy in approximating factorials by using the Stirling Series, of which only three terms are given. The series can produce more accurate estimates up to a point, but after that it makes worse estimates. (This is stated without proof.)
The following table compares some factorials with values calculated using Stirling's Approximation.
|N||Factorial||%Error||Error Abs||%Error||%Error||Error Abs|
From the graph we can notice that as the value of n increases, the relative (percentage ) error decreases, but the absolute error increases (at 15!, the error in the formula (without corrections) is more than 7 thousand million!)
We have argued that as n tends to infinity, the formula tends to n! However, even with small values of n, the approximations are quite close.