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
Click For Summary
SUMMARY

The discussion centers on determining the minimum value of N for which Stirling's formula achieves an accuracy of 2% when estimating N!. The key equation presented is \(\frac{N \ln N - N}{\ln N!} = \alpha\) with \(\alpha = 0.98\). It is established that the simplest version of Stirling's formula, \(N! \sim \sqrt{2 \pi} \, N^{N + (1/2)} \, e^{-N}\), must include specific factors to achieve the desired accuracy. The inequalities derived from Feller's probability book provide a framework for calculating the threshold for N.

PREREQUISITES
  • Understanding of Stirling's formula and its applications in approximating factorials.
  • Familiarity with logarithmic functions and their properties, particularly \(\ln N!\).
  • Basic knowledge of inequalities and their implications in mathematical proofs.
  • Proficiency in numerical methods for evaluating functions and approximations.
NEXT STEPS
  • Study the derivation and applications of Stirling's formula in greater detail.
  • Learn about numerical methods for evaluating factorials and logarithmic functions.
  • Explore Feller's probability book, particularly pages 52-54, for insights on Stirling's approximation.
  • Investigate the implications of additive constants in logarithmic approximations and their effects on accuracy.
USEFUL FOR

Mathematicians, statisticians, and students studying probability theory or numerical analysis, particularly those interested in approximating factorials and understanding the limits of Stirling's formula.

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 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?
 
  • #10
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.
 
  • #11
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.
 
  • #12
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.
 

Similar threads

  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 3 ·
Replies
3
Views
1K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 19 ·
Replies
19
Views
4K
  • · Replies 9 ·
Replies
9
Views
3K
Replies
3
Views
2K
Replies
21
Views
15K
  • · Replies 3 ·
Replies
3
Views
1K
  • · Replies 2 ·
Replies
2
Views
907