Post Reply 
Natural logarithm of 2 [HP-15C/HP-42S/Free42 & others]
10-12-2019, 04:18 PM (This post was last modified: 10-12-2019 04:19 PM by Gerson W. Barbosa.)
Post: #6
RE: Natural logarithm of 2 [HP-15C/HP-42S/Free42 & others]
(10-12-2019 11:04 AM)JMBaillard Wrote:  Hi !
Here is an HP-41 version:

01 LBL "LN2"
02 1
03 STO 00
04 2
05 STO 01
06 1/X
07 LBL 01
08 RCL 01
09 RCL 00
10 ST/ Y
11 1
12 +
13 STO 00
14 *
15 ST+ X
16 STO 01
17 1/X
18 +
19 X#Y?
20 GTO 01
21 END


(32 bytes)

It takes about 13 seconds with an HP-41 which gives 0.6931471808
So, an error of about 2 E-10 ( and perhaps a little too slow )
But with free42, the result 6,931471805599453094172321214581773e-1
is returned in much less than 1 second.

Hello, Jean-Marc,

Very concise program!

Here is another one, based on formula #20 at MathWorld (not what I’ve been using).

01 LBL "LN2"
02 0
03 3
04 STO 00
05 9
06 STO 01
07 LBL 00
08 *
09 1/X
10 +
11 2
12 ST+ 00
13 RDN
14 9
15 ST* 01
16 RDN
17 RCL 00
18 RCL 01
19 DSE T
20 GTO 00
21 2
22 ST* T
23 R^
24 +
25 3
26 /
27 END


9 XEQ LN2 -> 0.6931471807 (6.5 seconds on my HP-41C)

I am sure this can be optimized for size, but the lack of recall arithmetic is always a problem to me.

Best regards,

Gerson.
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Natural logarithm of 2 [HP-15C/HP-42S/Free42 & others] - Gerson W. Barbosa - 10-12-2019 04:18 PM



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