Hacker News new | past | comments | ask | show | jobs | submit login
The Ulam spiral: hidden structure among the prime numbers (bitbucket.org)
118 points by ctkrohn on Dec 29, 2010 | hide | past | web | favorite | 39 comments



Every time I see that thing, I want to take a huge chunk of prime numbers and write code to visualize them in different ways as quickly as possible. How do they look if you put them in, say, a hexagonal grid instead of a square one? Do patterns emerge if you draw them on a Hilbert curve? A 3D Hilbert curve? 4D? Has anyone tried these? Am I crazy for wanting to? Why are the ducks watching me?


No! Do it! Fork my trivial program and put up your results.

The square is a pretty interesting place to start, though, since we already know there's a relationship between quadratic polynomials over the naturals and the distribution of primes. These polynomials describe lines that (eventually) become straight.

This is definitely amateur math hour for me. I was a math major a few years ago, but I did not study any number theory.


I'm leaning towards making something in Ruby, as I'm more familiar with it. Then I can throw a few dozen (hundred?) million pre-calculated primes at it, and look for macro-scale patterns, without having to do much calculation at all. Just plotting points.

Maybe it's time to dive deeper into Objective C and / or OpenGL. I've got a few ideas that would be fun to try in real-time, but most of the more "fun" programming languages have poor / slow graphics libraries, and something low level lets you handle millions of entries without breaking a sweat.


Regarding diving deeper into Obj-C/OpenGL, you could also consider prototyping your ideas quickly using something like Quartz Composer. I don't know any specifics on whether it'd deal properly with a large data-set, but the learning curve is not steep at all and it might get you going quickly.


I've seen QC, poked at it a couple times, but never in depth. Any recommendations for resources?

Usually I'm struck by how unbelievably awesome the UI is, and how scores of similar attempts have been incomprehensibly awful. Meanwhile, Apple comes out with QC, a fast, elegant, simple version that goes almost totally unnoticed. Weird.


Mark Chu-Carroll plots it on the Archimedean spiral in his post about the Ulam here: http://scientopia.org/blogs/goodmath/2010/06/22/the-surprise...


Neat! I've also thought about drawing them on a Hilbert curve and would be interested in seeing the results.


Arthur C. Clarke described the prime spiral seven years before it was discovered by Ulam in his 1956 novel 'The City and the Stars': "Jeserac sat motionless within a whirlpool of numbers. The first thousand primes, expressed in the binary scale that had been used for all arithmetical operations since electronic computers were invented, marched in order before him. Endless ranks of 1's and 0's paraded past, bringing before Jeserac's eyes the complete sequences of all those numbers that possessed no factors except themselves and unity. There was a mystery about the primes that had always fascinated Man, and they held his imagination still. Jeserac was no mathematician, though sometimes he liked to believe he was. All he could do was to search among the infinite array of primes for special relationships and rules which more talented men might incorporate in general laws. He could find how numbers behaved, but he could not explain why. It was his pleasure to hack his way through the arithmetical jungle and sometimes he discovered wonders that more skilful explorers had missed.

He set up the matrix of all possible integers, and started his computer stringing the primes across its surface as beads might be arranged at the intersections of a mesh. Jeserac had done this a hundred times before and it had never taught him anything. But he was fascinated by the way in which the numbers he was studying were scattered, apparently according to no laws, across the spectrum of the integers. He knew the laws of distribution that had already been discovered, but always hoped to discover more."


Aside from him visualizing primes using the word "whirlpool", that doesn't sound like the same thing at all. For one, the Ulam spiral doesn't employ binary representation. And it distinctly presents a diagonal pattern, whereas Clarke seems to be describing a visualization with no patterns at all ("apparently according to no laws").


I love the fact Clarke used the term "hack" in 1956.


I'd just like to double-check that you and others realise that there are multiple definitions for the word "hack," some originating from far before the 1950s ;)

chop: cut with a hacking tool

cut away; "he hacked his way through the forest"

a mediocre and disdained writer

etc.

http://www.google.com/search?sourceid=chrome&ie=UTF-8...


I'm one of those guys who didn't necessarily pay a lot of attention to maths in college - not that I don't see the value in it, but it is certainly not a core interest. However, I've been slowly getting more and more into maths and the science of primes. So this post (and the questions the Ulam spiral asks) strike me at the worst of times and the best of times.

If you're at least a bit like me (no deep knowledge of maths, but growing curiosity) I recommend checking out BBC's recent documentary on primes, called 'The Music of the Primes'. It'll spark your interest, and it'll make you want to dig a little deeper.


if you've ever prepared for a standardized quant test like the GMAT it immediately becomes apparent how useful even a basic understanding of primes can be. being able to manipulate primes at even the superficial level required (to do well) by these exams gives great insight and appreciation for the power/beauty of prime numbers. it really opened my eyes to mathematics in general, and i wish it were an education/perspective i'd been given as a child rather than a young adult. (I realize the GMAT is likely anathema to this forum so i hesitate in mentioning it, but the result of my preparation was some surprisingly useful insight in these regards...)


I'd put myself in the same category, math-curious. I missed the TV series, but bought the book instead: http://www.musicoftheprimes.com/thebook.htm It's a good read.

BTW I hadn't seen that website until I went looking for a URL for the book just now. The site seems to have some pretty interesting material in its own right too.


Vi Hart has a great video which takes the Ulam spiral as its starting point: http://www.youtube.com/profile?user=Vihart#p/u/0/Yhlv5Aeuo_k

If you don't know her work, you should. She's so much fun...


Any time I see research or visualizations of primes, I get nervous. I fear that all of our online security is based on encryption and all of that is based on the one-way nature of prime functions.

Can you imagine a world where someone discovers a way to trivially decode every https or ssh session on the internet? I fear we are building a city on top of the fog.


I wouldn't worry so much. RSA is based on the integer factorization problem . Hypothetically if you figured out any pattern in the distribution of prime numbers it would help in the factorization but there has been about hundreds of years of research in this direction and it is a extremely hard problem. Even if this was solved we could always move to ECC encryption like curve22519

Sources http://cr.yp.to/ecdh.html http://en.wikipedia.org/wiki/Riemann_hypothesis http://en.wikipedia.org/wiki/RSA_problem


Clearly number theory research is a prohibited circumvention activity and should be prosecuted to the fullest extent of the law.


You laugh today…


Yea, but number theory also allows us to devise new crypto systems... for example take a look at curve 25519


As a metanote, I wish there was a standard way of marking sarcasm and joke posts on HN, so they don't get downvoted simply because they don't make sense when interpreted literally.


;)


Another interesting site concerning visualization of patterns in prime numbers:

http://www.divisorplot.com/

http://www.divisorplot.com/6.html -- the Ulam spiral


Sidenote: This is the same Ulam of "Ulam-Teller Design" fame, the basis for thermonuclear weapons.


On another sidenote; his autobiography "Adventures of a Mathematician", is really worth reading.

http://www.amazon.com/Adventures-Mathematician-S-M-Ulam/dp/0...


One of my mathematics teachers used to regard prime numbers with considerable irritation. She tried to explain to the class why there was no simple formula to determine which numbers were primes. In the end, she gave up and moved on to the next part of the syllabus, leaving the question unanswered. I almost felt sorry for asking her in the first place. Almost.

If this mathematics teacher had had access to the diagram of the Ulam spiral, however, I imagine that this alone could have provided the impetus for at least one student - me - to have made an academic career out of mathematics. As it is, she committed many other crimes against education, including her infamous catchphrase "Don't bother studying any kind of pointless mathematics that you'll never need to use at work." A catchphrase whose validity has been refuted many times over the years, not the least with the discovery of this diagram.


Something that's always struck me as odd is the "importance" of prime numbers. It seems so trivial that a number having only 1 and itself as common divisors would be useful or special. Nevertheless, they're important indeed.

In other words, I'm struck by the ability of mathematics to generate such apparent complexity from simple principles :)


.. and it's only with their (relatively recent) use in cryptography that prime numbers became "important". G.H. Hardy, one of the leading number theorist in his era claimed that none of his work was useful, and therefore never could be applied to good or evil. Makes you wonder what applications the future holds for what is considered purely theoretical today.


Primes are the "atomic" blocks of the natural numbers. Given the prime factors of a set of natural numbers, you can trivially computer the greatest common divisor and least common multiple. Primes are extremely important.

See http://en.wikipedia.org/wiki/Fundamental_theorem_of_arithmet...


> .. and it's only with their (relatively recent) use in cryptography that prime numbers became "important".

A pair of mechanical gears with relatively prime numbers of teeth have a longer service life: a given tooth rubs the same amount against every tooth in the partner gear. If they are not relatively prime, the hardest tooth would hit only a few teeth on the partner gear, wearing them out many times faster.



s/mathematics/the universe/

:) See also: http://en.wikipedia.org/wiki/Emergence


"It is a visual representation of just how little we know about the structure of the primes"

Come on, really? It's an intriguing visualization, but the patterns (in so far as they are real, and not an artefact of the limited size of the spiral) can be explained with some high school math.


If you can explain them please enlighten us all. You will have to show that Hardy-Littlewood's Conjecture F is true. http://en.wikipedia.org/wiki/Bateman%E2%80%93Horn_conjecture


I'm not a mathematician, but I don't think you can deduce that conjecture from the Ulam Spiral. On the other hand, you don't need this conjecture to show e.g. 4x^2-2x+41 is rich in primes (within the limits of the picture). If I recall, you can show the clumping arises from rewriting the primes in base 6.

EDIT: To hurry along the conversation a bit - it's entirely possible I've been misled into thinking things are more simple than they really are. Wouldn't be the first time...


Sorry if I was a bit snarky in my first reply. As far as I understand this, you can't explain the structure of the Ulam spiral in a trivial way. You are correct that there is a trivial part to the spiral: diagonal lines alternate between odd and even numbers, therefore all the primes lie along diagonal lines. However, the structure is much richer than that.

The question is why certain lines have lots of primes and not others? why is a given polynomial so rich in primes, while other similar ones are not? That's what some of these conjectures are trying to prove.


diagonal lines alternate between odd and even numbers, therefore all the primes lie along diagonal lines

Huh? If you draw the Ulam spiral on a checkerboard, all odd numbers end up on squares of one color and all even numbers of squares of the other color, but that is neither necessary nor sufficient to get those diagonal streaks in the picture.


Similar visualizations here:

  http://blog.morphism.com/2010/05/building-numbers.html
  http://blog.morphism.com/2010/07/pdfs-from-building-numbers.html
That stuff was generated using Mathematica.


What if prime numbers can actually plotted as a fractal, i.e. they have fractal geometry? I bet they do, since fractals showing up in more and more unexpected places in nature, physics, and math.




Applications are open for YC Winter 2020

Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | Legal | Apply to YC | Contact

Search: