# Primes that are the sum of three squares

This is in some sense an extension of the earlier MO question, "Gaussian prime spirals." Gaussian primes in the complex plane, $a+b i$, require $a^2 +b^2$ prime off the axes. The generalization to quaternions leads to Hurwitz primes $a + b i + c j + d k$, which require $a^2 + b^2 + c^2 + d^2$ prime (here I am ignoring the Hurwitz integers whose components are in $\mathbb{Z}+\frac{1}{2}$). So this suggests exploring points in $\mathbb{Z}^3$ with $a^2+b^2+c^2$ prime. (I realize this ignores the nice algebraic properties of complex numbers and quaternions.)

The Gaussian prime spirals were created by walking along a lattice direction and turning left at Gaussian primes. The generalization is to start at a point $p \in \mathbb{Z}^3$, walk along a lattice direction until a point $(a,b,c)$ is hit with $a^2 +b^2 + c^2$ prime, and then turn. It makes sense to iterate through the six lattice directions, $(+x,+y,+z,-x,-y,-z)$, in that order. The result seems again to be a closed cycle. Here is one example, with $p=(30,40,10)$ (marked in red), which cycles after encountering 739 "primes" (marked in yellow):

It appears that whether or not every Gaussian prime spiral cycles runs up against long-unsolved problems. What is the situation with these 3D "prime" spirals? Is there much known about the density and distribution of primes that are are sum of three squares? Are there theorems or conjectures that would either imply all spirals are closed, or the opposite, that there should exist infinite unclosed spirals?

-
Guass - there's always an evil twin. – Paul Reynolds Mar 22 '12 at 20:48
One sub-question is, "Are there infinitely many primes of the form a^2+k?", which is asked for all k that are the sum of two squares. As far as I know, this is not known for any nonzero k. – Will Sawin Mar 22 '12 at 21:11
In an answer (which I have deleted), IURIE asked what software was used, and the reply was, "Mathematica, with some touchups in Photoshop." – S. Carnahan Oct 26 '12 at 13:26

From one direction, everything is known about the resulting primes. All primes $$p \equiv 1,3,5 \pmod 8$$ are the sum of three squares, so is $p=2,$ while no numbers $$n \equiv 7 \pmod 8$$ are ever the sum of three squares.
However, your construction involves fixing two coordinates, say $x=a, y=b,$ then varying $z$ in either direction and hoping to find another prime. This is still unsure, for example if $a^2 + b^2 = 1,$ nobody knows for sure that there are infinitely many primes of the form $1 + z^2.$
For what it may be worth, Siegel's theorem gives an exact answer for the number of representations of a given number $n = x^2 + y^2 + z^2$ because the form is alone in its genus. I also gave a version in the style of Guass at Is there a simple way to compute the number of ways to write a positive integer as the sum of three squares? Meanwhile, following Linnik, the main result in Duke and Schulze-Pillot (1990) is that the lattice points on the sphere are asymptotically equidistributed.
@Joseph, I think you may have a chance with this variant: cyclically fix $x,y,z.$ Suppose $x$ is the one fixed this turn, with $x=a.$ we currently have a prime at $(a,b,c).$ Now, vary $(y,z)$ with some restriction on either direction or modulus, if the latter $y^2 + z^2 > b^2 + c^2,$ demanding a new prime. Possibly some restrictions on direction. The difference is that it may be possible to show that there really are infinitely many primes $1 + y^2 + z^2$ for example. I will see what I can find on that...if not certain in this dimension, there are infinitely many primes $1 + x^2 + y^2 + z^2.$ – Will Jagy Mar 23 '12 at 23:36