Possible connection between prime numbers in binary and $\pi$

201 Views Asked by At

I just realized I asked a question with a very similar title a while back. This is not a duplicate. It is another conjecture though.


Conjecture: $\lim\limits_{x\to\infty}\mu \{ f(2), f(3), f(5), ... , f(x) \}=\frac{\pi}{2}-1$ where $x\in\mathbb{P}$, $f(x)$ equals the amount of $1$s divided by the total number of digits in the binary representation of $x$.

$\mu$ is the arithmetic mean and $\mathbb{P}$ represents the set of all primes.

Example of $f(x)$ because of my poor explanation (I tried my best):

$f(5)\rightarrow 101\rightarrow \frac{\text{number of $1$s (or the digit sum)}}{\text{total number of digits}}\rightarrow\frac{2}{3}$

I have no idea why this conjecture would be true but it appears that it may converge, at least for the first $2000$ primes. In the picture, the green line is $y=\frac{\pi}{2}-1$ and the black points are $\mu \{ f(2), f(3), f(5), ... , f(x) \}$.

enter image description here

My question is whether or not my conjecture is true?

Am I missing something obvious here? Also, I find it very interesting that it looks similar to a quasiperiodic function.

2

There are 2 best solutions below

2
On BEST ANSWER

This conjecture seems unlikely to me. I suspect the apparent agreement is an artifact of not trying large enough numbers. I predict that your conjecture is wrong.

If $x>2$ is prime, then its binary representation starts with a 1 (because all binary representations do) and ends with a 1 (because all primes are odd). Heuristically, we could expect that every other bit is equally likely to be 0 or 1.

Under this heuristic, a $b$-bit prime can be expected to have about $(b+2)/2$ bits set to 1, on average. This corresponds to a fraction of $(b+2)/2b$ bits set to 1.

Under this heuristic, if you look at all of the primes that are up to $n$ bits long, then you'd expect the value of your expression ($\mu\{\cdots\}$) to be roughly $(n+2)/2n$, or a little bit more. Notice that the first 1900 primes are 15 bits long or less. So if you evaluate your expression on such a value of $x$, this heuristic would predict your expression would have the value about $(n+2)/2n$ where $n=15$, i.e., $17/30 \approx 0.567$, or a bit more. Notice that $\pi/2-1$ is about $0.57$.

So your observed data is consistent with my heuristic.

Also, my heuristic predicts that if you pick a much larger value of $x$, then the value will drop significantly, and that the correct limiting value is $0.5$, not $\pi/2-1$. So I predict that your conjecture is wrong.

To test this, you could write code to evaluate this expression for much larger values of $x$, and see how well it fits my heuristic vs your conjecture.

1
On

Partial result :

With this PARI/GP code I determined the minimum and the maximum for the mean in the range from the $10^7$-th prime upto the last prime below $10^9$ :

gp > mini=1;maxi=0;t=0;su=0.0;forprime(p=1,10^9,v=digits(p,2);r=1.0*vecsum(v)/length(v);su=su+r;t=t+1;f=su/t;if(t>10^7,if(f<mini,mini=f);if(f>maxi,maxi=f)));print(mini,"  ",f,"   ",maxi)
0.52710025334578590074151265796396630968  0.53079004362482697181564525293263092897   0.53693971161534270117817226154392726905
gp >