Philipp's Computing Blog

Success is about speed and efficiency

calculate pi to a 1000 digits

http://alien.slackbook.org/blog/calculating-pi/

Here is a shell / Bash script that calculates Pi to 1000 digits:

bc -l <<< 'scale=1000; 4*a(1)'
# which is shorter than the equivalent
echo "scale=1000;4*a(1)" | bc -l

One more calculation using bc: the golden ratio to 10 digits:

bc -l <<< 'scale=10;(1 + sqrt(5))/2'

Resources

  • If you want a multi-threaded program (to test the performace of your machine?!) calculating pi, try y-cruncher