Factorials and Stirling's Formula


By Paul on Saturday, December 22, 2001 - 12:17 pm:

Is there any way of calculating n! without encountering the large number created by the factorial?


By Nicholas Dean on Thursday, June 06, 2002 - 03:16 pm:
On a calculator I approximate n!= ( n+0.5 60.5 )60.5 × ( n+0.5 e )n-60 ×60!. When n=100 the error is less than 0.03%.
By Graeme Mcrae on Thursday, June 06, 2002 - 06:06 pm:

Nicholas, it's a good approximation. In fact, for n=60, it's perfect!

Your expression can be simplified to:


= e-n ×(n+0.5 )n+0.5 ×1.51930020735084
The constant (1.519...) can be adjusted to make any particular "n" come out exact, and the others will be wrong by only a few percent at the most. It's a pretty good approximation.

By Graeme Mcrae on Thursday, June 06, 2002 - 10:07 pm:

Nicholas, just fooling around with an Excel spreadsheet, I noticed that some adjustments can be made that make the formula fit even better:


e-n ×(n+0.7914 )n+0.5 ×1.13603289 gives n! to the nearest integer for n up to 7, and the nearest multiple of 10 for n up to 10.

After 10, the formula gives n! with an error less than 0.002%.

Here's another thought: e-n ×(n+0.91893858 )n+0.5 gives a close approximation for all n. The error is less than 1% when n>3, less than 0.1% when n>45, less than 0.01% when n>459, approaching zero (up to rounding error of Excel) as n increases.
By the way, the gammaln function in Excel gives the natural log of (n-1)! which is very useful for evaluating formulas like this for large n.

Does anyone know the limit as n of n!/ e-n ×(n+0.5 )n+0.5 ?

It seems to be about 1.52034683, but is there an exact answer, or does this number have a name?


Here's another one:

( e-n ×(n+0.803692299 )n+0.5 )×1.12214972 is exactly equal to n! when n is 1, and less than 0.1% off for all other n, approaching a limit of 0% error as n approaches infinity.
--Graeme

By Arun Iyer on Thursday, June 06, 2002 - 10:41 pm:

the answer of the required limit is


2π e
love arun
By Graeme Mcrae on Thursday, June 06, 2002 - 11:05 pm:
Oh, thanks Arun, 2π e is 1.52034690, proving that my numerical fooling around came very close to the right answer. Thanks for the info!

This means that a fairly good approximation of n!, for large n, is

2π e e-n (n+0.5 )n+0.5 .

--Graeme

By Arun Iyer on Friday, June 07, 2002 - 06:52 am:

Oh!!so you require an approximation of n!....

Why don't you use Stirlings formula..


n! is asymptotic to 2π e-n nn+0.5 as n tends to infinity.
This is what i used to evaluate your limit actually.


love arun
[Editor: Here's an interesting thread on large factorial calculations . ]