
> > > > > > > > > > > > > > > > > > > > > > > > 
On 12/31/01 2:53:13 AM, Bruce Chiarelli wrote: If you are looking for algorithms to calculate pi I know a few: here is the gauss algorithm (Which I find easiest). Set these values
Next do these iterations a number of times that is greater than the base 2 logarithm of the number of digits to compute for example: If you want to calculate 1 million digits, iterate this 20 times because the base two logarithm of 1 million is 19.932. Here are the values you need to calculate:
Once this has been repeated sufficiently, substitute the values of a, b , and t into this: pi=(a+b)�/(4*t) 
WOW!
That's the fastestconverging series I've ever seen. It only took 3 iterations (not counting your initial values) to equal the precision of Excel, which is 15 digits.
Here's the spreadsheet I used to verify this:
A  B  C  D  E  
1  a  b  t  x  pi=(a+b)�/(4*t) 
2  1  =1/sqrt(2)  =1/4  1  =(A2+B2)^2/(4*C2) 
3  =(A2+B2)/2  =sqrt(B2*A2)  =C2D2*(A2A3)^2  =2*D2  =(A3+B3)^2/(4*C3) 
4  
5 
Just copy the cells in row 3 to the rows below it, and here are the values you get:
A  B  C  D  E  
1  a  b  t  x  pi=(a+b)�/(4*t) 
2  1  0.707107  0.25  1  2.91421356237309 
3  0.853553  0.840896  0.228553  2  3.14057925052217 
4  0.847225  0.847201  0.228473  4  3.14159264621354 
5  0.847213  0.847213  0.228473  8  3.14159265358979 
The value of the cell E5, is
(((((((1+(1/sqrt(2)))/2)+ sqrt((1/sqrt(2))*1))/2)+ sqrt(sqrt((1/sqrt(2))*1)*((1+(1/sqrt(2)))/2)))/2)+ sqrt(sqrt(sqrt((1/sqrt(2))*1)*((1+(1/sqrt(2)))/2))*((((1+(1/sqrt(2)))/2)+ sqrt((1/sqrt(2))*1))/2)))²/(4*((((1/4)1*(1((1+(1/sqrt(2)))/2))²)(2*1)*(((1+(1/sqrt(2)))/2)((((1+(1/sqrt(2)))/2)+ sqrt((1/sqrt(2))*1))/2))²)(2*(2*1))*(((((1+(1/sqrt(2)))/2)+ sqrt((1/sqrt(2))*1))/2)((((((1+(1/sqrt(2)))/2)+ sqrt((1/sqrt(2))*1))/2)+ sqrt(sqrt((1/sqrt(2))*1)*((1+(1/sqrt(2)))/2)))/2))²))
This method of approximating pi is also called the GaussLegendre approximation.
You may wonder how I came up with that silly expression. I used Excel to create a text string, rather than carry out the computation. That is, instead of =sqrt(B2*A2), I wrote ="sqrt(("&B2&")*("&A2&"))", etc. Then, in cell E5, I got that delightful expression you see above. Then I found (and fixed) places where 1 is a factor, such as 1* or *1, and removed extraneous parentheses to get the (relatively) shorter expression you see here.
((((1+1/sqrt(2))/2+ sqrt(1/sqrt(2)))/2+ sqrt(sqrt(1/sqrt(2))*((1+1/sqrt(2))/2)))/2+ sqrt(sqrt(sqrt(1/sqrt(2))*((1+1/sqrt(2))/2))*(((1+1/sqrt(2))/2+ sqrt(1/sqrt(2)))/2)))�/(2*2*(((1/(2*2)(1(1+1/sqrt(2))/2)�)2*((1+1/sqrt(2))/2((1+1/sqrt(2))/2+ sqrt(1/sqrt(2)))/2)�)(2*2)*(((1+1/sqrt(2))/2+ sqrt(1/sqrt(2)))/2(((1+1/sqrt(2))/2+ sqrt(1/sqrt(2)))/2+ sqrt(sqrt(1/sqrt(2))*((1+1/sqrt(2))/2)))/2)�))
You may have noticed that the number 4, which appeared only twice in the original expression, is now replaced by 2*2, leaving an expression with just ones, twos, arithmetic operators and sqrt! I dare you to copy this and paste it into Excel just to see whether it gives you pi!
What fun!
The webmaster and author of this Math Help site is Graeme McRae.