*tl;dr*: Code and Visualization of the prime “gaps of gaps” table

The prime number sequence fascinates me. I am not sure why but exposing properties in it is exciting. Even if they are mundane and “obvious to everyone else”, the fact that I can answer questions visually, sometimes thrills me.

Sometimes I already know the answer but want a picture.

Anyway, in my life-pursuit of exploratory nerd-investigation, I asked myself, “What are the gaps of the primes, followed by the gaps of those gaps, etc etc?” So I wrote up a handy bit of code, but noticed a curious property.

The code just considers gaps between successive primes, as absolute differences:

1 |
<span class="nb">push</span> <span class="nv">@difference</span><span class="p">,</span> abs($sequence[$n + 1] - $sequence[$n]) |

For each sequence, starting with the primes themselves, we compute the gaps between elements and use those gaps as the next sequence. Mundane, yes?

**But the patterns! Cool!**

I tediously but anxiously drew (and “bucket-filled”) the polygons for my little table from a black iTerm screen-shot in the GIMP. (I apologize but there is no magic here. I manually applied the lines and colors.)

The “flowing triangles” pattern should continue. But it appears, at the far right, that the pattern is beginning to break up, or as I suspect, evolve into another set of evolving patterns. I’ll have to plot a bigger table.

I realize that I am illustrating an artifact, not some sort of revolution in number theory. I am just a curious cat. Maybe I’ll submit it to the Prime Curios site. But maybe it’s another one of those “obvious to everyone but me” things. ;-)

–gene

**Update**: My friend from Montréal, Quebec, Luc St Louis, saw my curious chart and rendered the graph that I had only imagined. His visualization shows white for zero and “more black” as the gap value increases (in the image at left), a colored version, of mostly greens, in “bands” or rows of gaps greater than two.

Colored rows of Prime gaps-of-gaps [4.3MB PDF]

So this answers my main questions, “Does the zero triangle pattern persist?” and “Does the chart become “taken over with the growing complexity?”

1. Yes the zero triangle pattern does persist and in fact makes up the vast majority of the chart.

2. No the complex patterns to do not “take over” and break up the chart into increasingly less patterned fragments. In fact, the “complex patterns” are obviously restricted to the top few bands of gaps. This makes sense because the gaps grow smaller, the farther down the graph you go, until it’s just 2s and 0s.