Post Reply 
Mardi Gras True Fibs
03-01-2017, 12:41 AM (This post was last modified: 03-01-2017 01:55 AM by Gerson W. Barbosa.)
Post: #1
Mardi Gras True Fibs
This is a follow-up of the recent thread about the Reciprocal Fibonacci Constant.

Quoting from Wikipedia:

"The reciprocal Fibonacci constant, or ψ, is defined as the sum of the reciprocals of the Fibonacci numbers:

\(\psi = \sum_{k=1}^{\infty} \frac{1}{F_k} = \frac{1}{1} + \frac{1}{1} + \frac{1}{2} + \frac{1}{3} + \frac{1}{5} + \frac{1}{8} + \frac{1}{13} + \frac{1}{21} + \cdots.\) "

That was an exercise on computing this series up to a certain number of terms. A number of you have contributed interesting codes and ideas, to which I am grateful.

It has been mentioned that the computation of the constant to d digits requires at least ⌈(d*ln(100) - ln(20))/(2*ln(φ)⌉ terms, where φ is the golden ratio ( (1 + √5)/2 ), using the plain series. Thus, for 100 digits we would need to sum up to 476 terms of the series. The demonstration is trivial and is left as an exercise for the reader.
476 terms to compute 100 digits looks somewhat inefficient, so my goal has shifted to finding a way to lower this number. Here I share what I have found. Again, without a proof, but only because I have none:

\[\psi = \frac{1}{F_{1}}+\frac{1}{F_{2}}+\frac{1}{F_{3}}+\cdots +\frac{1}{F_{n-1}}+\frac{1}{F_{n}}+\frac{1}{F_{n-1}-\frac{F_{1}^{2}}{F_{n+2}\cdot F_{1}+F_{n-1}\cdot F_{2}-\frac{F_{2}^{2}}{F_{n+2}\cdot F_{2}+F_{n-1}\cdot F_{3}-\frac{F_{3}^{2}}{F_{n+2}\cdot F_{3}+F_{n-1}\cdot F_{4}-\frac{F_{4}^{2}}{F_{n+2}\cdot F_{4}+F_{n-1}\cdot F_{5}-\frac{F_{5}^{2}}{F_{n+2}\cdot F_{5}+F_{n-1}\cdot F_{6}-\frac{F_{6}^{2}}{F_{n+2}\cdot F_{6}+F_{n-1}\cdot F_{7}-... }}}}}}}\]

Code:

%%HP: T(3)A(R)F(.);
\<< 0 R\<-\->F 1 R\<-\->F 1 4 PICK
  START DUP 4 ROLLD DUP ROT FADD
  NEXT FADD 4 PICK ROT 2 + ROLLD LASTARG ROLLD LASTARG 2 - 0 1 ROT
  START SWAP FINV FADD
  NEXT 4 ROLLD 1 4 PICK
  START DUP 4 ROLLD DUP ROT FADD
  NEXT DROP2 1 - 1
  FOR i i FIBn R\<-\->F FSQ SWAP FDIV FNEG FADD -1
  STEP FINV FADD ZZ\<-\->F DROP \->STR DUP HEAD "." + SWAP TAIL + DUP SIZE 1 - "  " REPL
\>>

FIBn:

%%HP: T(3)A(R)F(.);
\<< 5. \v/ DUP 1. + 2. / ROT ^ SWAP / .5 + FLOOR
\>>

This HP 50g user RPL program, using the LongFloat library, requires two parameters. The first is the number of terms of the continued fraction and the second is n in the expression above, the number of terms of the original series.

The following is an evaluation of the expression above with various parameters. When we compare the results with the true reciprocal Fibonacci constant in the first line, we notice that best results are achieved with approximately equal numbers of terms of the continued fraction and terms of the plain series. In this case we have obtained 99 correct decimals using only 30 terms in the last line. 30 is about 6.3% of 476. Not bad!

       3.359885666243177553172011302918927179688905133731968486495553815325130318996683​383615416216456790087

  2 12 3.3598856662421299884649892392688576236687368131807676633574000702972674942939991993079972711​21544920

  2 20 3.359885666243177553167433281787748928648776577928290964879706040408646726702491028523646222602832650​

  2 30 3.359885666243177553172011302918764514065619978389958675293504780890783041151282869607821301725790765

  2 40 3.359885666243177553172011302918927179688899353919213085077297503281892745245057092283592271334021082

  2 50 3.359885666243177553172011302918927179688905133731968281128034773312024205107370483101951938492442443

  4 10 3.3598856662431775529330373071740194358904425219090280535498309533751379799543475599629279294234996​62

  4 20 3.359885666243177553172011302918927179651795581225695045861072258099578065882672826328709609425804709

  4 30 3.359885666243177553172011302918927179688905133731968486489791485719247471989816805452564095340121083

  4 40 3.359885666243177553172011302918927179688905133731968486495553815325130318995788615553566782514358382

  4 50 3.359885666243177553172011302918927179688905133731968486495553815325130318996683​383615416216456651148

 10 20 3.359885666243177553172011302918927179688905133731968486495553815325130318996683​383615416201795067149

 11 20 3.359885666243177553172011302918927179688905133731968486495553815325130318996683​383615416216456790047

 14 14 3.359885666243177553172011302918927179688905133731968486495553815325130318996683​383615414413089430501

 15 14 3.359885666243177553172011302918927179688905133731968486495553815325130318996683​383615416216455221736

 14 16 3.359885666243177553172011302918927179688905133731968486495553815325130318996683​383615416216456790085



Hopefully there are not HP-49/50g-exclusive commands in the following RPL program. It is more difficult to be used with the LongFloat library, though.

Code:

%%HP: T(3)A(R)F(.);
\<< 0. 1. 1. 4. PICK
  START DUP 4. ROLLD DUP ROT +
  NEXT + 4. PICK ROT 2. + ROLLD LASTARG ROLLD LASTARG 2. - \->LIST REVLIST INV \GSLIST 4. ROLLD 1. 4. PICK
  START DUP 4. ROLLD DUP ROT +
  NEXT DROP2 \->LIST REVLIST DUP SIZE 1. - ROT SWAP 0. 1. 1. 4. PICK
  START DUP 4. ROLLD DUP ROT +
  NEXT DROP2 \->LIST REVLIST SQ NEG 0. + ROT 0. + OVER SIZE 1. DUP ROT
  START GETI SWAP 1. - 4. ROLL SWAP GETI 4. ROLL / 4. ROLL ROT GETI SWAP 1. - SWAP 4. ROLL + PUTI 1. -
  NEXT DROP DUP SIZE 1. - GET INV SWAP DROP +
\>>

Comments, corrections and code optimizations are welcome.

Definitely it looks like I have to find something more interesting to do during Easter and Carnival holidays ( Mardi Gras Basic Trigs (HP-12C), Easter Sunday Basic Trigs (HP-12C), Easter Sunday Trigs ( rpn38-CX) ).

Next year I think I'll go to Rio :-)

Edited to fix a couple of typos and minor mistakes.
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
Mardi Gras True Fibs - Gerson W. Barbosa - 03-01-2017 12:41 AM
RE: Mardi Gras True Fibs - Don Shepherd - 03-01-2017, 01:32 AM



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