Proving the Number of Digits in a Number Formula: A Scientific Exploration

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

Discussion Overview

The discussion centers around the formula for calculating the number of digits in a number \( n \) using logarithms, specifically the expression \( \text{number of digits in } n = [\log(n) + 1] \), where the logarithm is in base 10. Participants explore methods of proving this formula and its generalization to other bases, as well as its implications in algorithm analysis.

Discussion Character

  • Exploratory
  • Technical explanation
  • Mathematical reasoning

Main Points Raised

  • One participant proposes that the number of digits in \( n \) can be expressed as \( [\log(n) + 1] \) and seeks a proof for this assertion.
  • Another participant states that a number \( x \) has \( n \) digits if and only if \( 10^{n-1} \leq x < 10^n \), leading to a mathematical derivation that supports the original claim.
  • A third participant reinforces the previous point by taking the logarithm of the inequalities and noting the properties of logarithms as increasing functions.
  • One participant expresses gratitude for the clarification and acknowledges the generalization of the concept to any base \( b \), particularly highlighting its relevance in algorithm analysis.
  • Another participant connects the discussion to the efficiency of the Euclidean Algorithm, suggesting that it terminates in at most 7 times the number of digits of \( b \) when applied to two numbers \( a \) and \( b \) (with \( a > b \)).

Areas of Agreement / Disagreement

Participants generally agree on the validity of the logarithmic approach to determining the number of digits in a number, but there is no explicit consensus on the proof methodology or the implications of the generalization to other bases.

Contextual Notes

The discussion does not resolve potential limitations or assumptions regarding the use of logarithms in different bases or the specific conditions under which the Euclidean Algorithm's efficiency is analyzed.

Buri
Messages
271
Reaction score
0
I was playing around with my calculator and I noticed that to calculate the number of digits in a number n we have # of digits in n = [log(n) + 1], where log is in base 10 and [] represents the floor function. I after looked this up and it seems like its true. But how would you go about proving something like this? I thought of writing n as its decimal expansion, and then taking the logarithm, but it doesn't seem to get me no where. Any ideas?
 
Physics news on Phys.org
Let x be a number, then it is easy to see that

x has n digits if and only if 10^{n-1}\leq x&lt;10^{n}.

If we apply your expression on this, then we obtain

n=\log(10^{n-1})+1\leq \log(x)+1&lt;\log(10^n)+1=n+1

This yields that [\log(x)+1]=n.
 
A number, n, has "d" digits if and only if 10^{d-1}\le n&lt; 10^d. Take the logarithm (base 10) of each part of that, using the fact that logarithm is an increasing function.
 
Ahhh didn't think of that. Thanks a lot to both of you! :)
 
Buri said:
Ahhh didn't think of that. Thanks a lot to both of you! :)

Note that this can be generalized to any base b system. In particular, the number of bits needed to represent a number in base 2 is the log of that number to the base 2. This is really important in the analysis of algorithms.
 
Robert1986 said:
Note that this can be generalized to any base b system. In particular, the number of bits needed to represent a number in base 2 is the log of that number to the base 2. This is really important in the analysis of algorithms.

Funny how you actually mentioned algorithms. I actually got into this problem by looking at the efficiency of the Euclidean Algorithm. I was trying to show that when the Euclidean Algorithm is applied to a and b (a > b) that it terminates in at most 7 times the number of digits of b.
 

Similar threads

  • · Replies 11 ·
Replies
11
Views
4K
  • · Replies 17 ·
Replies
17
Views
2K
  • · Replies 6 ·
Replies
6
Views
752
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 3 ·
Replies
3
Views
1K
  • · Replies 5 ·
Replies
5
Views
4K
  • · Replies 11 ·
Replies
11
Views
2K
  • · Replies 25 ·
Replies
25
Views
4K
  • · Replies 7 ·
Replies
7
Views
3K
  • · Replies 4 ·
Replies
4
Views
2K