How to force prime numbers into a line?
Solution 1:
There are 2 behaviours going on here.
In your last picture, it's easy to see that all numbers lie on the 6 rays through the origin. Why? This is because there are $2\pi$ radians in a circle, and you are incrementing by $\pi/3$ radians each time (which is 1/6 of the circle). This is why you are getting distinct rays.
The other behaviour occurs when you only look at primes. In the second picture (the one consisting of only primes), there is space for 60 rays (since you are incrementing by $\pi/30$ radians, which is 1/60th of a circle each time). So the new question is, why do only 16 rays appear?
The answer is that $\varphi(60) = 16$, meaning that there are only 16 residue classes for primes to fit in mod 60. Stated differently there are only 16 solutions to $p \equiv x \pmod {60}$ in $x$, where $p$ ranges across all the primes. So there are 16 distinguished rays containing primes.
Similarly, there are two distinguished rays in the last picture, which is why you can only see primes on 2 of the rays.
You might be interested to know that the property of being a ray containing primes will not be origin-symmetric, but mirror-symmetric over the horizontal line $y = 0$. This has to do with how $\gcd(x,n) = \gcd(n-x,n)$, and the order in which you are plotting these rays.
To answer your final question, you can plot all primes (except 2) on the same line by using $\pi$ as your increment, or by using $2\pi$ as your increment. The first is equivalent to saying that all primes except $2$ are odd. The second actually puts all numbers on a single line.
Solution 2:
Loosely, what's going on here is that you're discovering the notion of residue class. If you look carefully, you'll discover that all of the points on your original spiral actually lie on a finite set of 60 lines through the origin: one line for every $6^\circ$ or for every $\frac\pi{30}$ radians. This means that what line a number is on is determined by its remainder when divided by $60$: $19$ is on the same line as $79, 139, 199, \ldots$ For convenience's sake, we'll label these lines by the smallest positive number on them (this is called the residue class of all the numbers on the line, $\bmod 60$). Now, consider:
- Every even number (greater than 2) remains even after adding 60 to it, so none of your 'even' lines hold more than possibly one prime. This means that no primes (other than just one transient one that we can ignore) can be on the lines with labels $0, 2, 4, 6, 8, 10, \ldots, 56, 58$.
- Every multiple of 3 (greater than 3) remains a multiple of 3 after adding 30 to it, so none of the multiple-of-three lines hold more than possibly one prime; so no primes (again, except for that one ignorable exception) can be on the lines with labels $3, 6, 9, \ldots, 54, 57$.
- And the same thing happens with multiples of 5, so we get no primes on the lines with labels $5, 10, 15, \ldots, 50, 55$ either.
Once you take all these into account, you'll find that the only lines that can possibly have infinitely many primes on them are the lines labeled $1, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 49, 53, 59$ - these are the sixteen lines you find in your ray pattern.
As for whether you can get all of the primes onto a single line this way, the answer is no (unless you use such a large angle increment for your spiral that all your points lie on either the x or y axes), but the reasoning is a bit complex: it turns out that for any number $n$, there are infinitely many primes that are of the form $k\times n+1$ (or primes that are on the line labeled '$1$'), and there are infinitely many primes of the form $k\times n-1$ (or primes on the line labeled '$n-1$'). This means that you'll get at least a couple of lines for any angular increment, and in fact you're going to get more than that - the number of lines you should expect to have primes on them is (essentially) equal to Euler's Totient function $\phi(n)$, which counts the numbers less than $n$ that are relatively prime to $n$ (i.e., have no common factors with $n$), and it's known that $\phi(n)$ grows as $n$ does, in the sense that for any given $K$ there are only finitely many values of $n$ where $\phi(n)$ is less than $K$.
But how do you know that all of these lines will have primes on them? (It should be clear that the primes can only show up on these lines, by a variant of the argument I gave above). Well, that's the content of Dirichlet's Theorem, which basically says that for any arithmetic progression, as long as you know that values on the progression are relatively prime, there will always be infinitely many primes on that progression. Here, the 'spokes' in your renderings represent these progressions.