home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / programm / 3538 < prev    next >
Encoding:
Text File  |  1993-01-21  |  2.3 KB  |  54 lines

  1. Newsgroups: comp.programming
  2. Path: sparky!uunet!newsgate.watson.ibm.com!yktnews2.watson.ibm.com!yktnews!admin!flu!lowry
  3. From: lowry@watson.ibm.com (Andy Lowry)
  4. Subject: Re: how to calculate PI
  5. Sender: news@watson.ibm.com (NNTP News Poster)
  6. Message-ID: <LOWRY.93Jan21121950@rotor.watson.ibm.com>
  7. In-Reply-To: rogerj@aix.rpi.edu's message of Wed, 20 Jan 1993 20:39:45 GMT
  8. Date: Thu, 21 Jan 1993 17:19:50 GMT
  9. Disclaimer: This posting represents the poster's views, not necessarily those of IBM
  10. References: <peterd.727508100@tscc2> <LOWRY.93Jan20104500@rotor.watson.ibm.com>
  11.     <c8h3xpm@rpi.edu>
  12. Nntp-Posting-Host: rotor.watson.ibm.com
  13. Organization: IBM T.J. Watson Research Center
  14. Lines: 38
  15.  
  16. In article <c8h3xpm@rpi.edu> rogerj@aix.rpi.edu (Diversion (Jeff Rogers)) writes:
  17.  > lowry@watson.ibm.com (Andy Lowry) writes:
  18.  > 
  19.  > >In article <peterd.727508100@tscc2> peterd@tscc2.macarthur.uws.edu.au () writes:
  20.  > > > Anyone out there have an algorithm for calculating PI ?
  21.  > 
  22.  > >One of the coolest formulas I've seen in Gregory's formula:
  23.  > 
  24.  > >  pi/4 = 4*atan(1/5)-atan(1/239)
  25.  > 
  26.  > Why not just 
  27.  >    pi/4=atan(1)? 
  28.  > If your answer is in radians, this works too, but
  29.  > I think it requires prior knowledge of pi. 
  30.  > 
  31.  > >In any case, you can use Taylor expansion to get atan(1/5) and
  32.  > >atan(1/239).  I understand there are more high-powered schemes out
  33.  > 
  34.  > Maybe this is the answer (to my question above), but I don't see why a
  35.  > taylor expansion would work for some values and not others.
  36.  
  37. Of course you can use atan(1), but the series won't converge anywhere
  38. near as quickly.  The series for atan(x) is:
  39.  
  40.    atan(x) = x - x^3/3 + x^5/5 - + ... + (-1)^(n-1)x^(2n-1)/(2n-1) + ...
  41.  
  42. For x=1, you get 1 - 1/3 + 1/5 - 1/7 + ..., which converges
  43. exceedingly slowly.  For x = 1/5 or x = 1/239 you get reasonably fast
  44. convergence... fast enough for many thousands of decimal places with a
  45. reasonably short computation on any modern machine.
  46.  
  47. Besides, part of the reason I posted Gregory's formula is that it's
  48. such a bizarre formula.  As I mentioned in my original post, I can't
  49. imagine how anybody ever stumbled onto it.  It's like whipped cream...
  50. what in the world inspired the first cream-whipper to do it?
  51. --
  52. Andy Lowry, lowry@watson.ibm.com, (914) 784-7925
  53. IBM Research, P.O. Box 704, Yorktown Heights, NY  10598
  54.