Re: HP prime: derivatives Message #9 Posted by Dieter on 29 Nov 2013, 3:14 p.m., in response to message #8 by Alberto Candel
EXPM1(x) is far more accurate as x approaches zero. Consider a small x-value like 1E-12. With 12-digit accuracy, EXP(x) is evaluated as excactly 1, so EXP(x)-1 becomes zero due to roundoff.
Here EXPM1(x) comes to rescue. It is evaluated differently so that the result is exact. Here are some results for 12 digit working precision:
x EXP(x) EXP(x)-1 EXPM1(x)
---------------------------------------------------------------
0,23 1,25860000993 0,25860000993 0,258600009929
0,0022 1,00220242178 2,20242178000 E-3 2,20242177564 E-3
1 E-5 1,00001000005 1,00000500000 E-5 1,00000500002 E-5
1/9 E-7 1,00000001111 1,11110000000 E-8 1,11111111728 E-8
1/7 E-9 1,00000000014 1,40000000000 E-10 1,42857142867 E-10
1/6 E-11 1,00000000000 0,00000000000 1,66666666667 E-12
So EXPM1(x) (and also its inverse function LNP1(x) = ln(1+x)) allow exact results where their conventional counterparts would return inexact or even useless results. There are extremely useful in many everyday applications.
Dieter
Edited: 29 Nov 2013, 3:17 p.m.
|