Lesson goal: Add numbers to get $\pi$

Previous: A clever for-loop for Pi | Home | Next: What kinds of numbers?

D. Bailey, P. Borwein, and S. Plouffe (called "BBP") came up with this formula for $\pi$:

$\pi=\sum\limits_{n=0}^\infty \frac{1}{16^n}\left(\frac{4}{8n+1}-\frac{2}{8n+4}-\frac{1}{8n+5}-\frac{1}{8n+6}\right)$ (from "Pi Unleashed," by J. Arndt and C. Haenel, p. 117).

Use a for loop of about 10 terms, and see how close this sum comes to $\pi$.

Now you try. Use this BBP sum to compute $\pi$! Try 100 terms! 1000!

Type your code here:


See your results here: