home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / programm / 2039 < prev    next >
Encoding:
Internet Message Format  |  1992-07-21  |  1.9 KB

  1. Path: sparky!uunet!darwin.sura.net!wupost!gumby!destroyer!ncar!noao!amethyst!organpipe.uug.arizona.edu!news
  2. From: dave@cs.arizona.edu (Dave Schaumann)
  3. Newsgroups: comp.programming
  4. Subject: Re: Calculating a cube root
  5. Message-ID: <1992Jul21.210207.1552@organpipe.uug.arizona.edu>
  6. Date: 21 Jul 92 21:02:07 GMT
  7. 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>
  8. Sender: news@organpipe.uug.arizona.edu
  9. Reply-To: dave@cs.arizona.edu (Dave Schaumann)
  10. Organization: University of Arizona
  11. Lines: 40
  12. In-Reply-To: jeroen@cs.ruu.nl (Jeroen Fokker)
  13.  
  14. In article <1992Jul21.085023.11890@cs.ruu.nl>, jeroen@cs (Jeroen Fokker) writes:
  15. >dave@cs.arizona.edu (Dave Schaumann) had some remarks about my
  16. >cuberoot-program.
  17. >
  18. >>> #define EPSILON 0.00001
  19. >
  20. >>  which of course limits the accuracy quite severly.
  21. >
  22. >The nice thing about #defined constants is that you can
  23. >adapt them to your needs. 
  24.  
  25. Of course, making EPSILON smaller will also increase the inefficiency of
  26. your algorithm.  (The point being, I suppose, that no such trade-off is
  27. required by using the library routines.)
  28.  
  29. >>> return( a-b<EPSILON && b-a<EPSILON );
  30. >
  31. >> This expression will always yield 0.
  32. >
  33. >Nice try for an insult, but not justified.
  34.  
  35. Mea culpa.  After careful observation, I see that your code is correct
  36. (tho not at all clear, IMHO).  I would've greatly preferred
  37.  
  38.     #define abs(x) ((x) > 0 ? (x) : (-x))
  39.  
  40.       . . .
  41.  
  42.     return abs(a-b) < EPSILON ;
  43.  
  44. >Speaking of correctness: try and calculate cubert(0.0)
  45. >using exp(log(x)/3.0).
  46.  
  47. No thanks; I'm driving.
  48.  
  49. -- 
  50. You unlock this door with the key of imagination.  Beyond it is another
  51. dimension: a dimension if sound, a dimension of sight, a dimension of mind.
  52. You're moving into a land of both shadow and substance, of things and ideas.
  53. You've just crossed over into... the Twilight Zone.
  54.