11:09:40 pm on 2/4/12

Menu
» Home
» About Scott
» VD Labs
» QRSS VD
» Old Stuff
» Archive
» Publications
» Contact

Categories
» C/C++
» Circuitry
» DIY ECG
» General
» high altitude balloon
» Linux
» Microcontrollers
» Molecular Biology
» My Website
» PHP
» Prime Numbers
» Python
» Radio
» UCF Lab
» Everything
» RF Links

Writings
» MD Labels
» Streamrip
» AIM Thoughts
» WindowsXP?
» Partitioning
» CD/DVD Repair
» Monitor Info
» CRT Deflection
» Venomcrack
» Flash Thing
» Heart/Brain
» Diabetes
» Triops
» Biomed

Friends
» Mike
» Fred
» Kyle W
» Nick
» Louis
» Tom
» Kyle H




Archives
» August 2011
» July 2011
» June 2011
» March 2011
» February 2011
» January 2011
» December 2010
» November 2010
» September 2010
» August 2010
» July 2010
» June 2010
» May 2010
» April 2010
» March 2010
» February 2010
» January 2010
» December 2009
» September 2009
» August 2009
» July 2009
» June 2009
» May 2009
» April 2009
» March 2009
» February 2009
» January 2009
» December 2008
» November 2008
» October 2008
» September 2008
» September 2007
» December 2006
» August 2006
» January 2006
» August 2005
» July 2005
» June 2005
» May 2005
» April 2005
» March 2005
» February 2005
» January 2005
» December 2004
» November 2004
» October 2004
» September 2004
» August 2004
» July 2004
» June 2004
» May 2004
» April 2004
» March 2004
» February 2004
» January 2004
» December 2003
» November 2003
» October 2003
» September 2003
» August 2003
» July 2003
» June 2003
» May 2003
» April 2003
» March 2003
» February 2003
» January 2003
» December 2002
» November 2002
» October 2002
» September 2002
» June 2001
« Prime Prototype Construction
McPPNG Nearing completion »


Code Monkey Want Cookie
673 words | Posted on June 5th, 2009
Scott was 23.70 years old when he wrote this!
Filed under: General, Prime Numbers, Python

This week has been a hectic week of ups and downs, with the stress never letting up. Work is stressful (I’m being challenged to collect representative data to write & submit two manuscripts for publication in JCN ASAP) and home is stressful. My wife and I are down to one car right now, which has no AC and pumps out heat! There’s always stuff I need to do around the house (cleaning, cooking, laundry, etc). Bills are actually getting a little intimidating since I haven’t gotten paid accurately in over a month and a half due to a payroll problem at UCF. On top of everything, I only have a few minutes here and there to devote to my microcontroller projects. When I have time to work on them, I’m rushed, and often make bad mistakes (such a yesterday when I destroyed 6 of my 2222 NPN transistors).

Thankfully, I’ve had a couple lucky breaks lately. Yesterday I finished the hardware enclosure and wiring for my microcontroller-powered prime number generator prototype. The code is sufficient to blink each of the 30 LEDs individually. When I do it fast, they all appear on. I’m golden – all I need to do to finish the [prototype] project is software side. Time to refresh myself on how to pass arrays with pointers in C! In other news, I had a little mental breakthrough this afternoon allowing me to generate prime numbers significantly more sufficiently. The screenshot below shows me identifying the 2,364,346′th prime number (38,790,019) in a little under two and a half hours. Yay! [makes dinner]
prime_screenshot

After a few hours running the code described above (writing down some time points along the way) I decided to try and visualize the curve of the rate of primes discovered with respect to time. I figured it would resemble an inverse exponential curve but it was surprisingly linear. Before I go to bed tonight I’ll re-write the code to make it automatically log time points so I can graph it in higher accuracy tomorrow. For now, this is what it looks like:
primespeedpng

As much as I’d like to toot my own horn about how fast and efficient my computational method is. The linear estimate based upon this data (an overshoot of the actual speed) suggests that it finds 10,000 prime numbers per minute. That sounds lovely, but according to my math in order to get to the 10^12′th prime (the goal) it would take 190 years. I hope I have a full battery.

The code to generate the graph (requires MatPlotLib):

data="""
112.5,2062841
141.0,2364346
168.75,2656766
177.5,2745573
214.5,3123373
232.5,3290106
247.5,3419679
256.5,3493450
"""
import pylab
x,y,fx,fy=[],[],[],[]
for line in data.split('n'):
        if not "," in line: continue
        nx,ny = line.split(",")
        x.append(float(nx))
        y.append(float(ny))
pylab.figure(figsize=(8,4))
pylab.plot(x,y,'k.-',label='real data',lw=1)
pylab.plot([x[0],x[-1]],[y[0],y[-1]],'b:',label='linear estimate')
pylab.ylabel("number of primes found")
pylab.xlabel("time (minutes)")
pylab.title("pyPrime Nth Prime Speed (bin=[2,3,5])")
pylab.legend(loc=8)
pylab.grid(alpha=.2)
pylab.show()

After letting the program run overnight using a larger prime bin (primes=[2,3,5,7]) and recording the progress every 100 bins I have a better idea of the speed (and rate of decay) of this method.
primespeedfancypng





This entry was posted on Friday, June 5th, 2009 at 8:51 pmand is filed under General, Prime Numbers, Python. You can follow any responses to this entry through the RSS 2.0 feed. You can skip to the end and leave a response. Pinging is currently not allowed.

Leave a Reply




copyright © 2006 swharden@gmail.com