Possible connection between binary numbers and $\pi$

124 Views Asked by At

Here is the Desmos if you want to follow along: https://www.desmos.com/calculator/b4vtzruupm

In messing around with binary numbers, I created a function $f(x)$ in Desmos that generated a list of digits of the binary representation of the input $x$ in reverse.

For example, $f(10)$ would output $[0,1,0,1]$.

I then created a function $g(z)$ that created a list of points $(z,\text{indexes of all 1s in f(z)}))$.

For example, $g(10)$ would output $(10,2),(10,4)$. $(10,1)$ and $(10,3)$ were removed because the first and third numbers in $f(10)$ were $0$.

Then, I created a list $h$ made up of lists of $g(x)$ where $x\in\mathbb{N}$. After testing a few lists of natural numbers for $x$. I created a python program that let me put a little more than a thousand values of $x$ in $g(x)$ without having to manually type them in.

I then did a regression $h.y=\log_n(h.x)$ where $h.x$ denotes the list of $x$-values in $h$ and $h.y$ denotes the list of $y$-values in $h$. After doing thorough testing with lists such as $[1,...,1000]$ and $[1000,...,1600]$, it seemed like as if I were to use the set of all natural numbers, the value of $n$ from the regression would be equal to $\pi$.

For example, the range $[600,...,1500]$ gave me $n=3.1562889032$. I used many other ranges too.

Conjecture: Pick a positive integer N, and construct a set S of tuples consisting of all pairs $(\log m,i)$ for which $1\le m\le N$ and m has a one in the $2^{i−1}$'s place when written in binary. Find the line through the origin of best fit for the points S. Then the slope, as $N\to\infty$, tends to $\log\pi$.

It would be much appreciated if anyone could help prove, disprove, and/or explain this.

I would also really appreciate if someone helped me edit my post to make it clearer and easier to understand as I struggled with trying to explain what I was doing at points and think it is a little confusing.

Thanks in advance.

1

There are 1 best solutions below

0
On BEST ANSWER

The conjecture is false. The real slope turns out to be $2/(3\log 2)<1<\log\pi$.

Taking numbers from $1$ to $N$ as $N$ approaches infinity, the points tend to a uniform distribution between the $x$-axis and the upper edge in the triangular region shown below:

enter image description here

The upper edge of the triangle, which is the maximum in the uniform distribution, is set by the number of total bits there can be in the binary representation.

Then the slope of the best-fit line through this distribution and containing the origin is

$\dfrac{\int_\triangle(uy)(dy)(du)}{\int_\triangle(u^2)(dy)(du)}.$

Standard integration techniques lead to the value

$\dfrac{2}{3\log 2}\approx0.9618\approx\log(2.616).$

for this slope. As $\log 2>2/3$ this is less than $1$, whereas $\log\pi$ is greater than $1$.

The conjecture may have looked more accurate with $N$ values up to only $1000$ because the above triangular distribution applies only asymptotically. With finite $N$ the distribution has to be corrected to account for minimum $y$ values of $1$ not $0$, and maximum values generally greater than $\log N/\log 2$. If we were to extend the numerical analysis so that these deviations become smaller compared to the size of the triangle, we would see the apparent $\log\pi$ value slowly drop off, converging to the true value. The error is $O(1/\log N)$.