Small RPN exponential routine
01-30-2019, 07:21 PM (This post was last modified: 01-30-2019 07:56 PM by Albert Chan.)
Post: #22
 Albert Chan Senior Member Posts: 1,659 Joined: Jul 2018
RE: Small RPN exponential routine
(01-27-2015 08:52 PM)Thomas Klemm Wrote:  At least in case of HP-calculators the CORDIC algorithm is used and not the Taylor Series of $$\ln(1+x)$$:

There is a faster series for ln(1+x), let y = x/(x+2), thus |y| < 1

ln(1+x)
= ln( ((x+2)+x) / ((x+2)-x) )
= ln( (1 + y) / (1 - y) )
= 2 * (y + y^3/3 + y^5/5 + y^7/7 + ...)

Using post 4 example of ln(0.52) :
For 12 digits accuracy, original ln(1+x) series required 33 terms, y transformed series only 12.

x = 0.52-1 = -0.48
y = -0.48/1.52 = -0.315789473684
ln(0.52) = -0.653926467406 (sumed 12 terms, upto y^21/21)

But, we can do better! |y| can be reduced furthur by scaling.
With 1+x between 1 and exp(1), worst case is if scaling does not help.
-> 1+x <= 2/(1+exp(-1)) = 1.46212
->|y| <= (exp(1)-1)/(3*exp(1)+1) = 0.187691
-> For 12 digits accuracy, term y^15/15 and beyond can be ignored.

Redo above with scaling, sum maximum of 6 terms:
Scaled argument = [1/1.46212, 1.46212) = [0.68394, 1.46212)

ln(0.52) = ln(0.52 * exp(1)) - 1 = ln(1.41350655080) - 1

x = 0.41350655080
y = x/(x+2) = 0.171330196167
ln(0.52) = 2*y + correction - 1 = 0.342660392334 + 0.00341314025930 - 1 = -0.653926467407
 « Next Oldest | Next Newest »

 Messages In This Thread Small RPN exponential routine - Gerson W. Barbosa - 01-02-2015, 10:25 PM RE: Small RPN exponential routine - Thomas Klemm - 01-03-2015, 08:42 AM RE: Small RPN exponential routine - Gerson W. Barbosa - 01-03-2015, 10:53 AM RE: Small RPN exponential routine - Gerson W. Barbosa - 01-03-2015, 05:31 PM RE: Small RPN exponential routine - Thomas Klemm - 01-03-2015, 08:33 PM RE: Small RPN exponential routine - Gerson W. Barbosa - 01-04-2015, 01:14 AM RE: Small RPN exponential routine - James Dunn - 01-20-2015, 07:57 PM RE: Small RPN exponential routine - Gerson W. Barbosa - 01-20-2015, 11:48 PM RE: Small RPN exponential routine - Namir - 01-21-2015, 12:34 AM RE: Small RPN exponential routine - Gerson W. Barbosa - 01-21-2015, 12:46 AM RE: Small RPN exponential routine - Namir - 01-20-2015, 09:24 PM RE: Small RPN exponential routine - Gerson W. Barbosa - 01-21-2015, 04:03 AM RE: Small RPN exponential routine - Thomas Klemm - 01-21-2015, 02:36 AM RE: Small RPN exponential routine - Thomas Klemm - 01-21-2015, 03:18 AM RE: Small RPN exponential routine - Gerson W. Barbosa - 01-21-2015, 03:48 AM RE: Small RPN exponential routine - Namir - 01-22-2015, 08:41 AM RE: Small RPN exponential routine - Gerson W. Barbosa - 01-22-2015, 06:59 PM RE: Small RPN exponential routine - Namir - 01-23-2015, 05:11 PM RE: Small RPN exponential routine - Gerson W. Barbosa - 01-23-2015, 06:48 PM RE: Small RPN exponential routine - Eddie W. Shore - 01-27-2015, 12:56 PM RE: Small RPN exponential routine - Thomas Klemm - 01-27-2015, 08:52 PM RE: Small RPN exponential routine - Albert Chan - 01-30-2019 07:21 PM

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