Early this year a software engineer, Shaun Gilchrist, reached out to me after reading a blog post of mine from many years ago, about my informal search for hidden patterns in the prime numbers.

The Ulam Spiral revealed non-random patterns, but they didn’t quite match up. Both Shaun and I had long felt there was a better way to wrap the primes that would reveal a deeper structure.

Shaun explained that he had developed a new algorithm (he calls it “Parallax Compression” or, “Daena,” named after his wife) for wrapping the primes on a plane, and visualizing their distribution, inspired by the Ulam Spiral. Shaun’s algorithm revealed an interesting glyph-like, fractal pattern in the distribution of primes, that to our knowledge, had not been seen before.

Try it:

Here is an easy to use interactive HTML version, for a quick hands-on demo of this pattern.

Code:

Shaun Gilchrist’s annotated Javascript version at Observable.

Here is a more robust Github version of the code in a Mathematica notebook if you want to explore it yourself (note: Thanks to Stephen Wolfram for taking a look at the Mathematica code and advising us in January, when we were wondering whether this might break crypto and needed advice; the answer is no, it doesn’t break crypto, but Mathematica is pretty great!).

And here is the code for prime-draw – a version in Perl by Simon Hardy-Francis.

Discussion:

We have set up a Telegram group for sharing images and insights about this. Lots of good things in there.

After his initial discovery of the Daena pattern, Shaun searched the Web for anyone else who was thinking this way and that led him to my blog post, and to me.

When one looks at a visualization of this pattern, it appears reminiscent of runes, Mayan glyphs, Amazonian tribal imagery, tapestries, and hieroglyphics. If you look at it for a moment or two you will see there are several levels of nested geometric shapes within it that appear to have a kind of fractal symmetry. And interestingly, these patterns recur in a self-similar way at different levels of scale – it’s a fractal.

A cell is colored black if there is at least 1 prime number within it, and red if there are no primes within it.

Here, the width of a cell, n, is 100, so each cell represents 100 integers in the sequence, and the pattern holds for 100 rows.

Initially we found that for even values of n this pattern converges on a known numerical sequence,OEIS A054521 — known as the GCD sequence.

For example, If n = 50, then each cell represents 50 integers, and the pattern holds for 50 rows. If n = 200 then each cell represents 200 integers, and pattern holds for 200 rows.

Here is an animation (Thanks to Ian Rust) that shows the pattern approaching the GCD sequence pattern, as the values of n increase.

However, some readers noted today in the thread on Hacker News that GCD doesn’t hold for all values of n.

For example, for odd values of n we see a different pattern that is also rather interesting. Here is n = 99:

Like the GCD pattern we see for even values of n, the odd valued n pattern also recurs for different sized odd values of n. This means that this pattern is not simply the GCD sequence — there are variances that we don’t understand yet.

The Daena visualization also reveals sequences (that we call “runs”) of primes and non-primes along various axes that might be useful for predicting prime and non-prime regions.

Since this article was published, many people have contributed visualizations and observations about Daena to the Telegram group discussion. We, and others, have also found a few patterns within this pattern that can be used to find specific classes of numbers. But for the most part, as far as we can tell, the characteristics of this pattern are well-understood in number theory already, and so it probably is not a major advance in understanding. However, the way we are laying out the pattern is novel (in the pyramid) and yields new insights about the relationships within it, and these insights, which are not necessarily noticeable until you see it visually (even for a mathematician), may inform further research and understandings.

Here are some highlights of findings from the Telegram discussion.

Here is a rendering that colors the cells by the number of primes they contain, by Simon Hardy-Francis:

2048*1024 row renderings (click to zoom in) (credit: Simon Hardy-Francis):

This is zoomed in at the bottom of the 2048×1024 1024 row render…

And some “sightseeing” from various places in this image….

We were also alerted by a reader to a video from many years ago, for creating the exact same pattern, but using a different geometric approach…

Here the algorithmic rendering (left) is compared to the geometric rendering (right) — they appear to be exactly the same.

We also heard from an artist, Henry King, who years ago, made a sculpture with striking similarities, using a different algorithm, below:

“the square rendering is actually from the prime zeta function for z=2, using the inverse of the square of the primes only. If I had used the zeta function itself using the composites as well as the primes the pattern would have been exactly the same but with more height” (comment by Henry King)

To construct the square rendering you first make a triangular rendering (instead of the pyramid rendering of Daena), and then you put two triangles together to get the square:

And, a reader noted that Stephen Wolfram also found the square version of this in his book, A New Kind of Science.

Here are two 3D models showing some interesting higher level patterns – when you visualize the number of primes per cell. We still haven’t fully analyzed these. These models were made by Allan Costa and illustrate the same pattern, found using a faster algorithm that was found separately by Stephen Wolfram and Henry King (however this algorithm has certain limitations; see Telegram discussion for more):

And here it is in 240 lines

So now we know of 4 entirely different algorithms that arrive at the same pattern.

It is also instructive to view the pattern in the inverse, so that instead of black cells indicating prime and colored cells indicating non-prime, black cells are non-prime and colored cells are prime. This helps the eye see different types of structure. Here is a side-by side view. On the left is the previous visualization (green = non-prime), and the right is the inverse (green = prime). In the view on the right you can see a regular triangular and circular motif in which you have a non-prime “hole” surrounded by primes. (This was rendered by playing around with this javascript code: http://www.gibney.de/parallax_primes )

It is also interesting to experiment with other ways of wrapping this pattern — for example, to a rectangular spiral instead of a triangle, (we haven’t yet tried other polygons, but that’s coming). (Image: by Simon Hardy-Francis):

In the Telegram group there have been some interesting findings about properties of the pattern, where we heard from several researchers, including Andrew Fuchs, who explained that what we are doing is related to his core area of mathematics research on the differences in the reduced residue system modulo primorials (product of first N primes), explained here.

We’re not exactly sure what this all means yet — it might not mean much — it might just be a pretty visualization — but it’s interesting enough (to us at least) that we decided eventually to make this public so that others could help us explore it further, in case there is something more to this.

At the very least we think this is a way to visualize the Riemann Zeta function. As for more than that, let’s see what emerges. Are there connections between this and other research findings, such as this recent article we found on aperiodic order in the primes?

Perhaps the most interesting aspect of this is that many different approaches arrive at this pattern — because it’s a fundamental pattern of the number system. In fact, I would venture to suggest that any mathematically advanced civilization, anywhere in the universe, would find this pattern and be able to recognize it as well. If that is correct, then this might be a good pattern to look for in the Search for Extra-Terrestrial Intelligence, and perhaps a good pattern to send out as well — a kind of Cosmic Dial-Tone that says, “we’re here and we’re intelligent.

We hope you enjoy this, and if you make further progress on this, or find anything that may be connected, please let us know. (You can discuss it with us, and others who are interested, on this Telegram group).

Social tagging: algorithms