*** Welcome to piglix ***

Stirling's approximation


In mathematics, Stirling's approximation (or Stirling's formula) is an approximation for factorials. It is a good-quality approximation, leading to accurate results even for small values of n. It is named after James Stirling, though it was first stated by Abraham de Moivre.

The formula as typically used in applications is

or, for instance in the worst-case lower bound for comparison sorting (by changing the base of the logarithm),

(in big O notation). The next term in the O(ln n) is 1/2ln(2πn); a more precise variant of the formula is therefore

where the sign ~ means that the two quantities are asymptotic, that is, their ratio tends to 1 as n tends to infinity.

It is also possible to give a version of Stirling's formula with bounds valid for all positive integers n, rather than asymptotics: one has

for all positive integers n. These simple bounds follow from the more precise error bounds discussed below.

The formula, together with precise estimates of its error, can be derived as follows. Instead of approximating n!, one considers its natural logarithm as this is a slowly varying function:

The right-hand side of this equation minus

is the approximation by the trapezoid rule of the integral

and the error in this approximation is given by the Euler–Maclaurin formula:


...
Wikipedia

...