Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!samsung!spool.mu.edu!uunet!comp.vuw.ac.nz!matai.vuw.ac.nz!forbesmc From: forbesmc@matai.vuw.ac.nz Newsgroups: comp.lang.pascal Subject: Re: Real LOGn functions in TP 5.5 needed Message-ID: <1991Mar22.092631.347@matai.vuw.ac.nz> Date: 21 Mar 91 21:26:31 GMT References: <1991Mar20.145939.83@gnv.ifas.ufl.edu> <1991Mar20.220800.24027@midway.uchicago.edu> <1991Mar21.122959.346@matai.vuw.ac.nz> <1991Mar21.042630.6174@midway.uchicago.edu> Organization: Victoria University of Wellington, NZ Lines: 31 In article <1991Mar21.042630.6174@midway.uchicago.edu>, daryl@zaphod.uchicago.edu (Daryl McLaurine) writes: > In article <1991Mar21.122959.346@matai.vuw.ac.nz> forbesmc@matai.vuw.ac.nz writes: >>Look up the required function in any standard maths book or 'log tables' - >>I think it goes something like this ; >> >> LOGn(x) = LN(x) / LN(n) >> >>where LN is the natural log function and n is the log base required, >>x is the number whose log you require. >> > This is the function I have been using, but I am getting some unexpected > results. (Perhaps I mis-remebered the formula?). Also, I am doing real-time > analysis, and I thought that TP used a table for LN(), and making 2 passes > to that function would be murder (Not using a '387...I know...I know...). > I want a foolproof LOGn function that is fast, compact, and isn't dependent > on the LN() function. > -dm Several points : if you are going to use the same log base (ie n) all the time in your program, calculate 1 / LN(n) ONCE and store it in a variable. Secondly, all the functions I know for LN (or LOG) are infinite series expansions of various convergence rates so if TP does use a lookup table, then it will always be faster than any expansion you may use - even if written in machine code. +------------------------------------------------------------------+ | I'm a toxophilite, | Murray Forbes, | | so what's your problem? | Physics Department, | |----------------------------| Victoria University of Wellington, | | standard disclaimer : | New Zealand. | | all opinions here are mine | FORBESMC@MATAI.VUW.AC.NZ | +------------------------------------------------------------------+