# Lines in image; are they significant to prime numbers if so how?

Amateur math question. I was playing around generating some 2D images, and wondered what it would look like if placed $P_{i}$ dots on a circle with diameter of $i$ for increasing values of $i$, where $P_{i}$ is the $(i + 1)$-th prime - so $P_{0}$ is 1. One interesting thing about the image is that there appear to be contours emanating from the center of the image. In particular there appear to be 3 distinguishable axes running though the center of the image. One top to bottom, the other two at about 30 degrees to the horizontal. I can explain the one running top to bottom easily, and also the general left to right symmetry. But I can't explain the other two. Why are they there?

Note the first image has had some pre-processing and a threshold to show the contours more clearly.

Note code used to generate points is like:

primes = [];
get_prime( primes, radius + 1 );
for( i = 0; i <= radius; i++ )
prime = primes[i];

for( j = 1; j <= prime; j++ )
y = i * cos( 2 * M_PI * ( j /prime ) );
x = i * sin( 2 * M_PI * ( j/prime ) );
printf( "%5f\t%5f\n", x, y );
end;
end;


Appendix 1: Original image, and one with 0 <= i < = 1000:

Appendix 2: I used PHP script to generate the dots, then gnuplot to generate image, and then GIMP for further processing. See http://pastebin.com/0Hfb6Kdq for the simple PHP and gnuplot code.

-
Cool question! Pedantic remark: 1 is not considered prime. A prime number is a positive number with exactly two positive divisors. However, this does not change the picture in an essential way, and it does not explain any of the patterns. Therefore: feel free to disregard the comment. –  jmc Feb 17 at 15:30
What language is the code in? Which program do you use to convert the points to an image? Would you mind adding/uploading a plot with a higher radius? Say 200, or maybe 1000. It would be very interesting to see if the patterns continue, or if others emerge. –  jmc Feb 17 at 15:37
How is the image oriented? And what is the explanation you know for the one line? (I assume it is you always have p/p = 1 and never 0 but something close to it as 1/p and (p-1)/p.) And continuing on this you would find other expanations. You never except for p=3, have j/p = 1/3 but you will find something close to it/approaching it for j= (p-1)/3 and j = (p+1)/3 depending on which is an integer. –  quid Feb 17 at 15:41
It looks like the points are too dense to detect patterns after the first concentric circles. Maybe you need to apply more image processing or correct the point sizes or the radii. –  Federico Poloni Feb 17 at 15:42
I really want to play that record. –  Ramsey Feb 19 at 5:53

The vertical line going up comes from when $j=prime$, so $x=0$, $y=i$. The vertical line going down comes from the fact that $prime/2$ is always fairly far ($1/2$) away from an integer, so $x=0$, $y=-i$, is white for $i$ sufficiently small.

There are also repeating patterns that occur nearby and approximately parallel to the axis. These correspond to formulas like $j=prime/2+1/2$, $j=primes/2+1$, etc.

The other axes are explained in a similar way. They correspond to $prime/6$, $prime/3$, $2prime/3$, $5prime/6$, which are always $1/3$ away from an integer. $1/3<1/2$ so this is a less powerful pattern that lasts a shorter amount of time. Also, you see an oscillation based on which integer is closer, which depends on whether $p\equiv 1$ or $p \equiv 2$ modulo $3$.

If you shrunk the radius of the dots, then more primes would appear, and I believe you would start to see a more distinct pattern on the horizontal axis corresponding to $prime/4$. As the dots get smaller more and more patterns would appear. It might be interesting to make the radius of the dots vary proportionally to $i/prime$ so they always cover the same proportion of the circle.

-
This might be tweaked into a graphical illustration of prime number races mod n. –  The Masked Avenger Feb 17 at 18:25
Hi @WillSawin. I want to accept this answer but your argument is not completely clear to me. Proof omitted, it's this?: For any prime number $P_{i}$, and some other +ve number d < $P_{i}$, there exists another number M < $P_{i}$ s.t. $P_{i}$/M = d + r where r element of $\pm{1/d,2/d,...,(d-1)/d}$. So for example for $P_{i}$=23, and d=4 we have 23/8 = 4-1/8. This leads to, where at say $\pi/2$ rads for each prime number there is only a small set of possible offsets from that vector the point can lie on $\pm{-1/4,-2/4-3/4,1/4,2/4,3/4}$, which gives the impression of a contour. –  S.Pinkus Feb 18 at 4:55
@WillSawin, I think I get the general idea but small correction; $P_{i}$/6 is not always $\pm1/3$ + some integer. Ex. 11/6 = 1+5/6. –  S.Pinkus Feb 18 at 4:59
@SamPinkus: Good point. –  Will Sawin Feb 18 at 5:00
It is $\pm \frac{1}{6}$ after 3. –  Mayank Pandey May 13 at 5:52