home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #23 / NN_1992_23.iso / spool / sci / math / 13215 < prev    next >
Encoding:
Internet Message Format  |  1992-10-15  |  2.0 KB

  1. Path: sparky!uunet!mcsun!sun4nl!cwi.nl!dik
  2. From: dik@cwi.nl (Dik T. Winter)
  3. Newsgroups: sci.math
  4. Subject: Re: Calculating pi: help!
  5. Message-ID: <7684@charon.cwi.nl>
  6. Date: 15 Oct 92 02:09:57 GMT
  7. References: <Bw304E.LKu@mentor.cc.purdue.edu> <7557@charon.cwi.nl> <stephen.719088307@mont>
  8. Sender: news@cwi.nl
  9. Organization: CWI, Amsterdam
  10. Lines: 32
  11.  
  12. In article <stephen.719088307@mont> stephen@mont.cs.missouri.edu (Stephen Montgomery-Smith) writes:
  13.  > In <7557@charon.cwi.nl> dik@cwi.nl (Dik T. Winter) writes:
  14. The pi program I wrote with help of Jurjen Bos (who no longer works here).
  15.  > 
  16.  > I would be very interested to know how this program works.
  17.  > 
  18. I have gotten quite a few request about the program.  It is a bit
  19. convoluted indeed (I ought to have submitted it to the obfuscated
  20. C contest).  There are a few levels of obfuscation.  I will give
  21. a some hints, and when time comes I might even reveal the innards.
  22. (And to those who asked whether it is easy to get more digits by
  23. changing some constants, the answer is no.  Quite a bit of error
  24. analysis is needed.)
  25. So, some hints:
  26. 1.  Standard C obfuscation.  Mostly C beautifiers help, but here:
  27. 2.  After beautifying you still see nothing, except a loop with as
  28.     a body a loop with an empty body.  You have to move manually
  29.     from the for statement to the bodies of the loops to see some
  30.     structure, but:
  31. 3.  Some expressions are split over statements.  Strange enough the
  32.     main reason was not so much to obfuscate, but to get the program
  33.     as short as possible!  So look what those statements are doing
  34.     and rearrange as you would write the expressions, but:
  35. 4.  We are finally there.  What are all those calculations doing?
  36.     What is the relation between successive iterations?  And
  37.     finally:
  38. 5.  Think about the cheapest way to calculate the digits of 'e',
  39.     take some reference book (Abramovitz and Stegun is good enough),
  40.     and you are done.
  41. -- 
  42. dik t. winter, cwi, kruislaan 413, 1098 sj  amsterdam, nederland
  43. home: bovenover 215, 1025 jn  amsterdam, nederland; e-mail: dik@cwi.nl
  44.