|
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;
}
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.
|
|