Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!psuvax1!wuarchive!m.cs.uiuc.edu!joshi From: joshi@m.cs.uiuc.edu (Anil Joshi) Newsgroups: comp.lang.c Subject: Re: Log Library - How is it done in the library code? Keywords: log, library, series expansion Message-ID: <1991Mar12.014416.4289@m.cs.uiuc.edu> Date: 12 Mar 91 01:44:16 GMT References: <1991Mar11.022141.12068@m.cs.uiuc.edu> <15438@smoke.brl.mil> Organization: University of Illinois, Dept. of Comp. Sci., Urbana, IL Lines: 37 gwyn@smoke.brl.mil (Doug Gwyn) writes: >In article <1991Mar11.022141.12068@m.cs.uiuc.edu> joshi@m.cs.uiuc.edu (Anil Joshi) writes: >>I need to compute natural log for some numbers. I could use the c math.h library >>routine but I do not want the accuracy of the library routine. A crude >>approximation would suffice. Does anyone know how this is done in the c library >>routine? Is it possible to get the source code? >I don't understand why you don't simply use the C library log() function. >It should be reliable and efficient, so what would you gain by trying to >roll your own cruder version? I do not want the accuracy that might have been provided in the c library log(). It might be spending more time than necessary to calculate more accurately than I want it to be. The suggestions I got were: 1. Use Taylor Series. 2. Use Chyebyshev (sp?) polynomials 3. Use a table and interpolate. 4. Harmonic Series (this is my/my advisor's idea). I am not sure wether this would give results. 5. Somebody mentioned Dr.Dobbs Journal (Old, old issue) which gave code for 2 above. I am tending towards Idea 3, which seems to be fastest (my intuition). If I get any more suggestions, I'll post. Thanks everybody. Anil -- "Come the (computer) revolution, all persons found guilty of such criminal behaviour will be summarily executed, and their programs won't be!" - Press, Flannerty, Teukolsky and Vetterling