# What is this strange constellation of primes found in the plot of $f(x) = \sum\limits_{n=1}^{\infty} {1 \over 2^{n-1}} e^ {{2\pi i x \over {n}} }$?

Let

## $$f(x) = \sum\limits_{n=1}^{\infty} {1 \over 2^{n-1}} e^ {{2\pi i x \over {n}} }$$

$f$ is therefore a complex-valued function of a real variable. (An intuitive explanation at the very bottom of this question)

On a Cartesian plane, I plot all points $(Re(f(x)), Im(f(x)))$ for real $x$ where $0 \leq x \leq 1000$: All values for the specified reals are first plotted in dark green.

Values of $f(x)$ only for integer values of $x$ between $0$ and $1000$ are overlayed as grayscale dots of varying intensity (explained later on) on the green trajectory.

Values of $f(x)$ only for prime values of $x$ between $0$ and $1000$ are overlayed as red dots on the green trajectory.

A pattern emerges: all prime numbers distribute into $16$ evident clusters (or as I like to call them, constellations - fun to pretend that integers are stars on the night sky), with the exception of $2, 3$ and $5$, whose locations I've highlighted on the plot.

Let us take a closer look at $f(x)$ values for the first $1000000$ integers: Same story: I first plot the integers in grayscale, and only later the primes in red. It looks like the integers form $60$ elliptical clusters, each of which could be divided into even more clusters.

I thought it'd be good idea to give some specific intensity ($0-255$) to the pixel at $f(x)$, so I've tried calculating it as $255\over{x \mod{60}}$ - this is why some gray pixels are darker and some brighter. As you can see on the plots, pixels belonging to the same cluster have the same intensities, so perhaps such formula can be used to identify which cluster the value of $f(x)$ will belong to.

Here is a closer look at one of the clusters (best viewed in 1:1): It looks like the aforementioned "elliptical" clusters divide into $42$ clusters, four of which intersect. These clusters divide into yet another $11$ circles...

...then let's see an even deeper zoom at one of these clusters: Each of the $11$ circles is made of circles again!

Sadly, primes don't exhibit any order at this level of zoom.

## Questions:

• What is so special about primes that they gather in these sixteen constellations? Does this function tell us something interesting about primality?
• Could this function be slightly modified so that a more striking structure becomes apparent?
• Could this function be extended so that its values have a higher number of dimensions? For example, a one-dimensional version would be: $$f(x) = \sum\limits_{n=1}^{\infty} {1 \over 2^{n-1}} cos( {{2\pi \over {n}} x} )$$

(whose plot unfortunately is not nearly as interesting)

## Intuitive explanation of $f(x)$:

Imagine a stick of length equal to $1$.

It makes a full rotation every one second: Imagine that another stick of length equal to $1\over{2^{1}}$ was attached to the above stick.

The smaller stick rotates, too: it makes a full rotation every two seconds: Imagine that another stick of length equal to $1\over{2^{2}}$ was attached to the smaller stick from above.

The new third stick, rotates, too: it makes a full rotation every three seconds: Repeating this procedure infinitely we get the trajectory of $f(x)$: Calculating $f(n)$ therefore asks: at which $(x, y)$ does the tip of this curve end up after $n$ seconds worth of time?

• I haven't carefully analyzed the procedure behind your graph. However, 99.9% of the time, "patterns in primes" are just an illusion for "patterns in residue classes". The symptoms you describe exactly fit this hypothesis: modulo 60 the primes can only appear in one of $\phi(60)=16$ residue classes, except for the primes dividing $60$, namely $2$, $3$ and $5$. If you just plot the integers that are $1, 7, 11, 13, 17, 19, 23, 29$ mod $30$ you should find that they cluster exactly the same way as the primes do, so the phenomenon has very little to do with primality. – Erick Wong Nov 20 '16 at 20:19
• Of course, if you zoom in further and resolve smaller clusters, you will probably find that you need finer-grained residue classes to distinguish them, such as mod $420$. – Erick Wong Nov 20 '16 at 20:20
• @ErickWong A very interesting insight indeed! Then, is the number of clusters of a given granularity predictable (perhaps given by a simple formula)? By the way, I believe that your comments are sufficient to make them a good answer. – Patryk Czachurski Nov 21 '16 at 0:54
• Now that I think of it, $12, 60, 420$ look like $p_{n} \# * 2$. – Patryk Czachurski Nov 21 '16 at 1:03

Let us start with $$f(K) = \sum_{n\ge 1} s^n\; \sin\frac {2\pi i\; K }n\ ,\ s=\frac 12\ ,\ K \in \mathbb Z\ .$$ (Other values of $s$, with a "small" $|s|$ may also be relevant for similar phenomena. Possibly, other sequences $(a_n)$ with $a_n\searrow 0$ lead to the similar behavior. But to fix ideas, $s=1/2$ in the sequel, and $(1/2)^n\searrow 0$ exponentially.)

Let me print the first approximations of the first few sine values $\exp (2\pi i\; K/n)$, $1\le n\le 9$, for the values $29$ and $30$ of $K$. sage code and results:

sage: for K in [28, 29, 30]:
....:     for n in [1..9]:
....:         print "n=%s exp(2 pi i %s/n) ~ %s" % ( n, K, CC( exp(2*pi*i*K/n) ) )
....:     print
....:
n=1 exp(2 pi i 28/n) ~ 1.00000000000000
n=2 exp(2 pi i 28/n) ~ 1.00000000000000
n=3 exp(2 pi i 28/n) ~ -0.500000000000000 + 0.866025403784439*I
n=4 exp(2 pi i 28/n) ~ 1.00000000000000
n=5 exp(2 pi i 28/n) ~ -0.809016994374947 - 0.587785252292473*I
n=6 exp(2 pi i 28/n) ~ -0.500000000000000 - 0.866025403784439*I
n=7 exp(2 pi i 28/n) ~ 1.00000000000000
n=8 exp(2 pi i 28/n) ~ -1.00000000000000
n=9 exp(2 pi i 28/n) ~ 0.766044443118979 + 0.642787609686538*I

n=1 exp(2 pi i 29/n) ~ 1.00000000000000
n=2 exp(2 pi i 29/n) ~ -1.00000000000000
n=3 exp(2 pi i 29/n) ~ -0.500000000000000 - 0.866025403784439*I
n=4 exp(2 pi i 29/n) ~ 1.00000000000000*I
n=5 exp(2 pi i 29/n) ~ 0.309016994374947 - 0.951056516295154*I
n=6 exp(2 pi i 29/n) ~ 0.500000000000000 - 0.866025403784439*I
n=7 exp(2 pi i 29/n) ~ 0.623489801858732 + 0.781831482468031*I
n=8 exp(2 pi i 29/n) ~ -0.707106781186547 - 0.707106781186547*I
n=9 exp(2 pi i 29/n) ~ 0.173648177666929 + 0.984807753012208*I

n=1 exp(2 pi i 30/n) ~ 1.00000000000000
n=2 exp(2 pi i 30/n) ~ 1.00000000000000
n=3 exp(2 pi i 30/n) ~ 1.00000000000000
n=4 exp(2 pi i 30/n) ~ -1.00000000000000
n=5 exp(2 pi i 30/n) ~ 1.00000000000000
n=6 exp(2 pi i 30/n) ~ 1.00000000000000
n=7 exp(2 pi i 30/n) ~ -0.222520933956313 + 0.974927912181824*I
n=8 exp(2 pi i 30/n) ~ -1.00000000000000*I
n=9 exp(2 pi i 30/n) ~ -0.500000000000000 + 0.866025403784439*I


We can write then the sum for $f(K)$ "numerically" $$f(K) = \sum_{1\le n\le 6} s^n\; \exp\left( 2\pi i\frac {b(K,n)}n\right) + \underbrace{\sum_{7\le n} s^n\; \exp\left( 2\pi i\frac {b(K,n)}n\right)}_{\text{Noise of order } s^7}\ , \ 0\le b(K,n)< n\ .$$

We can then define "clusters" by ignoring the "noise" starting with some given level, say level $7$ as above first. Then we have to consider all sums of the shape $$\sum_{1\le n\le 6} s^n\; \exp\left( 2\pi i\frac {t(n)}n\right)\ , \ 0\le t(n)< n\ .$$ There are $60$ such possible sums, where $60$ is structurally obtained as the l.c.m of $1,2,3,4,5,6$.

(For $K=60$, the above sage plot delivers $1,1,1,1,1,1,\dots$, compared to $1,1,1,-1,1,1,\dots$ for $K=30$.)

If we want to zoom in, then the sequence of corresponding l.c.m. values is

sage: L = list( set( [ lcm( [1..N] ) for N in [6..20] ] ) ); L.sort(); L
[60, 420, 840, 2520, 27720, 360360, 720720, 12252240, 232792560]


This controls the "zooming in strategy" and the refined cluster formation.