Can you see a fractal in primes in base binary?

232 Views Asked by At

I'm currently writing a computer program that computes prime numbers, and then, it give me on binary base. The structure is obviously $1XX\dotso XX1$. The first $1$ and the last $1$, are common, because all primes are odd except $2$.

If the binary expansions of the primes between $2^N$ and $2^{N+1}$ are written in an array, the pattern of $1$s and $0$s appears to have a fractal structure. For example, these are prime numbers from $256$ to $512$:

1 0 0 0 0 0 0 0 1 - 257
1 0 0 0 0 0 1 1 1
1 0 0 0 0 1 1 0 1
1 0 0 0 0 1 1 1 1
1 0 0 0 1 0 1 0 1
1 0 0 0 1 1 0 0 1
1 0 0 0 1 1 0 1 1
1 0 0 1 0 0 1 0 1
1 0 0 1 1 0 0 1 1
1 0 0 1 1 0 1 1 1
1 0 0 1 1 1 0 0 1
1 0 0 1 1 1 1 0 1
1 0 1 0 0 1 0 1 1
1 0 1 0 1 0 0 0 1
1 0 1 0 1 1 0 1 1
1 0 1 0 1 1 1 0 1
1 0 1 1 0 0 0 0 1
1 0 1 1 0 0 1 1 1
1 0 1 1 0 1 1 1 1
1 0 1 1 1 0 1 0 1
1 0 1 1 1 1 0 1 1
1 0 1 1 1 1 1 1 1
1 1 0 0 0 0 1 0 1
1 1 0 0 0 1 1 0 1
1 1 0 0 1 0 0 0 1
1 1 0 0 1 1 0 0 1
1 1 0 1 0 0 0 1 1
1 1 0 1 0 0 1 0 1
1 1 0 1 0 1 1 1 1
1 1 0 1 1 0 0 0 1
1 1 0 1 1 0 1 1 1
1 1 0 1 1 1 0 1 1
1 1 1 0 0 0 0 0 1
1 1 1 0 0 1 0 0 1
1 1 1 0 0 1 1 0 1
1 1 1 0 0 1 1 1 1
1 1 1 0 1 0 0 1 1
1 1 1 0 1 1 1 1 1
1 1 1 1 0 0 1 1 1
1 1 1 1 0 1 0 1 1
1 1 1 1 1 0 0 1 1
1 1 1 1 1 0 1 1 1
1 1 1 1 1 1 1 0 1 - 509

If we represent the transpose of this matrix as a raster array with each $1$ as a black square and each $0$ as a white square, we generate the following image:

enter image description here

Can we explain the apparent fractal structure in this image?

2

There are 2 best solutions below

1
On

I think that the fractal like structure is really arising from the simple repetitive patterns that we see when looking at consecutive integers in base 2. Note, for example, the similarity of the red blocks in the base 2 expansions of the numbers 1 through 7 below: $$ \begin{array}{ccc} 0 & \color{red}0 & \color{red}1 \\ 0 & \color{red}1 & \color{red}0 \\ 0 & \color{red}1 & \color{red}1 \\ 1 & 0 & 0 \\ 1 & \color{red}0 & \color{red}1 \\ 1 & \color{red}1 & \color{red}0 \\ 1 & \color{red}1 & \color{red}1 \\ \end{array} $$

If write the numbers $2^7=128$ through $2^8=155$ in base two and color and rasterize (essentially representing a zero as a white block and a one as a black block), then we obtain an image like the one below. (Note that I've transposed the matrix just because I think it fits better onto the web page.)

enter image description here

I don't think this is quite "fractal", since the natural limiting object is a line segment due to the shrinking aspect ratio. I can see how one might "see" a fractal, though.

I also don't think that focusing on prime numbers really makes sense. If anything, focusing on the primes obscures the simplicity of the process. Nonetheless, there's lots of primes so you kind of see a similar pattern, if you do so.

4
On

This part of the image:

enter image description here

where a black area is partitioned vertically from a white area, occurs every time you carry, so e.g. where $X, Y$ and $Z$ are arbitrary binary words, when you go from $X1111Y_2$ to $(X+1)0000Z_2$.

Since primes have gaps, $Y\to Z$ is a relatively random change and its height represents the ceiling base $2$ of the prime gap. Whereas, the carry operation almost always exchanges any bit sequence of consecutive ones to zeroes in its entirety.

The fractal you are seeing is the frequency of these vertical bars (the long carries), adjusted from every $2^n$ (its frequency in the natural numbers) to that same frequency divided by the density of primes in the integers.