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