home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / programm / 3583 < prev    next >
Encoding:
Internet Message Format  |  1993-01-25  |  1.9 KB

  1. Path: sparky!uunet!mcsun!uknet!comlab.ox.ac.uk!imc
  2. From: imc@comlab.ox.ac.uk (Ian Collier)
  3. Newsgroups: comp.programming
  4. Subject: Re: how to calculate PI
  5. Message-ID: <2961.imc@uk.ac.ox.prg>
  6. Date: 25 Jan 93 12:10:14 GMT
  7. References: <LOWRY.93Jan20104500@rotor.watson.ibm.com> <c8h3xpm@rpi.edu> <1993Jan23.080718.24306@qiclab.scn.rain.com>
  8. Organization: Oxford University Computing Laboratory
  9. Lines: 31
  10. X-Local-Date: Monday, 25th January 1993 at 12:09pm GMT
  11. Originator: imc@msc3.comlab
  12.  
  13. In article <1993Jan23.080718.24306@qiclab.scn.rain.com>, Leonard.Erickson@f51.n105.z1.fidonet.org wrote:
  14. >rogerj@aix.rpi.edu (Diversion (Jeff Rogers)) writes:
  15. >>lowry@watson.ibm.com (Andy Lowry) writes:
  16. >>>One of the coolest formulas I've seen in Gregory's formula:
  17. >>>  pi/4 = 4*atan(1/5)-atan(1/239)
  18.  
  19. (earlier I explained how this formula might have been invented.  Now can
  20. someone give me a convincing explanation for how someone came up with
  21.  
  22.  pi ~= 3*ln(640320)/sqrt(163)       [16 decimal places]
  23.  
  24. mentioned in the October notices of the AMS?)
  25.  
  26. >>Why not just 
  27. >>   pi/4=atan(1)? 
  28.  
  29. >On several different machines I've found that 2*atan(maxreal) gives
  30. >a more accurate value for pi than 4*atan(1).
  31.  
  32. This is presumably because a library routine probably calculates atan(x)
  33. where x>1 by  HALFPI - atan(1/x)  (where HALFPI is a stored constant),
  34. whereas it probably calculates atan(1) by using a modified form of the
  35. Taylor series.  In other words, by calculating atan(maxreal) you are fetching
  36. the pre-computed value of pi/2 whereas in asking for atan(1) you are
  37. calculating pi/4 as the sum of several terms.  Also, since atan(epsilon) is
  38. approximately equal to epsilon when epsilon is small, the error in the
  39. result after setting maxreal to 1eN is only 2e-N - which is too small to
  40. register (e.g.) in any 64-bit-float representation of pi if N is 20 or more.
  41.  
  42. Ian Collier
  43. Ian.Collier@prg.ox.ac.uk | imc@ecs.ox.ac.uk
  44.