Programming exercise (RPL/RPN) - Reciprocal Fibonacci Constant
|
02-25-2017, 09:55 PM
(This post was last modified: 02-28-2017 06:08 PM by Gerson W. Barbosa.)
Post: #53
|
|||
|
|||
RE: Programming exercise (RPL/RPN) - Reciprocal Fibonacci Constant
In fact it is possible to obtain 10 digits starting with only the first four terms. A simple 7-term continued fraction suffices for the rest:
1+1+1/2+1/3 + 1/(2-1/(10-1/(12-4/(22-9/(34-16/(56-25/(90))))))) = 3.35988566602 Denominators of the continued fraction: F(4-1)=2 F(4-1)+F(4+2)=10 10+2=12 12+10=22 22+12=34 34+22=56 56+34=90 ... Numerators: 1, 1, 1, 4, 9, 16, 25... Equal numbers of regular terms and continued fraction terms might be better. Edited to add a missing 's'. PS - Or more generically, for an even n: \[\psi \simeq \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{1}{F_{n+2}\cdot F_{1}+F_{n-1}\cdot F_{2}-\frac{1^{2}}{F_{n+2}\cdot F_{2}+F_{n-1}\cdot F_{3}-\frac{2^{2}}{F_{n+2}\cdot F_{3}+F_{n-1}\cdot F_{4}-\frac{3^{2}}{F_{n+2}\cdot F_{4}+F_{n-1}\cdot F_{5}-\frac{4^{2}}{F_{n+2}\cdot F_{5}+F_{n-1}\cdot F_{6}-\frac{5^{2}}{F_{n+2}\cdot F_{6}+F_{n-1}\cdot F_{7}-... }}}}}}}\] PPS - The following have been calculated with 10, 8 and 6 terms of the continued fraction, respectively. n=2 --> 3.359876595167099 n=6 --> 3.359885666018419 n=8 --> 3.359885666243172 These examples require further tests to significantly more terms of the continued fraction. PPPS - Although the first four or five terms of the continued fraction in the generalization above are certainly correct it appears there is a problem with it as it obviously doesn't converge to the tree constants, no matter the number of continued fraction terms is increased, at least in my tests on the HP 50g. Anyway, these first few terms of the continued fraction do improve the convergence, especially for larger n. While this isn't solved the '=' symbol will be replaced with '≃'. Perhaps this should be done with 34 digits of accuracy on Free42 or wp34s in double precision with an equivalent RPN program. Code:
This is based upon Bart's program and requires two arguments: k (number of terms of the continued fraction in level 2: and n (number of terms of the regular series), with even n and k >= 3. Examples: 10 2 --> 3.35987659517 50 2 --> 3.35987659517 100 2 --> 3.35987659517 3 4 --> 3.35988200590 4 4 --> 3.35988562091 5 4 --> 3.35988566563 6 4 --> 3.35988566601 7 4 --> 3.35988566602 10 4 --> 3.35988566602 4 6 --> 3.35988566623 5 6 --> 3.35988566624 3 8 --> 3.35988566624 PPPPS - Now, this appears to be correct: \[\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}-... }}}}}}}\] This should be obvious and indeed that's what I had tried in the beginning, but somehow I skipped one index, which may have led me astray. The first terms of the regular reciprocal series, 1/1 + 1/1 and 12 terms of the continued fraction give 12 correct digits: 2+1/(1-1/(4-1/(5-4/(9-9/(14-25/(23-64/(37-169/(60-441/(97-1156/(157-3025/(254-7921/441))))))))))) = 3.359885666241351 I will rewrite the RPL program above later and test this with 100 digits using the LongFloat library. |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)