news@midway.uchicago.edu (News Administrator) (03/21/91)
A quick question... TP has a natural log function. I need a LOGn(x) function that does not need a table lookup, and is highly accurate. Is there a quick algorithm or a real math library avalable? -dm From: daryl@zaphod.uchicago.edu (Daryl McLaurine) Path: zaphod!daryl ^ <{[-]}>--------------------------------------------------------------------- V Daryl McLaurine, Systems Consultant / Associate | University of Chicago Mathematics Dept. / Friedrich, Klatt & Associates | daryl@zaphod.UChicago.EDU(128.135.72.61)/ 1621 E. 55th St Chicago 60615 | {...}!gargoyle!tank!zaphod!daryl / 1-312-288-4849 ==\*/===================== Standard Disclaimers apply ======================
forbesmc@matai.vuw.ac.nz (03/21/91)
In article <1991Mar20.220800.24027@midway.uchicago.edu>, news@midway.uchicago.edu (News Administrator) writes: > A quick question... > TP has a natural log function. I need a LOGn(x) function that > does not need a table lookup, and is highly accurate. Is there a quick > algorithm or a real math library avalable? > -dm > From: daryl@zaphod.uchicago.edu (Daryl McLaurine) > Path: zaphod!daryl > 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. +------------------------------------------------------------------+ | 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 | +------------------------------------------------------------------+
daryl@zaphod.uchicago.edu (Daryl McLaurine) (03/21/91)
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. > >+------------------------------------------------------------------+ >| 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 | >+------------------------------------------------------------------+ 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 ^ <{[-]}>--------------------------------------------------------------------- V Daryl McLaurine, Systems Consultant / Associate | University of Chicago Mathematics Dept. / Friedrich, Klatt & Associates | daryl@zaphod.UChicago.EDU(128.135.72.61)/ 1621 E. 55th St Chicago 60615 | {...}!gargoyle!tank!zaphod!daryl / 1-312-288-4849 ==\*/===================== Standard Disclaimers apply ======================
forbesmc@matai.vuw.ac.nz (03/22/91)
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 | +------------------------------------------------------------------+
news@midway.uchicago.edu (News Administrator) (03/22/91)
I should kick myself for not realizing this... This solution saves me a Ln() call, Thanks to raymond@math.berkeley.edu (Raymond Chen): (Ps. TP does calculate Ln by Chebyshev (actualy, the *chip* is ;-}) From: daryl@zaphod.uchicago.edu (Daryl McLaurine) Path: zaphod!daryl var ln10,whatIsIt: real; function log10(x: real): real; begin log10 := ln(x)/ln10 end; { main program } begin ln10 := ln(10); { other stuff } whatIsIt := Log10(1001001); end. All praise the NET...All Hail the NET... ^ <{[-]}>--------------------------------------------------------------------- V Daryl McLaurine, Systems Consultant / Associate | University of Chicago Mathematics Dept. / Friedrich, Klatt & Associates | daryl@zaphod.UChicago.EDU(128.135.72.61)/ 1621 E. 55th St Chicago 60615 | {...}!gargoyle!tank!zaphod!daryl / 1-312-288-4849 ==\*/===================== Standard Disclaimers apply ======================
greg@athena.cs.uga.edu (GOD (Albert Ross)) (03/22/91)
In article <1991Mar21.122959.346@matai.vuw.ac.nz> forbesmc@matai.vuw.ac.nz writes: >In article <1991Mar20.220800.24027@midway.uchicago.edu>, news@midway.uchicago.edu (News Administrator) writes: >> A quick question... >> TP has a natural log function. I need a LOGn(x) function that >> does not need a table lookup, and is highly accurate. Is there a quick >> algorithm or a real math library avalable? >> -dm >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. Unless I misunderstood the question, the formula should read: LOGn(x) = LOG(x) / LOG(n) where the right hand side LOGs are base 10. (this formula usually spawns from an equation similiar to y=2^x where x is your base. Take base 10 of each side and solve.) Hope this helps.... greg@athena.cs.uga.edu ALBATROSS rules! University of Georgia ----------------------------------------------------------------------------- One can't proceed from the informal to the formal by formal means. --
bobb@vice.ICO.TEK.COM (Bob Beauchaine) (03/23/91)
>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. I'm gonna check on TP using a table lookup for the LN() function, but that doesn't seem exactly viable with a range of possible values like the LN() function can handle... As for making two passes to the LN() function, sounds like you need to brush up on your basic CS coursework. The LN(10) function could be precomputed, or better yet, you could declare the value as a constant at the top of your program. I'd be surprised if you could outsmart the guys at Borland who wrote the Math package, which has been an industry leader in speed for quite some time now. /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\ Bob Beauchaine bobb@vice.ICO.TEK.COM C: The language that combines the power of assembly language with the flexibility of assembly language.
dmurdoch@watstat.waterloo.edu (Duncan Murdoch) (03/25/91)
In article <7152@vice.ICO.TEK.COM> bobb@vice.ICO.TEK.COM (Bob Beauchaine) writes: > I'd be surprised if you could > outsmart the guys at Borland who wrote the Math package, which has > been an industry leader in speed for quite some time now. Do you think that Borland wrote the math routines? There's some circumstantial evidence that they didn't write the coprocessor emulator routines: the source code isn't available with the run-time library. This carries over to some other math routines, since LN (at least the $N+ version) is calculated using one of the INT 3E calls. Not conclusive by any means, but it has the signs of being code licensed from someone else. Duncan Murdoch dmurdoch@watstat.waterloo.edu