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