Pi-Pourri
Several formulae for calculating 100 million digits of Pi in 3 minutes, using python and GMPY2
I wanted to see how long it would take to calulate pi to a million places to answer a kid's question
I found a page https://medium.com/@cosinekitty/how-to-calculate-a-million-digits-of-pi-d62ce3db8f58 that had a program using Machin's formula from 1706:
The article also included a link to several Machin-like formulae: https://en.wikipedia.org/wiki/Machin-like_formula
I added several to the code I also used GMPY's mpfr() and mpz types to speed things along instead of just big integer support in python The GMPY2 library has a wide range of high precision functions.
I added 7 Machin formulae like:
Then I added Chudnovsky:
Finaly I added Arithmatic Geometric Mean
Here is the help for the program type python3 pi-pourri.py -h
to see it
usage: pi-pourri.py [-h] [-f [FILENAME]] [-d [1 to 100,000,000]] [-a [1 to 10]]
pi-pourri.py runs an algoritym from a list to calulate Pi to a number of decimal places
Default: pi-pourri.py --digits 100000 --file pi.txt --alog 4
So -d 100,000,000 will take a while to finish, -d 1,000,000 very quickly
A last 5 digit check is done on powers of ten (10,...10000000,100000000)