[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [FWP] algorithm to calculate pi



On Mon, Jun 26, 2000 at 11:24:07AM -0500, Andy Bach wrote:
> On Sun, 25 Jun 2000, Michael Assels wrote:
> > #!/usr/bin/perl -l
> > for(0..9999){$i=$_*8;$p+=(16**-$_)*(4/($i+1)-2/($i+4)-1/($i+5)-1/($i+6))}print$p
> 
> and, briefly, can one of the math whizes say why?

Michael's code is a direct implementation of the Bailey-Borwein-Plouffe
Algorithm which is a digit extraction algorithm (if you work in hex)
for pi. I.e. it can calculate a particular digit without being forced to
calculate the preceding digits. That was a pretty spectacular discovery
at the time.

It's since been improved on in speed and flexibility (e.g. base 10). Of
particular note for hackers: check out Francis Bellard's work: he has
a bunch of code (in C & FORTRAN) you can play with.

Here's a good starting point,
http://www.mathsoft.com/asolve/plouffe/plouffe.html

There is a very compelling story on two famous pi hackers, the Chudnovsky
brothers who built supercomputers in their apartment and grabbed world
records, http://www.lacim.uqam.ca/plouffe/Chudnovsky.html

For some reason, Canada seems to have the edge on pi folk right now :-)

Enjoy,
Paul

==== Want to unsubscribe from Fun With Perl?  Well, if you insist...
==== Send email to <fwp-request@technofile.org> with message _body_
====   unsubscribe