CS 1073 Introductory Programming
for Scientific Applications
Calculate Pi Inefficiently


pi: the ratio of circumference to diameter of a circle: Use the following formula:


Here is a simple Java program that uses the above series to calculate pi:


Here are results of a run with N = 1000 (as above). Notice that with 1000 terms, we still only get 3 significant digits of accuracy.


Here are results of a run with N = 10000 (just N changed above). Notice that with 10000 terms, we still only get 4 significant digits of accuracy.


Here are results of a run with N = 100000 (just N changed above). Notice that with 100000 terms, we still only get 5 significant digits of accuracy.


Here are two more complicated listings along these lines:
Better formulas for pi,   pi by averaging,   pi from an expression.