home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!darwin.sura.net!wupost!gumby!destroyer!ncar!noao!amethyst!organpipe.uug.arizona.edu!news
- From: dave@cs.arizona.edu (Dave Schaumann)
- Newsgroups: comp.programming
- Subject: Re: Calculating a cube root
- Message-ID: <1992Jul21.210207.1552@organpipe.uug.arizona.edu>
- Date: 21 Jul 92 21:02:07 GMT
- References: <l624kmINN29e@girtab.usc.edu> <129360001@hpfcso.FC.HP.COM> <1992Jul20.123722.27958@cs.ruu.nl> <1992Jul20.160255.17562@organpipe.uug.arizona.edu> <1992Jul21.085023.11890@cs.ruu.nl>
- Sender: news@organpipe.uug.arizona.edu
- Reply-To: dave@cs.arizona.edu (Dave Schaumann)
- Organization: University of Arizona
- Lines: 40
- In-Reply-To: jeroen@cs.ruu.nl (Jeroen Fokker)
-
- In article <1992Jul21.085023.11890@cs.ruu.nl>, jeroen@cs (Jeroen Fokker) writes:
- >dave@cs.arizona.edu (Dave Schaumann) had some remarks about my
- >cuberoot-program.
- >
- >>> #define EPSILON 0.00001
- >
- >> which of course limits the accuracy quite severly.
- >
- >The nice thing about #defined constants is that you can
- >adapt them to your needs.
-
- Of course, making EPSILON smaller will also increase the inefficiency of
- your algorithm. (The point being, I suppose, that no such trade-off is
- required by using the library routines.)
-
- >>> return( a-b<EPSILON && b-a<EPSILON );
- >
- >> This expression will always yield 0.
- >
- >Nice try for an insult, but not justified.
-
- Mea culpa. After careful observation, I see that your code is correct
- (tho not at all clear, IMHO). I would've greatly preferred
-
- #define abs(x) ((x) > 0 ? (x) : (-x))
-
- . . .
-
- return abs(a-b) < EPSILON ;
-
- >Speaking of correctness: try and calculate cubert(0.0)
- >using exp(log(x)/3.0).
-
- No thanks; I'm driving.
-
- --
- You unlock this door with the key of imagination. Beyond it is another
- dimension: a dimension if sound, a dimension of sight, a dimension of mind.
- You're moving into a land of both shadow and substance, of things and ideas.
- You've just crossed over into... the Twilight Zone.
-