Post Reply 
Small RPN exponential routine
01-04-2015, 01:14 AM (This post was last modified: 01-04-2015 02:06 AM by Gerson W. Barbosa.)
Post: #6
RE: Small RPN exponential routine
(01-03-2015 08:33 PM)Thomas Klemm Wrote:  
(01-03-2015 05:31 PM)Gerson W. Barbosa Wrote:  There surely is a more obvious method which I cannot see, so I won't bother optimizing it.

Using the same method but a little shorter:
Code:
00 { 24-Byte Prgm }
01>LBL "LX"
02 1
03 STO- ST Z
04 CLX
05>LBL 00
06 RCL Y
07 1/X
08 X<>Y
09 -
10 RCL× ST Z
11 DSE ST Y
12 GTO 00
13 END

Cheers
Thomas

A "little shorter"? I appreciate your sense of humor :-)

Definitely I should have made a second attempt in the first place. I've rewritten it looking at the expression with five terms of my example and obtained the same number of steps, but four bytes longer. Despite having one extra step inside the loop, yours appears to be a little faster (only one measurement before I got "Memory Clear" due to flat batteries).

Cheers,

Gerson.


ln(0.52) = -(0.48*(1 + 0.48*(1/2 + 0.48*(1/3 + 0.48*(1/4 + 0.48/5)))))

Code:

00 { 28-Byte Prgm }
01>LBL "LX"
02 1
03 RCL- ST Z
04 0
05>LBL 00
06 1
07 RCL÷ ST T
08 +
09 RCL× ST Y
10 DSE ST Z
11 GTO 00
12 +/-
13 .END.


P.S.: One step less, but still one byte longer, using one of your ideas:

Code:

00 { 25-Byte Prgm }
01>LBL "LX"
02 1
03 RCL- ST Z
04 0
05>LBL 00
06 RCL ST Z
07 1/X
08 -
09 RCL× ST Y
10 DSE ST Z
11 GTO 00
12 END
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Small RPN exponential routine - Gerson W. Barbosa - 01-04-2015 01:14 AM
RE: Small RPN exponential routine - Namir - 01-21-2015, 12:34 AM
RE: Small RPN exponential routine - Namir - 01-20-2015, 09:24 PM
RE: Small RPN exponential routine - Namir - 01-22-2015, 08:41 AM
RE: Small RPN exponential routine - Namir - 01-23-2015, 05:11 PM



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