Post Reply 
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
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
Find all posts by this user
Quote this message in a reply
Post Reply 


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 - Dieter - 01-12-2016 02:02 PM



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