Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!uupsi!sunic!sics.se!fuug!news.funet.fi!tukki.jyu.fi!jadbalja!tt From: tt@jadbalja.jyu.fi (Tapani Tarvainen) Newsgroups: comp.sys.handhelds Subject: Re: Accuracy w/ ln and log Message-ID: Date: 5 Jun 91 13:34:12 GMT References: <1991May30.120658.3590@panix.uucp> <3630@charon.cwi.nl> Sender: news@jyu.fi (News articles) Organization: University of Jyvaskyla Lines: 62 In-Reply-To: jurjen@cwi.nl's message of 4 Jun 91 09: 10:59 GMT Originator: tt@jadbalja.jyu.fi Nntp-Posting-Host: jadbalja.jyu.fi In article <3630@charon.cwi.nl> jurjen@cwi.nl (Jurjen NE Bos) writes: >marek@ifi.uio.no (Marek Vokac) writes: >>I compared the results from LOG/LOG and LN/LN calculations with those >>produced by Mathematica, and it seems LN is _marginally_ more >>accurate, the results differed +/- 1 in the last decimal digit >>calculated. >>The difference is small enough to be insignificant in most >>applications; but it does seem to indicate the LN is used for LOG and >>not the other way round. >This is unfortunately not true: >As I said in my previous posting, both LN and LOG are based on a 15 digit >logarithm function. Roundoff from the conversion is not visible at all on the >user level; both functions are almost always correctly rounded to the last >decimal. >(I think the answers are even *always* correct, but I am not sure; Bill?) What isn't true? That LN is used for LOG or that LN/LN is more accurate than LOG/LOG? I'm fairly sure that LN is used in computing LOG (because it's easier and because that's the way HP71B does) -- but without rounding the intermediate result, i.e., it computes LN with 15 digits, divides that with 15-digit LN(10), and rounds only then. Consequently the difference in accuracy between LN and LOG is negligible for all practical purposes, but if there is a difference, LN is better. Considering how the LN is computed, I'd guess the result is not quite always correctly rounded, but quite likely the error is always less than 0.51 units in the least significant digit or something like that. And since there is one extra step in LOG, it would be slightly less accurate (maybe as much off as 0.52 units in LSD!?). (Might be fun to figure out the maximum errors exactly. Perhaps someone at HP already has?) However, even if both LN and LOG were always correctly rounded, LN/LN and LOG/LOG would still occasionally give inaccurate results (well, at least incorrectly rounded). And in worst case analysis the small difference in accuracy would be doubled (although in the average it would probably vanish). This could explain the results as compared to Mathematica. (The "wobbling precision" effect is also possible, but note that it can work either way, depending on the range of numbers used.) (A side note: F1 and F2 being equally accurate would not automatically imply that F3 could be computed using either with equally good results, although in this case it apparently is so. Consider, e.g., computing hyperbolics or compound interest with LN and EXP or with LNP1 and EXPM.) At this point I should stress that the differences I've been talking about are so small that even detecting them is hard, let alone finding a case where they matter in practice. Nonetheless I'd recommend LN/LN over LOG/LOG, but mainly for another reason: it is faster. (Prediction based on the theory that LOG is computed with LN -- and confirmed by an experiment I just did: the difference is some 2 ms per log.) -- Tapani Tarvainen (tarvaine@jyu.fi, tarvainen@finjyu.bitnet)