in reply to Stirling Approx to N! for large Number?

I hope you miscopied your "reasonable approximation" because it's off by an order of magnitude . . . (4.0e5 vs 4.1e6). Also IMSMR log(n*m) should be log(n) + log(m) so the commented out example should be log(2) + log(PI) rather than log(2 + log(PI)) (which might explain any inacurracy).

Addendum: If you have access to a copy of Numerical Recipies In C (ISBN 0521431085), chapter 6 has a factorial approximation using ln(Γ(x)) which should be easily translated into Perl (or use it unaltered via Inline::C).

Replies are listed 'Best First'.
Re^2: Stirling Approx to N! for large Number?
by jimbojones (Friar) on Mar 25, 2005 at 14:45 UTC
    Hi

    Numerical Recipes in C is available free online. See Numerical Recipes Books On-Line. It's a great resource. The site says:

    Thanks to special permission from Cambridge University Press, we are able to bring you, free, the complete Numerical Recipes books in C, Fortran 77, and Fortran 90 On-Line, in Adobe Acrobat format. Due to copyright restrictions, Numerical Recipes in C++ is not available as part of this free resource.

    The factorial representation is available at this PDF (after a I chose LANL as the mirror site).

    - j