An Interesting Pattern in the Prime Numbers: Parallax Compression
novaspivack.com
novaspivack.com
More specifically, it’s a drawing of OEIS A054521 (black if gcd(row, col) == 1, red otherwise), not of the parallax compressed primes. The two drawings do not match as claimed. The first place where they differ is row 9, column 1, which is drawn as black even though none of 217, 226, 235, 244, 253, 262 are prime.
It’s clear that gcd(row, col) == 1 is a necessary condition for there to be any primes in that cell (which consists of the numbers col + 3row² − 3row, col + 3row² − 2row, col + 3row² − row, col + 3row², col + 3row² + row, col + 3row² + 2row), but it’s not sufficient. There’s no way it could be sufficient, because there are only constantly many (six) numbers tested in every cell, but the asymptotic density of the primes goes to 0 and the asymptotic density of A054521 goes to 6/π².
T = (n, k) => { return (GCD(n, k) == 1) ? 1 : 0; }
The given code doesn’t use primes, primesSet, or isPrime at all.
n = 14: fails on row 13, col 3
n = 20: fails on row 17, col 8
n = 30: fails on row 17, col 7
n = 38: fails on row 37, col 8
n = 44: fails on row 31, col 2
n = 50: fails on row 43, col 13
…
Https://GitHub.com/shaunxcode/a-pattern-in-the-primes
He's not claiming it holds for _all_ n, just for _many_ n.
[1095, 1108, 1121, 1134, 1147, 1160, 1173, 1186, 1199, 1212, 1225, 1238, 1251, 1264]
none of which are prime. cellToTerms(13, 14, binomialCoEfficient2, 3) in the observable gives the same list (though no such calls are made when generating the picture).
row 1, col 1: [1, 2, 3, …, 75], has primes
row 2, col 1: [76, 78, 80, …, 224], no primes
row 2, col 2: [77, 79, 81, …, 225], has primes
Then their claim that this pattern holds isn't even true; as pointed out elsewhere, and is obvious when you write out the sequence items explicitly in terms of their coordinates, any gcd!=1 cell will be red. But a gcd=1 cell need not be black, for many n.
Thanks to comments from readers we have found that the pattern does not exactly match the GCD triangle for some values of the number of cells and rows.
This possibly makes it a more interesting finding. But it also means we can’t use GCD to render it quickly for all values.
In the code on Observable we were using GCD as a shortcut to render it because it saved time compared the earlier approach. However readers correctly pointed out that the rendering was not always correct using GCD.
Now that we know GCD doesn’t apply to all values of n, we are reverting to the original code, which generates the correct renderings for all values - but is slower - and there will be an update on Observable soon.
Meanwhile - to see the original code at work, and test it out for any value yourself, here is the Mathematica notebook code:
Https://GitHub.com/shaunxcode/a-pattern-in-the-primes
The Observable JavaScript code is being updated soon to account for this.
Join the discussion in the Telegram group as well - details below.
See the Mathematica notebook, which correctly renders it for any value.
Https://GitHub.com/shaunxcode/a-pattern-in-the-primes
However, for odd values of n, it does not match GCD. So it's not simply a drawing of the GCD pattern.
And when n is even, there's also a heuristic argument that there are only finitely many counterexamples; i.e. you should expect to find the pattern from your process exactly match that from just the gcd, beyond a few counterexamples: https://news.ycombinator.com/item?id=17106648
Meaning that the chance of finding a prime in these sequences of N numbers approaches one, after eliminating the cases that make primes impossible (n odd and r=2 mod 4, gcd(r,c) > 1).
Is there any deeper meaning to that, or is it simply that the probability of finding a prime in any sequence of n numbers approaches one as n increases, excluding sequences in which primes are impossible?
For the benefit of others who may be similarly mystified, here's an elaboration. First, in vague terms, there are two things going on here:
1. If you colour a triangular grid according to the gcd of the coordinates, then you get a pretty picture (this is itself interesting IMO), and
2. If you colour a triangular grid according to a particular function involving prime numbers, then the picture will often (NOT ALWAYS!), and in many places (NOT EVERYWHERE!) resemble the pretty picture of (1) above.
Less vaguely, here are precise definitions:
--------------------
Draw a triangle (triangular grid) where row R (for R = 1, 2, 3, ...) has R cells or "columns" (C = 1, 2, 3, ..., R). Suppose we colour the cell at co-ordinates (R, C) to be
- black, if gcd(R, C) = 1 (that is, R and C have no common factors except of course 1), and
- red, if gcd(R, C) > 1 (that is, there is some number > 1 that divides both R and C).
(This is the sequence http://oeis.org/A054521.) Then, the triangle has a pretty and regular pattern, as shown in the post. This is not too hard to prove, but is IMO itself interesting, and a nice discovery for someone playing with numbers and visualizations. So congratulations to the authors for coming up with this.
Call this Drawing 1.
--------------------
Next, fix an even integer N, and for each pair of coordinates (R, C) with 1 ≤ C ≤ R, let S(R, C) be a particular set of N integers, to be defined precisely shortly. (Roughly, in row R, we take RN numbers and assign them to the C cells in a round-robin fashion.)
For example, for N = 10, the first 3 rows have 6 cells so 60 numbers, so in row 4, the numbers 61 to 100 are distributed as follows:
S(4, 1) = {61, 65, 69, 73, 77, 81, 85, 89, 93, 97}
S(4, 2) = {62, 66, 70, 74, 78, 82, 86, 90, 94, 98}
S(4, 3) = {63, 67, 71, 75, 79, 83, 87, 91, 95, 99}
S(4, 4) = {64, 68, 72, 76, 80, 84, 88, 92, 96, 100}
In general, to define the elements of the set S(R, C), start with (R(R-1)N/2 + C), and increase by R each time, until there are N integers. In Python notation, S[(R, C)] = range(R*(R-1)*N/2 + C, R*(R+1)*N/2 + C, R)
Then, colour the cell with coordinates (R, C) with:- black, if any of the numbers in the set S(R, C) are prime, and - red, if none of the numbers in the set S(R, C) is prime.
Call this Drawing 2 (for a particular value of N).
--------------------
Now, note the following:
- when cell (R, C) in Drawing 1 is red, i.e. when gcd(R, C) > 1, then in Drawing 2, whatever the value of N, all the numbers in the set S(R, C) are divisible by that gcd, so none of them can be prime.
- when cell (R, C) in Drawing 1 is black, i.e. when gcd(R, C) = 1, then in Drawing 2, especially for larger values of N, you have a set of N integers that have no particularly forced reason to be composite, so it's rather likely that at least one of them may be a prime. (This can be made somewhat more precise using standard number-theory heuristics like the Cramer random model, but nothing that reaches the level of proof.)
So Drawing 2, which depends on the primes, is likely to resemble Drawing 1 (red in all the places where Drawing 1 has red), but with occasional additional red dots (where Drawing 1 has black) that break the nice, regular pattern. Some of these counterexamples are listed in this comment: https://news.ycombinator.com/item?id=17104624
(I haven't worked out the details but I think we can prove things like that there will be infinitely many of these counterexamples if we extend the triangle far enough, but also that the ratio (asymptotic density) of these counterexamples will be small. So "the pattern will kind of hold" is about all we can say.)
--------------------
What does all this tell us about primes? Unfortunately, not much it appears. To the extent that there is a nice pattern in the picture, it comes from the regular properties of the gcd function. And if one considers the deviations from the regular pattern as what's interesting, then it tells us things only in a diffuse way: whereas with Ulam's spiral one sees individual primes, here what one sees visually is cases where in a particular set of N numbers none of them happened to be prime.
Still, the pictures are pretty to look at, and that counts for something. :-)
The drawing has been updated on the blog post cited above; there was an error in the description of it, this has been clarified and the code has been updated as well
Join the Telegram group to discuss: https://t.me/joinchat/G8AnchIna2q8yn1lGHirkA
Note that Even and Odd Values of N have a very different pattern.
For example try using the values 99 and 99, and then 100 and 100, in this HTML PREVIEW VERSION:
https://htmlpreview.github.io/?https://github.com/acmegeek/p...
CODE TO TRY:
Javascript https://beta.observablehq.com/@montyxcantsin/unwinding-the-u...
Mathematica https://github.com/shaunxcode/a-pattern-in-the-primes
Perl https://www.dropbox.com/s/z5tfub5geyuctex/prime-draw.pl?dl=0
EXPLANATION:
In short, actually there are some curious patterns in this, and they are not simply equivalent to OEIS A054521 (as we, and others, initially thought they were).
For even values of n, they seem to approach the OEIS A054521 sequence as n increases. But for odd values the pattern is different and OEIS A054521 doesn't describe it at all. More discussion of this on the Telegram group...
Looking at the layman letters that my institute gets on a regular basis, I can say, that this is unfortunately a recurring theme with amateur mathematicians: They fail to state their basic definitions and assumptions and seem all to eager to dive right into applications, be it computer graphics, cryptography or finance.
More to the point: This picture seems from a cursory inspection to plot T(k,n) with n=row, k=column from the top left. But why is this interesting?
[1] https://math.stackexchange.com/questions/2654984/identifying...
Don't forget: There's nothing bad about no-response - People are much more likely to respond on the web and email when you're wrong. ;)
There certainly could be something bad about no-response. As someone in academia who gets uninformed musings or crackpot theories from laypeople in his mailbox from time to time, no-response basically means “I know you are wrong, seriously wrong (and, in many crackpot cases, probably mentally ill), but I am not going to just waste my time trying to tell you that.”
(I'm particularly horrid at email.). So I wouldn't take it personally.
Maybe the majority of recipients won't act, or they'll even take offense, but if somebody in there chose to contact you because they look up to your position, you could easily find in a few years that you challenged somebody to get on the right track with one of those responses. Some people are on the fence and looking for a push.
Obviously it's up to you, but I think it's worth a shot.
“Searching for interesting tautologies” or “Hunting for patterns” are good descriptions of what mathematicians do.
Mathematicians do mathematics because they want to be sure that a) they caught a pattern and b) that it is interesting. That’s what’s being discussed here.
http://htmlpreview.github.io/?https://github.com/acmegeek/pr...
I changed it to render with circles vs squares, and have them stack nicely. Also, have the variables more isolated to test. Also, it counts how many primes are within a pack, and assigns the color proportionately. This is still a work in progress.
If you replace condition isPrime() with simpler checks: "is not divisible by 2" "is not divisible by 2 and 3" .. "... by 2, 3 and 5" .... "... by 2,3,5,7,13,17 and 23" ... you'll get more and more complex images but still symmetrical.
For me the whole thing is subtle hiding of messiness of primes into the strong, pretty, symmetrical shape which obscures the mess and just gets richer and more artistic due to that.
Experiment with the code provided by user no_gravity here: http://www.gibney.de/parallax_primes
By changing the contents of isPrime() function you can see how you get fooled into thinking there's order in primes by mixing messiness of primes into the order of number picking scheme.
It's interesting, that up to 4, it's a perfect pattern:
function isPrime(n) { return n%2 && n%3 && n%4; }
As soon as you get to 'Not divisible by 5' noise starts to appear: function isPrime(n) { return n%2 && n%3 && n%4 && n%5; }
This 'noise' closes some gaps between the pattern and makes it look like runes.Would any type of noise do this?
Here is how it looks like with some random noise added:
function isPrime(n) { return n%2 && n%3 && n%4 && (Math.random()>0.95); }
It is not as structured as the version based on primes.As of now, I'm not sure what to make of it. Maybe there is some other type of simple 'noise' that creates something as complex and logical as the primes. Maybe not.
Take the relation to the GCD triangle http://oeis.org/A054521
At GCD(n,k)!=1 all numbers are divisible by GCD(n,k) therefore contains no prime
At GCD(n,k)==1 we have https://en.wikipedia.org/wiki/Dirichlet%27s_theorem_on_arith... - so those series contain infinitely many primes - and seems like they actually contain at least one prime in all the pixels of the first N rows (but this should be explained/proved, if it is always true for any chosen N, or just happen to be true for the N-s tried by the OP)
So their picture is nice, and the gcd!=1 cells are all red, but the gcd=1 cells need not be black. For odd N this fails loads of times (always?), and for even N you quickly find failing cells when you start looking for it (see linked comment).
- take a line of integers, color them black if prime, red otherwise
- hexagonally arrange them in a spiral (similar to Ulam's spiral)
- cut the hexagon into six equilateral triangles
- overlap the triangles (rotate where necessary)
- if any pixels are black, color the whole thing black, if none are black, color it red
- interesting pattern arises
- interesting pattern already exists as per http://oeis.org/A054521
Edit: They may be packing more than 6 numbers into a pixel, looks like 75. Unsure how that would look visually, but you extend the above to use 75 or any other number. Unsure why 75 was chosen, maybe it's the only interesting one?
It also helps to understand my other comment about the explanation of the pattern and GCD equivalence...
./prime-triangle.py 74
is included as x_output_74.png. It's not fancy, but it could save you some time trying to figure out what the actual formulae are.https://gist.github.com/mortehu/ccca0bafc7a9caa26d6008379057...
Edit: Other than 2, 14, 20, 30, 38, 44, 50, and 74, the two patterns match perfectly for every even N up to at least 600.
Edit 2: Looks like this is related to Linnik's theorem: https://en.wikipedia.org/wiki/Linnik%27s_theorem
- The right edge of the triangle is always red (ie, no primes present), because it represents (row number) * (3* (row number)+[1..6])
- Prime numbered rows are always black (except the far right column). I can sort of feel why this is true but can't express it mathematically yet.
Cell i of row j contains n elements of an arithmetic progression, with common difference of j. If i and j have a GCD != 1, they are not coprime, so they share a factor p, as do all numbers in the sequence, so they cannot be prime
Otherwise it's very likely there's at least one prime
If j is prime every column i is coprime with it, so it's going to be black
Does this mean that we have a sort of bloom filter-esque test for primality? (ie, it will give you a guaranteed no in O(1) but you'll have to crunch numbers to get the yes?)
If so, are there implications for things that want to know "is it prime?" quickly? Crpytography comes to mind, for instance...
This catches most non-primes ;)
bool maybe_prime(x) { return x % 2 && x % 3 && x % 5 && x % 7; }
https://en.wikipedia.org/wiki/Primality_test#Probabilistic_t...
https://en.wikipedia.org/wiki/Primality_test#Fast_determinis...
So speed improvements are welcome for academic use. Although this doesn’t look like it’s a game changer.
How? Just run Fermat's little theorem on multiple values of "a" until you feel comfortable. [1]
Why a majority? There are certain exceptions such as the Carmichael numbers to which we need to use slower algorithms to verify the primality of.
Note that I'm assuming the number of calls to an algorithm is constant since it would be naive to discount the size of the number you're testing.
What are the implications of this result? Off the top of my head I can only think of one: the problem of deciding whether a number is prime or not is in the complexity class P (decidable in polynomial time). [2]
How does this affect cryptography? I would say not by that much.
Why? The "hardness" of some forms of cryptography (asymmetric) isn't from the ability to determine primality of a number. It's from the ability of determining the factors of a number. [3] That problem itself has greater implications for the field.
The question of whether it is possible to do so in polynomial time on a classical computer is actually an open question in CS right now.
Note the emphasis on classical! Amazingly, there exist a polynomial time algorithm to do so on a quantum computer called Shor's algorithm. [4]
[1] https://en.wikipedia.org/wiki/Fermat_primality_test
[2] https://en.wikipedia.org/wiki/AKS_primality_test
replace the source with the one I dropped here and hit Go: https://pastebin.com/aw9nRmeZ
It's actually fun to run the original first and then watch the colors overlay on top of it.
This shows the pattern again:https://imgur.com/qR4iGJb
Further fiddling ~shows~ highlights more patterns: https://imgur.com/a/Yjln2RX
Isn't it plotting a prime spiral, not GCD?
Obviously prime implies gcd=1, but the "kth" square isn't "k", because it's a spiral counting up from the center.
Maybe if you shifted everything to the left to line it up, but
This addresses the issues that were pointed out below for the most part.
In short, actually there are some curious patterns in this, and they are not simply equivalent to OEIS A054521 (as we, and others, initially thought they were).
For even values of n, they can be rendered by the GCD sequence, without the primality testing. But for odd values the pattern is different and GCD doesn't describe it.
The Mathematica code on Github lets you experiment with this.
There are some nice versions, and experiments in different ways of coloring or arranging the graph in the Telegram group as well.
Telegram group https://t.me/joinchat/G8AnchIna2q8yn1lGHirkA
Javascript code https://beta.observablehq.com/@montyxcantsin/unwinding-the-u...
Mathematica code: https://github.com/shaunxcode/a-pattern-in-the-primes
Counterexample: N=14, (R,C) = (13, 3)
Counterexample: N=20, (R,C) = (17, 8)
Counterexample: N=20, (R,C) = (19, 1)
Counterexample: N=30, (R,C) = (17, 7)
Counterexample: N=30, (R,C) = (19, 1)
Counterexample: N=38, (R,C) = (37, 8)
Counterexample: N=44, (R,C) = (31, 2)
Counterexample: N=44, (R,C) = (37, 2)
Counterexample: N=50, (R,C) = (43, 13)
Counterexample: N=74, (R,C) = (73, 43)
(For n=74, look at the last shown row in the post right now, for N=73, where there's a “stray” red dot: this dot wouldn't be present in the computed-from-gcd sequence.)There are very few counter-examples though (larger ones seem hard to find); you can see some reasons in my long comment here: https://news.ycombinator.com/item?id=17106193
Here's a rough heuristic calculation for how many counterexamples we should expect. Let's say gcd(R,C)=1, so that there should be no “special reason” to expect everything in the set to be composite. Then, as the set contains N numbers each of size roughly (NR^2/2), each is prime with “probability” 1/log(NR^2/2) — this is the Cramer heuristic — so the probability that all of them are composite is
(1 - 1/log(NR^2/2))^N < (1 - 1/log(N))^N ≈ e^(-N/log N).
Even with about N^2/2 chances for a counterexample, the expected number of counterexamples (union-bound) is only N^2e^(-N/log N), so for sufficiently large (even) N, the probability of the two drawings differing at any point should be vanishingly small. In fact, by this heuristic, we should expect only finitely many counterexamples, so quite likely the 10 above are the only ones.Note that for odd values of n the pattern does not resemble GCD.
Based on the linked explanation here: https://beta.observablehq.com/@montyxcantsin/unwinding-the-u...
1,2,3,4,5,6
7,8,9,10,11,12
13,14,15,16,17,18
19,20,21,22,23,24
25,26,27,28,29,30
See a pattern? 2 & 3 are the only prime numbers that are an exception. All others are multiples of 1 and 5.
Assuming you used “and” when you meant “or”, that's trivially true (and redundant) in that all numbers (irrespective of base, which has no effect on this) are integer multiples of 1.
But no primes other than 5 are integer multiples of 5, in any base.
https://en.wikipedia.org/wiki/Senary
I expressed it poorly, but not as you state, incorrectly.
No, really, it is completely incorrect to use “multiple of X in base Y” to mean “have X as the final digit in base Y” (which is equivalent to “is congruent to X modulo Y.”)
13 is not, in base 10 (or anywhere else), a multiple of 3.[0]
That's just not what “multiple” means.
[0] Well, the number denoted by the digits “13” in any base that is itself a multiple of 3—other than base 3 itself where “13” is not a valid number—is a multiple of 3, obviously, but we're talking about the number represented by “13” in base 10.
What you seem to mean to claim is that primes > 3 are all congruent to either 1 or 5 modulo 6.
Join the Telegram group to discuss: https://t.me/joinchat/G8AnchIna2q8yn1lGHirkA
Note that Even and Odd Values of N have a very different pattern. For example try using the values 99 and 99, and then 100 and 100, in this HTML preview version:
https://htmlpreview.github.io/?https://github.com/acmegeek/p...
Here is animation of increasing even values of N approaching GCD: https://streamable.com/l7r96
CODE TO TRY:
Javascript https://beta.observablehq.com/@montyxcantsin/unwinding-the-u....
Mathematica https://github.com/shaunxcode/a-pattern-in-the-primes
Perl https://www.dropbox.com/s/z5tfub5geyuctex/prime-draw.pl?dl=0
EXPLANATION:
In short, actually there are some curious patterns in this, and they are not simply equivalent to OEIS A054521 (as we, and others, initially thought they were).
For even values of n, they can be rendered by the GCD sequence, without the primality testing. But for odd values the pattern is different and GCD doesn't describe it.
Or, do the regions overlap?
I tried to look at the first 4 rows for n=5, but did not see the pattern depicted (each interval had a prime in it).
Am I interpreting what is meant by the blocks incorrectly, or does the pattern not work for small enough n?
Is that
((n/2) * y^2) - ((n/2) * y) + (y * z) + x ? (For z ranging from 0 to n)
If so, alright, that makes more sense to me, thanks.
So, n * (y * (y-1)/2) + x + y * z ?
Edit: does HN have an escape character to deal with the asterisks?
https://www.dropbox.com/s/d2dfwhxdmzkp4y4/a-pattern-in-the-p...
Edit: The link was changed to a group (at the bottom of the post).
That is a sequence of n consecutive numbers none of which are prime.
Not sure how that would map in this triangle shape yet.
pack =: 3 : '+./ (r,y+1) $ (npc*y+1) {. (npc*y) }. p' "0
pc =: 3 : 0
r =: npc =: y
c =: +/ 1+i.y
p =: 1 p: (1+i.c*npc)
pack i.r
)
Image of output for numbers-per-cell = 75 here: https://twitter.com/seanstickle/status/997675789264015361Really neat! (I still know I haven't the math chops though. Good place to further my study)
As it is, the explanation doesn't really make sense to me.
EDIT: Found this lower down: https://beta.observablehq.com/@montyxcantsin/unwinding-the-u...
"SQLite looks nice, but I would have double checked with Oracle engineers before announcing this as something novel"
Otherwise you’d end up like the MD who’ve “rediscovered” numerical integration (the trapezoid method) and got it published in the journal of diabetes or whatever.
This was shocking because calculus is a required subject in American high schools, and this American doctor presumably went to American high school, not because the doctor didn't check in with mathematicians. Frankly, it would be equally shocking if the doctor had asked a mathematician if integration were a thing, because presumably a doctor is an educated member of society.
In the more mathematical realm in information theory, turbo codes came out of nowhere by people who were not experts in the field of FEC. Their efficiency far surpassed other methods of the time, to the point that their results in the conference paper were doubted. They didn't have any understanding at the time of why they worked well, they just published results.
Lots of physical phenomena start as simple observations that are later worked into theoretical frameworks. The photoelectric effect comes to mind.
The blog post serves that function.
"While the definitions before Conway's LIFE were proof-oriented, Conway's construction simply aimed at simplicity without a priori aiming at the proof of automaton being alive." https://en.wikipedia.org/wiki/Conway%27s_Game_of_Life
If so this could be a huge blow to security.
But I must say this is amazing that they were able to visualize prime numbers in this way. These guys are geniuses.