Calculating the Number of Digits in x

  • Context: Undergrad 
  • Thread starter Thread starter soandos
  • Start date Start date
Click For Summary

Discussion Overview

The discussion revolves around methods to estimate the number of digits in the factorial of a number, x!. Participants explore various mathematical approaches, including Stirling's formula and logarithmic calculations, while considering the precision of the results.

Discussion Character

  • Exploratory
  • Mathematical reasoning
  • Technical explanation

Main Points Raised

  • Some participants propose using Stirling's formula for large n, suggesting that n! can be approximated as (2πn)^(1/2) (n/e)^n.
  • Another approach mentioned involves estimating the number of digits using the formula D = 1 + ⌊log₁₀⌊n!⌋⌋.
  • It is noted that for integer n, an alternative series D = 1 + ⌊∑ᵢ₌₁ⁿ log₁₀ i⌋ may be easier to compute than calculating n! directly.
  • Some participants express that the feasibility of these methods may depend on the size of n, with larger values potentially complicating direct logarithmic calculations.
  • A participant inquires about obtaining results to a certain precision in Mathematica, seeking a method to limit the number of decimal points in calculations without truncating the answer.

Areas of Agreement / Disagreement

Participants present multiple approaches and methods, indicating that there is no consensus on a single best method for estimating the number of digits in x!. The discussion remains open with various competing views and techniques.

Contextual Notes

Some limitations are noted regarding the complexity of calculations for large n and the precision of results, but these aspects are not resolved within the discussion.

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

[tex]D = 1 + \lfloor \log_{10} \lfloor n! \rfloor \rfloor[/tex]

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

[tex]D = 1 + \lfloor \log_{10} \lfloor n! \rfloor \rfloor[/tex]

after that for the number of digits.

If [tex]n![/tex] is hard to calculate, the series

[tex]D = 1 + \lfloor \sum^n_{i=1} \log_{10}i \rfloor[/tex]

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

[tex]D = 1 + \lfloor \sum^n_{i=1} \log_{10}i \rfloor[/tex]

should be easier to calculate - for integer [tex]n[/tex].

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?
 

Similar threads

  • · Replies 11 ·
Replies
11
Views
3K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 7 ·
Replies
7
Views
2K
  • · Replies 1 ·
Replies
1
Views
1K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 20 ·
Replies
20
Views
2K
  • · Replies 2 ·
Replies
2
Views
1K
  • · Replies 34 ·
2
Replies
34
Views
7K
  • · Replies 13 ·
Replies
13
Views
3K
Replies
1
Views
2K