Calculating the Number of Digits in x

  • Thread starter Thread starter soandos
  • Start date Start date
AI Thread Summary
To determine the number of digits in x!, Stirling's formula can be used, which approximates n! as n approaches large values. The formula indicates that the number of digits can be estimated using D = 1 + ⌊log₁₀(n!)⌋, which simplifies to D = 1 + ⌊x log x - x log e + O(log x)⌋. For easier calculations, especially for large n, the series D = 1 + ⌊∑ log₁₀(i)⌋ for i from 1 to n can be utilized. However, for very large n, calculating logs for each term may not be more efficient than using Stirling’s approximation. There are inquiries about achieving a specific precision in Mathematica without excessive decimal points, highlighting the need for manageable calculations.
soandos
Messages
166
Reaction score
0
is there a way to determine (does not need to be exact) the number of digits in x! ?

sorry if this is kind of pointless
 
Mathematics news on Phys.org
For large n, use Stirling's formula:

n! ~ (2[pi]n)1/2 (n/e)n
 
soandos said:
is there a way to determine (does not need to be exact) the number of digits in x! ?

O(x log x).

To be more precise, x log x - x log e + O(log x), where the base of the logarithms is the base you want to express the number.
 
Don't forget to then apply

D = 1 + \lfloor \log_{10} \lfloor n! \rfloor \rfloor

after that for the number of digits.
 
Gib Z said:
Don't forget to then apply

D = 1 + \lfloor \log_{10} \lfloor n! \rfloor \rfloor

after that for the number of digits.

If n! is hard to calculate, the series

D = 1 + \lfloor \sum^n_{i=1} \log_{10}i \rfloor

should be easier to calculate - for integer n.
 
Jarle said:
If n! is hard to calculate, the series

D = 1 + \lfloor \sum^n_{i=1} \log_{10}i \rfloor

should be easier to calculate - for integer n.

Depends how large n is. If it's quite large, calculating logs for each term up to it may not be easier than using Stirlings Formula which simplifies into something that doesn't look that bad after a log anyway. But that definitely is a good idea =]
 
Anyone know of a way to get an answer just to a certain precision in mathematica?
I do no mean truncating the answer, but more the way a person would, so for example,
1/"insert incredibly long hard to calculate mess here" as zero, or instead of getting the inside of a natural log to hundreds of decimal points, just get it to 10 or so.
is there a way to do that?
 
Back
Top