home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!mcsun!uknet!comlab.ox.ac.uk!imc
- From: imc@comlab.ox.ac.uk (Ian Collier)
- Newsgroups: rec.puzzles
- Subject: Re: Formulae for pi
- Message-ID: <2740.imc@uk.ac.ox.prg>
- Date: 19 Nov 92 17:53:20 GMT
- References: <1992Nov6.163504.17171@husc15.harvard.edu> <1992Nov15.193400.8408@r-node.gts.org> <1992Nov16.052144.23407@bnr.ca>
- Organization: Oxford University Computing Laboratory, UK
- Lines: 45
- X-Local-Date: Thursday, 19th November 1992 at 5:52pm GMT
- Originator: imc@msc5.comlab
-
- In article <1992Nov16.052144.23407@bnr.ca>, bcash@crchh410.BNR.CA (Brian Cash) wrote:
- >In article <1992Nov15.193400.8408@r-node.gts.org>,
- >amichail@r-node.gts.org (Ashraf Michail) writes:
- >|>This is the best algorithm I know for generating PI:
- [iteration deleted]
- >|>1/(a15) will give more than two billion digits of PI..
- >Don't your roots need to be taken to two billion digits, then?
-
- Yes, but what of it?
-
- I've tested this by the way, and it really works. (I haven't tested it to 2
- billion digits, but to a few hundred anyway). I also have two similar
- ones - one based on square roots from ages ago, and one based on cube roots
- which was published in the October notices of the AMS. This one uses
- quartic roots. I wonder if there is a general formula (I suppose this
- should have gone to sci.math...) Incidentally, the cube root version was
- the quickest, because it seems that the time taken to calculate a fourth
- root cancels out the extra speed of the algorithm.
-
- Anyway, the original poster wanted to use BASIC. All these formulae are not
- much use for your average BASIC. If you are still reading, what system is
- this on? It's not often I get to say this, but REXX is the best language
- for the job. It is available for most systems. My implementation of the
- above algorithm (and several others) is in REXX. (If anyone wants to see
- these, just email).
-
- REXX is good because it's fairly easy to program, and it can do high
- precision arithmetic with the greatest of ease. Here's a quickie which
- calculates 6*arcsin(0.5):
-
- parse arg n .
- if n='' then n=9
- numeric digits n+3
- numeric fuzz 1
- a=1/8;pi=3+a
- do i=3 by 2 until p=pi
- a=a*i*i/4/(i+1)/(i+2)
- p=pi
- pi=pi+a
- end
- numeric digits n
- say "pi = "format(pi)
-
- Ian Collier
- Ian.Collier@prg.ox.ac.uk | imc@ecs.ox.ac.uk
-