[net.micro] n-digit Pi algorithm

SECRIST%OAK.SAINET.MFENET@lll-mfe.arpa (12/18/85)

Date:    Sat, 14-DEC-1985 10:58 EST
To:      Info-Micro@BRL-VGR.Arpa
Message-ID: <[OAK.SAINET.MFENET].8F8D6F60.008E77DA.SECRIST>
Organization: Science Applications Int'l. Corp., Oak Ridge, Tenn.
Geographic-Location: 36 01' 42" N, 84 14' 14" W
CompuServe-ID: [71636,52]
X-VMS-Mail-To: ARPA%"Info-Micro@BRL-VGR.Arpa"


Does anybody out there know the algorithm for computing Pi to n-digits ?
I don't mean 22/7 or a quickie approximate-it-in-a-loop-in-basic... I
mean computing it to like 100,000 places.  Not that this has much practical
value, of course, but just as a nifty computing curiosity.  Thanks.

Richard
SECRIST%OAK.SAInet.MFEnet@LLL-MFE.Arpa

doug@terak.UUCP (Doug Pardee) (12/20/85)

> Does anybody out there know the algorithm for computing Pi to n-digits ?

I don't know a fast one.  One that works, but will take forever, is
  4/1 - 4/3 + 4/5 - 4/7 + 4/9 - 4/11 + 4/13 - 4/15 + 4/17 - 4/19 + ...
-- 
Doug Pardee -- CalComp -- {hardy,savax,seismo,decvax,ihnp4}!terak!doug

LINDSAY@tl-20b.arpa (12/22/85)

Pi = 16 arctan 1/5  - 4 arctan 1/239

arctan x = x - x**3/3 + x**5/5 ...
-------

LINDSAY@tl-20b.arpa (12/24/85)

I've been asked for the provenance of the formula I gave.  I suggest looking
up the "Gregory-Leibniz equation", which is a close relative of

arctan x = x - x**3/3 + x**5/5 ...                and dates to the 1600's.

Various people have fiddled with argument values and trig transforms:

Gauss's version     Pi = 48 arctan 1/18  + 32 arctan 1/57 - 20 arctan 1/239
Stormer's version   Pi = 24 arctan 1/8   +  8 arctan 1/57 +  4 arctan 1/239
the one I gave      Pi = 16 arctan 1/5                    -  4 arctan 1/239

In 1961, someone calculated Pi to 100,000 places, using both Gauss's version
and Stormer's version. Both gave the same answer (except for roundoff).
However, Gauss's version ran in half the time. I suspect my version is
the slowest of the three.
-------

ags@pucc-h (Dave Seaman) (12/24/85)

In article <842@brl-tgr.ARPA> SECRIST%OAK.SAINET.MFENET@lll-mfe.arpa writes:
>Does anybody out there know the algorithm for computing Pi to n-digits ?

A reasonably fast series for pi is given by

	pi/4 = 4 * arctan(1/5) - arctan(1/239)
where
	arctan x = x - x^3/3 + x^5/5 - x^7/7 + ...

so that

	pi/4 = 4 * [1/5 - 1/(3*5^3) + 1/(5*5^5) - 1/(7*5^7) + ...]
	       - [1/239 - 1/(3*239^3) + 1/(5*239^5) - 1/(7*239^7) + ...]
-- 
Dave Seaman	  					pur-ee!pucc-h!ags