home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / rec / puzzles / 7384 < prev    next >
Encoding:
Text File  |  1992-11-19  |  2.2 KB  |  58 lines

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