Stirling's Approximation

LA home
Computing
 Algorithms
 Bioinformatics
 FP,  λ
 Logic,  π
 MML
 Prog.Langs

Algorithms
 glossary
 Numerical
  Num'Errors
  Polynomials
  Stirling
  Mean&S.D.
  Integration

Stirling's approximation for N!:

N! ~ sqrt(2 π N).(N/e)N + ...

hence

loge(N!) ~ N.loge(N) - N + 0.5 loge(N) + 0.5 loge(2 pi) +...

function Stirling(N) // JavaScript
 { return
    (N+0.5)*Math.log(N) - N + Math.log(2*Math.PI)/2;
 }

L
.
A
.
N=

Factorial is generalized by the Γ function to real, and even complex, values. For a +ve int, n, Γn=(n-1)!.

Notes

D. E. Knuth in The Art of Computer Programming, Fundamental Algorithms, Vol.1, p.46, (1969), gives the reference as:
James Stirling. Methodus Differentialis, p.137, (1730).
On page 111 of his book, Knuth derives a more accurate approximation:
N! = sqrt(2 π N) (N/e)N {1 + 1/12N + 1/288N2 - 139/51840N3 - 571/2488320N4 + O(1/N5)}
-- L.A., 1999, 2000, 2007, Australia.
window on the wide world:

Computer Science Education Week

Linux
 Ubuntu
free op. sys.
OpenOffice
free office suite,
ver 3.4+

The GIMP
~ free photoshop
Firefox
web browser
FlashBlock
like it says!

© L. Allison   http://www.allisons.org/ll/   (or as otherwise indicated),
Faculty of Information Technology (Clayton), Monash University, Australia 3800 (6/'05 was School of Computer Science and Software Engineering, Fac. Info. Tech., Monash University,
was Department of Computer Science, Fac. Comp. & Info. Tech., '89 was Department of Computer Science, Fac. Sci., '68-'71 was Department of Information Science, Fac. Sci.)
Created with "vi (Linux + Solaris)",  charset=iso-8859-1,  fetched Friday, 18-Apr-2014 13:19:23 EST.