A Programmer’s Quest for Primes: Part 3 – Prime Distribution

9 03 2009

While playing around with primes and C some more, I put together some plots with Mathematica dealing with the distance between primes. The prime numbers are plotted, with the n’th prime on the x-axis and the difference between it and the last prime on the y-axis. After all, I’ve got gigabytes of primes sitting around.. got to figure out something to do with them other than test my RAM while generating them.

The first 1,000 primes,

prime_distro_1k1Of course, primes can’t be odd numbers apart, because that would make them even. That explains the pattern a bit. Still, for something that has baffled mathematicians for centuries, it certainly does seem like there’s a pattern to it. If you draw lines between the points,

primes_1k_dist_linedCertainly not as pretty.

The first 10,000 primes,

prime_distro_100kThe scale makes this one a bit less interesting. Too much overlap, but Mathematica really doesn’t like big listplots like this. I even crashed it a few times when I tried to do a listplot of 100,000 data plots. 10,000 was pushing it.

A random sampling of 1,000 primes (between the 90 millionth and 90 million 1 thousandth prime),

primes_distri_90mil1More interesting patterns in primes, the Ulam spiral. Starting at 1 and spiraling outwords from the orgin, you create a graph like so (http://en.wikipedia.org/wiki/Ulam_spiral),

ulam-spirale1And then remove all but the primes (http://en.wikipedia.org/wiki/File:Ulam-Spirale2.png),

ulam-spirale21And you find an intersting pattern, that the prime numbers tend to lay along some diagnols more oftan than others. Expanding this to 150,000 primes,

spiral

Advertisements

Actions

Information

One response

9 03 2009
Mike

Enjoy reading your blog.Btw, this is first time I visit to your blog :)

________________________
Why pay $1000’s for solar or wind power when you can build your ownprofessional system for less than $200?! (in your own backyard)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s




%d bloggers like this: