Hello! I wrote this simple prime number grid visualiser last night, just for fun. It is inspired by the "Show HN" post https://news.ycombinator.com/item?id=44888548 that I stumbled upon a few days ago.
My tool uses the Miller-Rabin primality test with prime bases drawn from https://oeis.org/A014233 to determine whether a number is prime. This allows it to handle numbers up to 3317044064679887385961980.
You actually sent me on a rabbit hole trying to visually look for patterns :D
But I guess the discretionality with which you can organize in rows and columns makes mine quite a pointless excercise :D
Thank you for making and sharing this! It's fun to quickly increment the column counter and spot repeating patterns over time — little spiral movements, big swinging lines.
Growing up I loved math's logic puzzle elements, but it got tough when presentation of the subject became more abstract in late high school and college. Visualization tools like this would have gone a long way toward making the concepts concrete and keeping me curious about the relationships behind the symbols.
I think another interesting feature would be if you could change the number base to 16 or some other base, I'm really curious if the pattern would change.
It's effectively a visualization of gcd(x,y), and has almost nothing to do with primes. Once you realize that, it's a lot easier to reason about a lot of the patterns, although it is still a pretty interesting visualization.
Your description here does not quite match your linked code, in that it is not that the N-th pack contains integers spaced out by N. Rather, packs on the N-th row contain integers spaced out by N. For example, the third pack does not contain "every third integer", but rather draws alternating integers just like the second pack, because it is on the second row. The second pack contains (first cell of the second row) contains {101, 103, 105, ..., 299} and the third pack (second cell of the second row) contains {102, 104, 106, ..., 300}.
Ok this nerd-sniped me pretty good, never seen this before and assumed it would be quickly connected to the Ulam spiral mentioned elsewhere in the the thread. That particular rabbit hole kinda bottoms out in polynomial residues and the very mysterious-sounding "Conjecture F" [0].
This parallax primes thing though led to the linked page [1] which has lots of background and other connections, including the most satisfying part, which turned out more geometric [2]
I've been messing with this and you can get a very detailed view of another highly self-similar structure by changing the packsize to 1, the cellsize to 2, and then adding packSize++; to the end of the drawRow function.
It looks the way it does because we like to see patterns even where there are none. E.g. you see a number 696969 and this seems more significant than 482649 for whatever reason
Of course the pressing question is, if this is the start field for a Conway game-of-life, do any interesting patterns evolve?
It would be fun to brute-force a few starting grid sizes and seeing how long the game continues. Games that last more than a few steps can be set aside for human evaluation.
Because if it turns out that some particular smallish grid or spiral of primes causes something interesting to happen in game-of-life, then you can imagine HN melting down!?
This happens because when columns = p (prime), numbers in each column share the same remainder mod p, creating visible diagonal patterns as multiples of p are eliminated from primality.
Not so much that cols is prime as that cols+1 or cols-1 has lots of factors - see for example 25 or 91 or 119. But it does seem like numbers adjacent to primes have a lot of factors.
When the col is seven, there are a lot of diagonals going from top right to bottom left. When col is five, from top left to bottom right. Are runs of consecutive sexy primes also this frequent for larger numbers, or does that pattern break down at some point?
Almost all of these patterns that you see don't really come from primes. If you display numbers not divisible by first 100 natural numbers you get pretty much the same picture.
I did recently also a tool for prime numbers visualization:
https://ilmenit.github.io/prime-fold/
It's not only for visualization but also discovering of mathematical functions that generate or embed prime numbers using evolutionary algorithms and fitness functions. It has two modes:
PrimeFold Mode (2D Embedding): Enter or evolve two functions, f_x(n) and f_y(n), to map numbers to 2D points. Primes and composites are visualized differently. This mode helps you discover spatial patterns and structures unique to primes. Example: f_x(n) = n, f_y(n) = n^2 or simply n, n^2.
PrimeGen Mode (1D Generation): Enter or evolve a single function, f(n), to generate numbers. The app visualizes which outputs are prime and how many unique primes are produced. Example: f(n) = 2*n + 1.
I'd love this but in SDL+GL allowing to scale up and down an image.
Or better, a command to write an XBM/XPM image and then I'd convert it to any format I like.
Fun to see that prime numbers of columns causes stripy patterns, and some stripe to the left and some stripe to the right. Probably some deep number theoretic reason for that.
My intuition was that there were even fewer primes and there was a greater rate of decrease as the numbers got bigger – but it looks like there are so many! Even at [1, 10,000, 10,000] it seems pretty dense near the bottom, though perhaps less dense.
Here's a weird relationship between consecutive primes that I discovered while bored trying some python...
Take the last digit (in base 10) of consecutive primes. Now ignore 2 and 5 as .. well they only occur once, and look at the mapping between 1->3, 1->5, 1->7, 1->9 ... 3->1 etc etc..
You would think that they would pretty much all be equal, I mean primes are "random" right?
WRONG!
There are statistically significant differences in those edges, and no-one knows why.
[+] [-] susam|6 months ago|reply
My tool uses the Miller-Rabin primality test with prime bases drawn from https://oeis.org/A014233 to determine whether a number is prime. This allows it to handle numbers up to 3317044064679887385961980.
For example, https://susam.net/primegrid.html#3317044064679887385961781-2... shows the upper limit of the numbers this tool can check. The three circles displayed there represent the following prime numbers:
I hope this is fun for you too![+] [-] Tepix|6 months ago|reply
Would we see new patterns emerge if the number of columns increases per row by X (X being constant or perhaps prime numbers ;-) )?
[+] [-] camillomiller|6 months ago|reply
You actually sent me on a rabbit hole trying to visually look for patterns :D But I guess the discretionality with which you can organize in rows and columns makes mine quite a pointless excercise :D
[+] [-] reb|6 months ago|reply
Growing up I loved math's logic puzzle elements, but it got tough when presentation of the subject became more abstract in late high school and college. Visualization tools like this would have gone a long way toward making the concepts concrete and keeping me curious about the relationships behind the symbols.
[+] [-] davedx|6 months ago|reply
[+] [-] mg|6 months ago|reply
You look at integers in "packs" of 100. If a pack contains a prime number, you color it black, otherwise you color it red.
The first pack contains 100 consecutive integers. The second every second integer. The third every third integer and so on.
Every pack starts where the last one stopped.
On the first row, you draw 1 pack, on the second 2, on the third 3 and so on:
https://www.gibney.org/parallax_primes
It looks like hieroglyphs from another universe.
I'm still not sure why it looks the way it looks.
If you want to compare it to a random distribution, you can change this line:
To this: Very different. I wonder where the symmetry and all the other properties of the pattern come from when using primes.[+] [-] davidnc|6 months ago|reply
It's effectively a visualization of gcd(x,y), and has almost nothing to do with primes. Once you realize that, it's a lot easier to reason about a lot of the patterns, although it is still a pretty interesting visualization.
[+] [-] Chinjut|6 months ago|reply
With this in mind, the seeming patterns of the figure you link to are explained by https://news.ycombinator.com/item?id=17106193
[+] [-] photonthug|6 months ago|reply
This parallax primes thing though led to the linked page [1] which has lots of background and other connections, including the most satisfying part, which turned out more geometric [2]
[0] https://en.wikipedia.org/wiki/Ulam_spiral#Explanation [1] https://www.novaspivack.com/science/we-have-discovered-a-new... [2] https://www.cut-the-knot.org/Curriculum/Arithmetic/PrimesFro...
[+] [-] segfaultgolf|6 months ago|reply
Okay so if you iterate only even or odd packings the pattern actually converges, which is crazy!
[+] [-] unknown|6 months ago|reply
[deleted]
[+] [-] xerox13ster|6 months ago|reply
[+] [-] shaunxcode|6 months ago|reply
[+] [-] BobbyTables2|6 months ago|reply
[+] [-] unknown|6 months ago|reply
[deleted]
[+] [-] pinoy420|6 months ago|reply
[+] [-] willvarfar|6 months ago|reply
Of course the pressing question is, if this is the start field for a Conway game-of-life, do any interesting patterns evolve?
It would be fun to brute-force a few starting grid sizes and seeing how long the game continues. Games that last more than a few steps can be set aside for human evaluation.
Because if it turns out that some particular smallish grid or spiral of primes causes something interesting to happen in game-of-life, then you can imagine HN melting down!?
[+] [-] madcaptenor|6 months ago|reply
[+] [-] vincnetas|6 months ago|reply
[+] [-] BrainBacon|6 months ago|reply
https://embed.plnkr.co/mdZX6C/
It isn't just doing primes though, instead the size of the dot generated is dependent on the number of even divisors for the number at that position.
[+] [-] throw310822|6 months ago|reply
[+] [-] rmrfchik|6 months ago|reply
[+] [-] ethan_smith|6 months ago|reply
[+] [-] madcaptenor|6 months ago|reply
[+] [-] spongebobism|6 months ago|reply
[+] [-] amne|6 months ago|reply
And if you go up or down by one (119 or 121) they appear to "rotate" left or right.
Very cool viz tool.
[+] [-] scotty79|6 months ago|reply
[+] [-] ilmenit|6 months ago|reply
[+] [-] AmazingTurtle|6 months ago|reply
zoom out, then play around with cols +/-1 and observe the pattern change. I observe the pattern from -7 to +5; same on #1-200-420
[+] [-] haar|6 months ago|reply
[+] [-] anthk|6 months ago|reply
[+] [-] vintermann|6 months ago|reply
[+] [-] dfee|6 months ago|reply
Apparently the average gap between primes is `log(n)`: https://en.wikipedia.org/wiki/Prime_number_theorem
[+] [-] ragmondo|6 months ago|reply
Take the last digit (in base 10) of consecutive primes. Now ignore 2 and 5 as .. well they only occur once, and look at the mapping between 1->3, 1->5, 1->7, 1->9 ... 3->1 etc etc..
You would think that they would pretty much all be equal, I mean primes are "random" right?
WRONG!
There are statistically significant differences in those edges, and no-one knows why.
[+] [-] martinclayton|6 months ago|reply
Try these shapes: 100x113, then 100x114, then 100x115, the "patterns" swing from slant down, to vertical, to slant up.
I'd love this (even more) with some animation and colo(u)r options.
[+] [-] themafia|6 months ago|reply
[+] [-] dirkc|6 months ago|reply
1. Make the grid render as a square when rows == columns
2. Default to the largest number of rows and columns that would still avoid page scrolling
[+] [-] kitd|6 months ago|reply
[+] [-] physix|6 months ago|reply
[+] [-] mickeyp|6 months ago|reply
[+] [-] susam|6 months ago|reply
[+] [-] nyc111|6 months ago|reply
[+] [-] unknown|6 months ago|reply
[deleted]
[+] [-] cuber_messenger|6 months ago|reply