Post Reply 
Programming exercise (RPL/RPN) - Reciprocal Fibonacci Constant
02-25-2017, 02:49 PM (This post was last modified: 02-25-2017 02:55 PM by Gerson W. Barbosa.)
Post: #51
RE: Programming exercise (RPL/RPN) - Reciprocal Fibonacci Constant
If our only goal is just to compute the constant, the following does it faster by summing up about four times as less terms and adding a correction term:

HP-42S
Code:

00 { 39-Byte Prgm }
01>LBL "RFC"
02 STO+ ST X
03 0
04 RCL ST X
05 1
06>LBL 00
07 1/X
08 STO+ ST Y
09 X<> ST L
10 STO+ ST Z
11 X<> ST Z
12 DSE ST T
13 GTO 00
14 STO- ST Z
15 STO+ ST X
16 1/X
17 RCL+ ST Z
18 1/X
19 -
20 .END.

6 XEQ RFC --> 3.35988566624 ( 1.4 s )

HP-42S code on wp34s:

18 A --> 18 XEQ RFC --> 3.359885666243177553172011302918926 ( 0.2 s, timed with TICKS )


HP-41
Code:

01>LBL 'RFC
02 STO+ X
03 0
04 RCL X
05 1
06>LBL 00
07 +
08 LASTX
09 1/X
10 STO+ Z
11 X<> L
12 X<>Y
13 DSE T
14 GTO 00
15 ST- Y
16 ST+ X
17 1/X
18 +
19 1/X
20 -
21 .END.

7 XEQ ALPHA RFC ALPHA --> 3.359885666 ( 3.7 s )


HP 50g
Code:

%%HP: T(3)A(D)F(.);
\<< DUP + 0. 1. DUP2
ROT 5. ROLL
  START PICK3 + SWAP 
OVER INV + ROT
  NEXT ROT OVER + DUP
+ INV - INV +
\>>

<< 6 RFC >> TEVAL --> 3.35988566624 ; s: .0946

Notes:

1) non-optimized codes;
2) no proof why this works.
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Programming exercise (RPL/RPN) - Reciprocal Fibonacci Constant - Gerson W. Barbosa - 02-25-2017 02:49 PM



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