Small RPN exponential routine
01-03-2015, 05:31 PM
Post: #4
 Gerson W. Barbosa Senior Member Posts: 1,429 Joined: Dec 2013
RE: Small RPN exponential routine
This is my first attempt at natural logarithm using

ln(1 + x) = x - x^2/2 + x^3/3 - x^4/4 + x^5/5 -+ ..., x < 1

There surely is a more obvious method which I cannot see, so I won't bother optimizing it. I am primarily interested in implementing these functions on TurboBCD, but rather than trying to reinvent the wheel I'll look for a ready-made solution.

Code:
 00 { 43-Byte Prgm } 01>LBL "LX" 02 NOT 03 +/- 04 LASTX 05 1 06 RCL- ST T 07 RCL÷ ST Z 08 LASTX 09 1 10>LBL 00 11 RCL÷ ST T 12 RCL+ ST Z 13 RCL× ST Y 14 STO ST Z 15 Rv 16 1 17 DSE ST T 18 GTO 00 19 RCL ST Z 20 +/- 21 .END.

0.52 ENTER 35 --> -6.53926467407e-1

There are two problems, though:

1) The series does not converge for arguments greater than 1;

2) More and more terms are required as arguments approach to zero. For instance, ln(0.052) will require 525 terms for 12-digit accuracy.

In these cases, conversions to and from decimal logarithms will help:

ln(0.52) = -6.53926467407e-1

2.30258509299 / --> -2.83996656366e-1

1 - 2.30258509299 * --> -2.95651156041 = ln(0.052)

ln(0.52) = -6.53926467407e-1

2.30258509299 / --> -2.83996656366e-1

1 + 2.30258509299 * --> 1.64865862558 = ln(5.2)

ln(0.52) = -6.53926467407e-1

2.30258509299 / --> -2.83996656366e-1

2 + 2.30258509299 * --> 3.95124371856 = ln(52)

ln(0.52) = -6.53926467407e-1

2.30258509299 / --> -2.83996656366e-1

3 + 2.30258509299 * --> 6.25382881155 = ln(520)
 « 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)