The Stirling's formula is an approximation to the factorial function and can be generalised for the gamma function; it states that which means that the two quantities are asymptotically equal when approaches infinity and can be used for numerical estimation.
Proof:
First, we rewrite the factorial function using Euler's integral of the second kind (definition for the gamma function )as and change the variable of integration to such that :
Let us define , then there is . For , there is while we may apply logaritihm on both sides to obtain . Furthermore, for , from the Mercator series we have the asymptotic approximation for the natural logarithm , which may be use to evaluate . Therefore, we have shown the approximation as .
Then, let us consider which implies there is . Since is integrable on , from the Lebesgue's dominated convergence theorem we can deduce that is also integrable on and hence can be properly defined and evaluated.
In summary, we have shown that for there is the asymptotic equality which leads to . From the Gaussian integral and the aforementioned Euler's integral representation of , we have finally proved the correctness of the Stirling's approximation as .
The Stirling's approximation can be further applied for the gamma function for where . Since the error term is large for , we may use the reflection formula to estimate .
The Stirling's approximation can also be generalised to the asymptotic expansion named Stirling series for both the factorial and the gamma function to an arbitrary-precision.
Notice that the series is not absolutely convergent; for any particular , only a finite number of terms can be used to ameliorate the accuracy of estimation.