Path: utzoo!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!sdd.hp.com!elroy.jpl.nasa.gov!ncar!noao!amethyst!arizona!dave From: dave@cs.arizona.edu (Dave P. Schaumann) Newsgroups: comp.lang.c Subject: Re: Log Library - How is it done in the library code? Keywords: log, library, series expansion Message-ID: <1119@caslon.cs.arizona.edu> Date: 11 Mar 91 02:55:57 GMT References: <1991Mar11.022141.12068@m.cs.uiuc.edu> Organization: U of Arizona CS Dept, Tucson Lines: 23 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 outine 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? Trancendental functions are generally modeled with a Taylor-series expansion. (Check your favorite calculus books for what a Taylor series is, and your favorite numerical analysis book on how to get the best (ie most accurate) results). However, you might also consider using a table, and interpolating the intermediate values. Depending on the expected range of your arguments, and the required accuracy of your result, this could be an effective (and quick) method of gaining the results. Of course, you would still have to initialize the table at the start of the program... (yikes! shades of another thread creeping in -- film at 11). But if you're calling the function enough times that efficiency is a problem, this should be all right. -- Dave Schaumann | dave@cs.arizona.edu | Short .sig's rule!