Calculating e^x-1 on classic HPs
|
01-15-2016, 06:46 PM
(This post was last modified: 01-15-2016 07:13 PM by Dieter.)
Post: #31
|
|||
|
|||
RE: Calculating e^x-1 on classic HPs
(01-15-2016 06:07 PM)Gerson W. Barbosa Wrote: I'm currently running this on an ordinary 12C and Dieter's program on a 12C+, so I cannot compare speeds, but Dieter's should be slightly faster because it requires no tests. Hm, seems you forgot an essential test here: if x is so small that ex rounds to 1 (here –5 E–11 < x < 5 E–10), the term (u–1)/ln u becomes 0/0... #-) In such a case the program should return x. This additional test would also handle the x=0 case that's now tested in the first line. BTW, W. Kahan's method is supposed to calculate (ex–1)/x. Even if this quotient is evaluated exactly, i.e. for small x very close to 1, there is always a potential error of half an ULP or 5 E–10 on a ten-digit device. This translates to a possible error of up to 5 ULP in the final result, i.e. after the multiplication with x. Example: x=9 E–9. The exact quotient is 1,000000045... which on a ten-digit calculator is rounded to 1,000000005. This indeed is the correctly rounded ten-digit value. But the final result is returned as 9,000000045 E–9 instead of 9,0000000405000...E–9, i.e. there is an error of +4,5 ULP. Dieter |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 12 Guest(s)