Post Reply 
Accuracy of HP Financial Calculators - Canadian mortgage
04-08-2014, 08:19 PM (This post was last modified: 04-09-2014 12:19 PM by Dieter.)
Post: #21
RE: Accuracy of HP Financial Calculators - Canadian mortgage
(04-07-2014 11:16 PM)Thomas Klemm Wrote:  But it's still good to know when you better avoid it.

OK, you could check whether (1+x) – 1 equals x and then evaluate ln(1+x) literally (1 + LN). But is it worth the effort? Without a dedicated function the last digit cannot be trusted anyway.

(04-07-2014 11:16 PM)Thomas Klemm Wrote:  OTOH: how does your method compare to HP's trick to calculate \(log(1+x)\) for small values?

The artanh-method was not intended to replace HP's method. It's an alternative way that requires only two stack levels. But anyway I did a quick test. I used the 34s emulator with a short program that rounds every intermediate result to a given number of significant digits and compares the approximate result with that of the the exact ln1+x function. This was done for 100.000 random numbers between 1 and 1E-15, using x = 10^(–15 · ran#). The seed for the RNG was always the same.

Here are the results:

10 digit working precision:
HP method: error within –6 ... +9 ULP
artanh method: error within –6 ... +6 ULP

12 digit working precision:
HP method: error within –6 ... +9 ULP
artanh method: error within –7 ... +8 ULP

16 digit working precision:
HP method: error within –5 ... +8 ULP
artanh method: error within –4 ... +4 ULP

So the artanh method seems to perform on par or even slightly better. On the other hand the HP method also works for large x where the artanh method fails (argument rounds to 1).

Dieter
Find all posts by this user
Quote this message in a reply
04-09-2014, 01:49 PM
Post: #22
RE: Accuracy of HP Financial Calculators - Canadian mortgage
(04-08-2014 08:19 PM)Dieter Wrote:  Here are the results:

10 digit working precision:
HP method: error within –6 ... +9 ULP
artanh method: error within –6 ... +6 ULP

12 digit working precision:
HP method: error within –6 ... +9 ULP
artanh method: error within –7 ... +8 ULP

16 digit working precision:
HP method: error within –5 ... +8 ULP
artanh method: error within –4 ... +4 ULP

I now found another method of evaluating ln(1+x) using the inverse hyperbolic sine, cf. this message.

Here is how it performs using the same test as above:

10 digit working precision:
arsinh method: error within –5 ... +4 ULP

12 digit working precision:
arsinh method: error within –4 ... +5 ULP

16 digit working precision:
arsinh method: error within –6 ... +5 ULP

So the arsinh method seems even better than the previous one. It also does not have problems with very large x, so that it is my preferred method now.

Dieter
Find all posts by this user
Quote this message in a reply
04-09-2014, 04:17 PM
Post: #23
RE: Accuracy of HP Financial Calculators - Canadian mortgage
(04-09-2014 01:49 PM)Dieter Wrote:  So the arsinh method seems even better than the previous one. It also does not have problems with very large x, so that it is my preferred method now.

Mine also!
Jeff Kearns
Find all posts by this user
Quote this message in a reply
04-09-2014, 06:59 PM
Post: #24
RE: Accuracy of HP Financial Calculators - Canadian mortgage
(04-09-2014 04:17 PM)Jeff_Kearns Wrote:  Mine also!

I just started a new thread that suggests another method with significantly better accuracy. ;-)

Dieter
Find all posts by this user
Quote this message in a reply
Post Reply 




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