Post Reply 
[VA] SRC #017 - April 1st, 2024 Spring Special
04-02-2024, 07:41 PM (This post was last modified: 04-02-2024 07:51 PM by J-F Garnier.)
Post: #4
RE: [VA] SRC #017 - April 1st, 2024 Spring Special
(04-01-2024 06:59 PM)Valentin Albillo Wrote:  I've always thought that the two logarithmic functions available in the 10-digit HP-15C (LOG and LN, base 10 and base e respectively) would have essentially the same accuracy overall, but lo and behold, I've found that LOG seems to be substantially more accurate in some cases than LN.

I remember this has been reported a few times in the past, maybe in connection with some solutions of your challenges/SRCs, but I can't find any reference again (can you?).

I've never been convinced by this effect (decimal LOG better than natural LN), because internally the decimal log is computed by:
LOG(x) = LN(x) / LN(10) , using 3 extra guard digits.
So there is no reason for LOG to be more accurate, on the contrary it may be marginally less accurate.

Let's see your 15c example (a 10-digit machine) - with minor corrections:

    N    LOG(5N)/LOG(5)  LN(5N)/LN(5)
 ---------------------------------
     2    2.000000001   2.000000001
     3    3             3.000000001
     4    4             4.000000001
     5    5.000000001   5.000000001
     6    6             6.000000002
     7    7             7.000000004
     8    8.000000001   8.000000002
     9    9             9.000000001
-----------------------------------
 Total ulps:    3           13
               { more than 400% larger error overall }

but let's try another number: 11N instead of 5N:

    N    LOG(11N)/LOG(11)  LN(11N)/LN(11)
 ---------------------------------
     2    2               2
     3    3               3
     4    4.000000001     4
     5    5.000000001     4.999999998
     6    6.000000001     6.000000001
     7    7.000000001     7
     8    8.000000001     7.999999998
     9    9.000000001     9.000000001
-----------------------------------
 Total ulps:    6           6
               { now similar error overall }

Doing now the same test on the 71B (a 12-digit machine):

    N    LGT(11N)/LGT(11)  LN(11N)/LN(11)
 ---------------------------------------
     2    2               2
     3    2.99999999999   3
     4    3.99999999999   4
     5    4.99999999999   5
     6    5.99999999999   6
     7    6.99999999999   7
     8    7.99999999999   8
     9    8.99999999999   9
----------------------------------------
  Total ulps:      7           0
               { here, much larger error overall for the decimal LOG case }

So it's clear to me that we can't say that the decimal LOG provides more accurate results than the natural LN, overall.

The question we may ask is: why does it seem that LOG is better for expressions using a certain number such as 5N, and why is LN better for other numbers such as 11N ?

J-F
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: [VA] SRC #017 - April 1st, 2024 Spring Special - J-F Garnier - 04-02-2024 07:41 PM



User(s) browsing this thread: 10 Guest(s)