Pi at the intersection of pure and applied mathematics

So back on pi day I wrote a short blog post about calculating pi to 30,000 digits. I have to admit that I fundamentally tend to fall into the applied mathematics category. That is to say that as an engineer math has always been a means to an end, i.e. I do math to find the correct voltage in a given circuit or to calculate total resistance or distance as a related to time. But I can spend some time in the study of pure mathematics occasionally. I started calculating pi some time ago on a pentium 166 MHz computer. Ironically you could argue that it started out as applied mathematics. I used the process to burn in the CPU and detect and arithmetic flaws the processor might have. But once I spotted some interesting numbers like 6 9’s in a row “999999” starting at position 763 of Pi or the fact that there are no zeros in the first 31 digits. I became quite interested in the number in general. That pattern does not show up again in the next 100,000 digits… I have calculated pi to 100,000 digits on several different machines to understand the differences in processing power of a single core. So why do I do it? Curiosity I suppose… why does anyone really do pure mathematics?

It took my machine 167 seconds or 2 minutes and 47 seconds to calculate pi to 10,000 digits. So how long would it take to calculate pi to 100,000 digits? It turns out it took 67,255 seconds or 18 hours 40 minutes and 55 seconds. I find those results interesting.

Here is my code to calculate the first 100,000 characters of pi.

#!/bin/bash
pi=$(echo "scale=100000; 4*a(1)" | bc -l)
timestamp=`/bin/date`
/bin/echo "The time is now $timestamp and this script has been running $SECONDS seconds and is now finished running." >> ./cpu.log
/bin/echo "$pi" > ./pi.file

And here is the first 100,000 digits of pi
Here is a little chart of some of the machines I have calculated pi on and how long it took each machine to get to 10,000 digits

pi to 10,000 digits

Pi to 10,000 digits from various CPU’s

Obviously it took quite a while to calculate pi with older machines and much of the speed increases in the beginning were simply a function of processor speed, but as technology grew and processors became more efficient it ceased to be about processor speed and more about on board cache and now it would seam its back to processor speed again… the ebb and flow of technology….

Just for grins I calculated pi to 10,000 digits on the raspberry-pi model b running at 700 MHz. It took a whopping 1783 seconds to complete which would put it slower than my decade and a half old Pentium III computer. But that Pentium III computer did not cost 35 dollars.

Likewise I calculated pi to 10,000 digits on my pcDuino3 which has a AllWinner A20 SoC 1GHz ARM Cortex A7 Dual Core processor. The process ran for 937 seconds which is quite a bit faster than it ran on the raspberry pi but still in the range of an older Pentium III computer.

So after those results I decided to go back and calculate pi to 10,000 digits on my Beaglebone Black and the results supprised me a bit. The beaglebone black was able to perform the task in 728 seconds. This is significantly faster than the raspberry pi and slightly faster than the pcDuino.

I just checked my macbook pro with a 2.3 GHz core i5 and it took 162 seconds to calculate pi to 10,000 digits.

Feel free to run the script and post your results in the comments below.

on the topic of pure math… here are a couple video’s worth watching…

the first video is about dynamical sequences, prime divisors and special exceptions. Featuring Dr Holly Krieger from MIT.

and the second video is about the Fibonacci series. Featuring Arthur Benjamin

Edited to add an update

So I ran into a problem with this script when you extend the scale to 200,000 digits bash has a problem with a variable of that length so I rewrote the script slightly and ran it again.


#!/bin/bash
echo "scale=200000; 4*a(1)" | bc -l > ./pi.file
timestamp=`/bin/date`
/bin/echo "The time is now $timestamp and this script has been running $SECONDS seconds and is now finished running." >> ./cpu.log

The slightly rewritten script works fine. It took 400,625 seconds or just over four and a half days to complete.

So to summarize the results for my linux pc are as follows.

pi to 10,000 digits in 167 seconds
pi to 100,000 digits in 67,255 seconds
pi to 200,000 digits in 400,625 seconds
pi to 250,000 digits in 951,833 seconds
pi to 500,000 digits in 5,700,119 seconds

Are there any guesses as to how long it will take to calculate pi to a million digits running single threaded on a single core?

and here is the first half milliom digits of pi for those who are wondering what they are.

And here is some more pure mathematics if you are so inclined.

pure matematics comes to the raspberry pi with the addition of Wolfram and Mathematica!

Tagged on:

5 thoughts on “Pi at the intersection of pure and applied mathematics

  1. Pingback: Getting to know the pcDuino3 | One Mans Anthology

  2. zero

    I ran this on a Intel Pentium(R) Dual-Core CPU E6300 @ 2.80GHz running mint 17 and it calculated pi to 10k in 172 seconds. Not bad for a motherboard with an old american megatrends bois.

  3. hytekblue Post author

    I just updated the post with the results of calculating the first half million digits of pi. It took 65 days 23 hours 21 minutes and 59 seconds to complete. That is quite a jump in time….

Leave a Reply

Your email address will not be published. Required fields are marked *