Post Reply 
Programming exercise (RPL/RPN) - Reciprocal Fibonacci Constant
02-19-2017, 04:04 PM
Post: #36
RE: Programming exercise (RPL/RPN) - Reciprocal Fibonacci Constant
Little OFF, but I wrote it also for my CASIO 50f. The original version was 12 steps and works as I want.

This new version is 19 steps and collects separately the numerator and denominator:

\(\frac{N_i}{D_i}=\frac{N_{i-1}}{D_{i-1}}+\frac{1}{F_i}=\frac{F_i · N_{i-1}+D_{i-1}}{D_{i-1} · F_i}\)

This version works well also, need only one improvement: a short fraction simplification routine - I hope I can fit it into the remained 10 steps, or I must to go to fx-3600P, where 39 steps available.

The results:
Code:

i    Ni        Di        Ni/Di       Running time(s)
10   3.64E10   1.09E10   3.342....    7.5
15   2.79E23   8.30E22   3.358....   10.8
20   3.56E41   1.06E41   3.3597...   14.0
25   7.64E64   2.27E64   3.359872.   17.3
30   2.75E93   8.18E92   3.3598845   20.5


The program code:
Code:

--------
KOUT2
+
X<->K1
=
KIN2      //F_i
--------
×
KOUT4
+
KOUT5
=
KIN4      //N_i
--------
KOUT2
KIN×5     //D_i
--------
1
KIN-3
KOUT3
x>0?      //check counter
--------
[alpha]D  //numerator
[alpha]E  //denominator
--------

The variables and initial values:
Code:
K1: F_i-1, store 0 before start
K2: F_i, store 1 before start
K3: counter, store i before start
K4: N_i-1, store 1 before start
K5: D_i-1, store 1 before start


Csaba
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 - Csaba Tizedes - 02-19-2017 04:04 PM



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