Calculating e^x-1 on classic HPs
01-12-2016, 02:02 PM (This post was last modified: 01-12-2016 03:06 PM by Dieter.)
Post: #4
 Dieter Senior Member Posts: 2,397 Joined: Dec 2013
RE: Calculating e^x-1 on classic HPs
(01-12-2016 05:13 AM)Claudio L. Wrote:  I just checked at 2000 digits precision and the result was good.

Fine. My results on 10- and 12-digit calculators did not show any results with larger errors than ±1 ULP, mostly because of different rounding. The vast majoriy was dead on.

(01-12-2016 05:13 AM)Claudio L. Wrote:  I always thought e^x-1 was the easiest of all to implement, since the power series expansion at 0 starts with a 1. All you have to do is skip the first term and with relatively few terms in the summation you get the answer. No need to worry about argument reduction because the whole point is to use it around zero.

Right. This is true if you want to evaluate ex–1 in terms of simple arithmetics, i.e. without the use of other transcendental functions. Which may be a good idea on a computer, but not on a calculator where speed and memory are much more limited.

(01-12-2016 05:13 AM)Claudio L. Wrote:  Question is: would a program computing terms of the power series in a loop be faster?

I'd say this depends on the implementation of the required exponential and logarithm functions. On most common processors this is done in hardware (the FPU provides these functions). On the required interval (ln 0,9 < x < ln 2) and 15-16 digit accuracy a continued fraction method with 7 terms or a 16-term series expansion will do.

Now, how much faster are addition, multiplication and division compared to exp and log? The continued fraction method requires 14 divisions, 7 additions and 7 subtractions, plus a bit overhead for the range check and the loop counter. I suppose this is still faster than using exp and log. On a computer, that is.

For the record, here is a VBA implementation using the continued fraction method and hard-coded seven terms (k = 13, 11, 9, 7, 5, 3, 1):

Code:
Function expm1cf(x) If (x < -0.1053605156578263) Or (x > 0.6931471805599453) Then    expm1cf = Exp(x) - 1 Else    s = 0    For k = 13 To 1 Step -2        s = x / (k - x / (s + 2))    Next k    expm1cf = s End If End Function

Dieter
 « Next Oldest | Next Newest »

 Messages In This Thread Calculating e^x-1 on classic HPs - Dieter - 01-11-2016, 10:20 PM RE: Calculating e^x-1 on classic HPs - Thomas Klemm - 01-12-2016, 01:41 AM RE: Calculating e^x-1 on classic HPs - Dieter - 01-12-2016, 06:12 PM RE: Calculating e^x-1 on classic HPs - Claudio L. - 01-12-2016, 05:13 AM RE: Calculating e^x-1 on classic HPs - Dieter - 01-12-2016 02:02 PM RE: Calculating e^x-1 on classic HPs - ElectroDuende - 01-12-2016, 03:34 PM RE: Calculating e^x-1 on classic HPs - Dieter - 01-12-2016, 06:30 PM RE: Calculating e^x-1 on classic HPs - Claudio L. - 01-12-2016, 09:44 PM RE: Calculating e^x-1 on classic HPs - Dieter - 01-12-2016, 08:16 PM RE: Calculating e^x-1 on classic HPs - Gerson W. Barbosa - 01-13-2016, 03:46 PM RE: Calculating e^x-1 on classic HPs - Dieter - 01-13-2016, 06:43 PM RE: Calculating e^x-1 on classic HPs - Gerson W. Barbosa - 01-14-2016, 02:47 AM RE: Calculating e^x-1 on classic HPs - Dieter - 01-14-2016, 01:44 PM RE: Calculating e^x-1 on classic HPs - Gerson W. Barbosa - 01-14-2016, 03:30 PM RE: Calculating e^x-1 on classic HPs - Gerson W. Barbosa - 01-14-2016, 06:50 PM RE: Calculating e^x-1 on classic HPs - Dieter - 01-14-2016, 07:38 PM RE: Calculating e^x-1 on classic HPs - Gerson W. Barbosa - 01-14-2016, 07:50 PM RE: Calculating e^x-1 on classic HPs - Albert Chan - 02-02-2019, 07:32 PM RE: Calculating e^x-1 on classic HPs - Dieter - 02-03-2019, 06:46 PM RE: Calculating e^x-1 on classic HPs - Paul Dale - 01-14-2016, 07:20 AM RE: Calculating e^x-1 on classic HPs - Dieter - 01-14-2016, 01:48 PM RE: Calculating e^x-1 on classic HPs - emece67 - 01-14-2016, 03:55 PM RE: Calculating e^x-1 on classic HPs - Dieter - 01-14-2016, 06:42 PM RE: Calculating e^x-1 on classic HPs - emece67 - 01-14-2016, 09:14 PM RE: Calculating e^x-1 on classic HPs - Dieter - 01-14-2016, 09:55 PM RE: Calculating e^x-1 on classic HPs - Paul Dale - 01-15-2016, 01:19 AM RE: Calculating e^x-1 on classic HPs - Dieter - 01-15-2016, 02:00 PM RE: Calculating e^x-1 on classic HPs - matthiaspaul - 01-15-2016, 10:10 AM RE: Calculating e^x-1 on classic HPs - Gerson W. Barbosa - 01-15-2016, 06:07 PM RE: Calculating e^x-1 on classic HPs - Dieter - 01-15-2016, 06:46 PM RE: Calculating e^x-1 on classic HPs - Gerson W. Barbosa - 01-15-2016, 10:45 PM RE: Calculating e^x-1 on classic HPs - Dieter - 01-16-2016, 08:19 AM RE: Calculating e^x-1 on classic HPs - Gerson W. Barbosa - 01-16-2016, 12:40 PM RE: Calculating e^x-1 on classic HPs - Dieter - 01-16-2016, 01:32 PM RE: Calculating e^x-1 on classic HPs - Albert Chan - 02-02-2019, 07:22 PM RE: Calculating e^x-1 on classic HPs - Paul Dale - 01-14-2016, 09:22 PM RE: Calculating e^x-1 on classic HPs - Dieter - 01-14-2016, 09:49 PM RE: Calculating e^x-1 on classic HPs - Paul Dale - 01-15-2016, 01:15 AM RE: Calculating e^x-1 on classic HPs - Albert Chan - 02-03-2019, 08:28 PM RE: Calculating e^x-1 on classic HPs - Albert Chan - 02-04-2019, 07:28 PM RE: Calculating e^x-1 on classic HPs - Dieter - 02-04-2019, 07:59 PM

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