Gaussian prime spirals

Stan Wagon, coauthor of the award-winning article "A Stroll through the Gaussian Primes," became intrigued, and sent me these two stunning images. The first is a different rendering of the 2,956-cycle I posted earlier:
 Polygon Cycle
The second is a Rorschach-like cycle of 316,268 primes he found:
 Rorschach Cycle
(seed: $232+277 i$). [Apologies for the loss of resolution converting for this forum.]

Soon there will be a Mathematica Demonstration Project on this topic; it currently awaits approval.

Update. The Mathematica Demo is available at this link:
            Mma Demo
Using a modification of this code, Stan has found a cycle of length 3,900,404. Seed: $107 + 992 i$.


(16Feb13): Stan Wagon worked with Walter Stromquist, the editor of Mathematics Magazine, on the cover of the February 2013 issue, which displays the spiral immediately above:
                       MathMagCover


Expanding slightly on Greg Martin's answer, the symmetry applies across the imaginary axis as well as the real axis, so the only way a path can avoid closing up is if it crosses at most one axis at most once (and if it does cross an axis, the path -- if extended in the backward as well as forward direction -- will be mirror symmetric with respect to the axis it crosses). Note that within a quadrant the horizontal (respectively vertical) steps are alternately toward and away from the imaginary (respectively real) axis.

Intuitively the steps, on average, get larger the further you are from the axes. So if you're in the first quadrant and take a step to the right and then a step up, you expect your next step, to the left, to be somewhat larger than your previous step to the right (and similarly with the next step down, assuming you're still in the first quadrant). So in a sense the axes are exerting kind of a gravitational tug on sort of a random walk. Of course, nothing of the sort is literally going on. Still, it seems hard to imagine the stars (I mean Gaussian primes) aligning to keep a random walk going in perpetuity.

It seems more likely one might encounter closed paths that don't have any nice symmetry, such as $$(a,b) \rightarrow (a+4,b) \rightarrow (a+4,b+8) \rightarrow (a-2,b+8) \rightarrow$$ $$(a-2,b+4) \rightarrow (a+2,b+4) \rightarrow (a+2,b+6) \rightarrow (a,b+6) \rightarrow (a,b)$$
          Barry Cycle
(Sorry, if someone could replace that with a picture, that would be helpful.) As "unknown" pointed out, there are certainly closed square paths that stay in the first quadrant. There are also rectangles, such as the $2\times4$ rectangle with $8+13i$ for its lower left hand corner and the $2\times6$ one starting at $14+19i$. (I spotted these in a picture of Gaussian primes of norm less than 1000 in the paper "A Stroll Through the Gaussian Primes" by Gethner, Wagon, and Wick.) One might expect a souped-up (supped-up?) $k$-tuple conjecture to predict the existence of any closed-path pattern that isn't forbidden by the usual suspects. (Part of the souping up, though, is that not only are there primes at the specified corners, but everything else along the edges is composite.)

All in all, a nice problem -- and the spirals, reminiscient of Celtic knots, are really lovely!


Just for your amusement, here is a spiral of length 2,956 primes that crosses just one axis, and hits no prime on that axis. I encountered it twice, once in a horizontal orientation (seed: $12+28 i$) and once in a vertical orientation (seed: $43 + 55 i$). That it should occur twice is a consequence of the symmetry of the conditions that render a Gaussian integer prime.
Horiz Spiral
            alt text