Computing 45 million digits of \pi

Bryden Cais


This program is a very short and simple pari script that implements one of the powerful AGM recursions for computing \pi. The program, and in particular the mathematics behind it, are described in the slides for my talk How to compute 45 million digits of \pi at the University of Michigan Undergraduate Math Club. In turn, this talk is based on the excellent book Pi and the AGM by Borwein and Borwein.

To run the program, proceed as follows: at a terminal on a machine with pari installed, issue the command "gp pi1". This starts pari with the program loaded. Next, change the precision to the desired value by typing "\p N" where N is the number of significant digits you care about. Then type "pi(d)" where d is the number of iterations you want the program to cycle through. After d iterations, you should have more than 10^(2^(d+1)) accurate digits of pi. Of course, for large values of N, you may also need to increase the memory allocated to the program as otherwise you'll likely get overflow errors (after all, 45,000,000 is rather large).


[back]