Log Library - How is it done in the library code?

Anil Joshi joshi at m.cs.uiuc.edu
Tue Mar 12 11:44:16 AEST 1991


gwyn at smoke.brl.mil (Doug Gwyn) writes:

>In article <1991Mar11.022141.12068 at m.cs.uiuc.edu> joshi at 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



More information about the Comp.lang.c mailing list