Accuracy of Stirlings Formula

In summary: 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...
  • #1
Physgeek64
247
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
  • #2
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
  • #3
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.
 
  • #4
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:
  • #5
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
 
  • #6
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.
 
  • #7
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 :)
 
  • #8
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.
 
  • #9
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.
 

1. What is Stirling's Formula?

Stirling's Formula is a mathematical approximation for the factorial function, which calculates the product of all positive integers less than or equal to a given number. It is named after Scottish mathematician James Stirling and is commonly used in statistics, probability, and number theory.

2. How accurate is Stirling's Formula?

The accuracy of Stirling's Formula depends on the number of terms used in the approximation. As the number of terms increases, the accuracy improves. However, it is not exact and can introduce errors when compared to the actual factorial value.

3. What is the formula for Stirling's Formula?

The formula for Stirling's Formula is n! ≈ √(2πn)(n/e)^n, where n is the given number and e is the mathematical constant equal to approximately 2.71828.

4. When is Stirling's Formula used?

Stirling's Formula is commonly used to simplify complex calculations involving large factorials. It is also used in probability and statistics to estimate the number of possible outcomes in a given scenario.

5. What are the limitations of Stirling's Formula?

Stirling's Formula is only an approximation and can introduce errors when compared to the actual factorial value. It is also less accurate for smaller values of n. Additionally, it does not work for non-integer values of n and can produce negative values in some cases.

Similar threads

  • Precalculus Mathematics Homework Help
Replies
8
Views
2K
  • Calculus and Beyond Homework Help
Replies
1
Views
346
  • Precalculus Mathematics Homework Help
Replies
4
Views
1K
  • Precalculus Mathematics Homework Help
Replies
2
Views
3K
  • Precalculus Mathematics Homework Help
Replies
2
Views
2K
  • Precalculus Mathematics Homework Help
Replies
2
Views
1K
  • Precalculus Mathematics Homework Help
Replies
2
Views
1K
  • Precalculus Mathematics Homework Help
Replies
3
Views
1K
  • Precalculus Mathematics Homework Help
Replies
8
Views
2K
  • Precalculus Mathematics Homework Help
Replies
3
Views
1K
Back
Top