How Big Must N Be for Stirling's Formula to Achieve 2% Accuracy?

  • Thread starter Thread starter Physgeek64
  • Start date Start date
  • Tags Tags
    Accuracy Formula
Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
11 replies · 3K views
Physgeek64
Messages
245
Reaction score
11

Homework Statement


How big must N be for the simple version of stirlings formula to be accurate to within 2%

Homework Equations

The Attempt at a Solution


So I think the starting point is

##\frac{N lnN-N}{lnN!} =\alpha ## where ##\alpha=0.98##

But i have no idea how to solve this expression for N

Many thanks
 
Physics news on Phys.org
Physgeek64 said:

Homework Statement


How big must N be for the simple version of stirlings formula to be accurate to within 2%

Homework Equations

The Attempt at a Solution


So I think the starting point is

##\frac{N lnN-N}{lnN!} =\alpha ## where ##\alpha=0.98##

But i have no idea how to solve this expression for N
You can't solve it algebraically, but you can substitute values of N. With N = 100, ##\alpha \approx 0.991##
 
  • Like
Likes   Reactions: Charles Link
One thing that can aid in the computation is ## \ln{ N!}=\ln{N}+\ln(N-1)+... +\ln{2}+\ln{1} ##, but otherwise, this simply needs to be computed with the computer doing the work.
 
Physgeek64 said:

Homework Statement


How big must N be for the simple version of stirlings formula to be accurate to within 2%

Homework Equations

The Attempt at a Solution


So I think the starting point is

##\frac{N lnN-N}{lnN!} =\alpha ## where ##\alpha=0.98##

But i have no idea how to solve this expression for N

Many thanks

What, exactly, do you regard as the "simple version" of Stirling's formula? The simplest version that actually works is
$$N! \sim \sqrt{2 \pi} \, N^{N+ (1/2)} \, e^{-N},$$
and without the factors ##\sqrt{2 \pi}## and ##\sqrt{N}## the formula can never, ever get within 2% of ##N!##, no matter how large is ##N##.

However, in pp. 52--54 of his beautiful probability book, Feller gives a surprisingly simple derivation of the following:
$$\sqrt{2 \pi} N^{N+ (1/2)} e^{-N} < N! < \sqrt{2 \pi} \, N^{N+ (1/2)} \, e^{-N\:+\: 1/(12N)},$$
and this works for all ##N \geq 1##. (For clarity:the exponent is ##-N + \frac{1}{12N}##.) For example, even when ##N## is as small as ##N=1## the inequalities read as ##0.9221< 1 < 1.002##.

The inequalities should allow you to figure out when ##\sqrt{2 \pi}\, N^{N+ (1/2)} \, e^{-N}## comes within 2% of ##N!##.

See, eg., https://www.amazon.com/dp/0471257087/?tag=pfamazon01-20 for more information on Feller's book. I understand that free versions are now available on-line as pdf files.
 
Last edited:
Ray Vickson said:
What, exactly, do you regard as the "simple version" of Stirling's formula? The simplest version that actually works is
$$N! \sim \sqrt{2 \pi} \, N^{N+ (1/2)} \, e^{-N},$$
and without the factors ##\sqrt{2 \pi}## and ##\sqrt{N}## the formula can never, ever get within 2% of ##N!##, no matter how large is ##N##.

However, in pp. 52--54 of his beautiful probability book, Feller gives a surprisingly simple derivation of the following:
$$\sqrt{2 \pi} N^{N+ (1/2)} e^{-N} < N! < \sqrt{2 \pi} \, N^{N+ (1/2)} \, e^{-N\:+\: 1/(12N)},$$
and this works for all ##N \geq 1##. (For clarity:the exponent is ##-N + \frac{1}{12N}##.) For example, even when ##N## is as small as ##N=1## the inequalities read as ##0.9221< 1 < 1.002##.

The inequalities should allow you to figure out when ##\sqrt{2 \pi}\, N^{N+ (1/2)} \, e^{-N}## comes within 2% of ##N!##.

See, eg., https://www.amazon.com/dp/0471257087/?tag=pfamazon01-20 for more information on Feller's book. I understand that free versions are now available on-line as pdf files.
I think the 'simplest formula' is meant to be ##NlnN-N## in this case
 
Physgeek64 said:
I think the 'simplest formula' is meant to be ##NlnN-N## in this case

It is simple for sure; it is also wrong. You must beware of assuming that an accurate formula for ##\ln (f(n)## produces an accurate formula for ##f(n)## via exponentiation. It generally does not, and Stirling's formula is a perfect example of that.
 
Ray Vickson said:
It is simple for sure; it is also wrong. You must beware of assuming that an accurate formula for ##\ln (f(n)## produces an accurate formula for ##f(n)## via exponentiation. It generally does not, and Stirling's formula is a perfect example of that.
Okay, but how would i go about working out for which N gives an answer to within 2% of the true value? Thanks :)
 
Physgeek64 said:
Okay, but how would i go about working out for which N gives an answer to within 2% of the true value? Thanks :)

Use the two inequalities I wrote in #4.
 
Ray Vickson said:
Use the two inequalities I wrote in #4.
Can you solve for N in these, or just plug in values of N?
 
Ray Vickson said:
You must beware of assuming that an accurate formula for ##\ln (f(n)## produces an accurate formula for ##f(n)## via exponentiation. It generally does not, and Stirling's formula is a perfect example of that.
If the accuracy of ln( f(n) ) is in terms of abs( trueValue - estimatedValue ) and the desired accuracy is in terms of percentage, I think this should be possible.
 
FactChecker said:
If the accuracy of ln( f(n) ) is in terms of abs( trueValue - estimatedValue ) and the desired accuracy is in terms of percentage, I think this should be possible.
Unfortunately, not. If ##f(n) \sim g(n) \to \infty## as well as ## \ln f(n), \ln g(n) \to \infty##, then we have ##\ln f(n) \sim \ln g(n)##. However, we also have ##\ln f(n) \sim \ln 2 + \ln g(n)##, and yet we do not have ##2 g(n)## asymptotic to ##f(n)##. And that is the problem right there: an additive constant in the logarithm (whose importance goes to zero in the limit) becomes a constant mutliplicative factor in the original function, whose importance never goes away.
 
Physgeek64 said:
Can you solve for N in these, or just plug in values of N?

You can do it either way, but solving directly for N is easier.