Rob's Method to Calculate Value of Pi

Introduction

The above applet implements a few methods for computing Pi. You can pick your method from the combo box. All of them are series or iterative methods, so click on reset to reset to first order estimate, single step to step forward one more step, or you can enter a number in the multi step box and click the button to jump forward that many steps all at once.

For all these methods only basic operations (arithmetic and square root) are used. You might argue that square root is not a basic operation, but I think I could write a recursive square root function for you using only arithmetic operations.

The Trapezoidal Integral method uses the trapezoidal rule to compute the area of a 'quarter circle of radius 1', which is pi/4. This method converges slowly, but keeps getting closer.

The Binomial Integral method expands the integrand for the area of a quarter circle, written in Cartesian coordinates, as a series using the binomial expansion. The integral of each polynomial term is easily computed analytically, yielding a series for pi. This converges rapidly, but it has problems after a few iterations because there are factorials in the series which blow up quickly and start to overflow the "long" data structures.

The Newton-Raphson method expands cos(x) as the well-known series, and uses Newton-Raphson to iteratively search for a zero, each time adding another term to the series. The zero of the function is pi/2. This method has similar convergence, and suffers from a similar problem to the Binomial Integral method.

The Arctan Series method expands atan(x) as a Taylor series about x = 0, and then evaluates it at x = 1, producing the simple series    1-1/3+1/5-1/7... which converges to pi/4. Convergence is very slow, worse than the Trapezoidal Integral method. This series does not suffer from the overflow problem because there are no factorials or other rapidly growing numbers. This is the only method so far which does not use the square root function. This method was Ron Walker's idea.

The Iterative Cosine Series method was written by Alan Asbeck. He used a sequence of approximations to pi/2 by guess[i] = guess[i-1]+cos(guess[i-1]) where cosine is computed using a Maclaurin series about pi/2. He used 20 terms in the Maclaurin series to compute the cosine, which is why you will notice that the Java App says each "SingleStep" counts for 20 steps.



How to use this Applet

First, click on the combo box and select method to calculate the value of Pi. If you want to calculate value in each step then you have to click on “SingleStep” button otherwise if you want to calculate value of Pi in multiple steps then you have to click on “MultiStep” button and continue clicking on button until no iteration. Every step displays the value of Pi and also displays the estimate error. If you want to stop processing then click on “RESET” button and the process will stop.