Post Reply 
Mardi Gras True Fibs
03-01-2017, 04:34 AM (This post was last modified: 03-01-2017 05:29 AM by Gerson W. Barbosa.)
Post: #3
RE: Mardi Gras True Fibs
I forgot to mention that n (the number of terms of the original series) has to be even. The continued fraction has to have at least two terms. The latter is a limitation of the program only. Notice the continuous fraction terms involved one division and one subtraction only. Let's take a look at a numerical example:


\[\frac{1}{1}+\frac{1}{1}+\frac{1}{1-\frac{1^{2}}{4-\frac{1^{2}}{5-\frac{2^{2}}{9-\frac{3^{2}}{14-\frac{5^{2}}{23-\frac{8^{2}}{37}}}}}}}=3.35988549037\]

That's the result we get when running either program with arguments 7 and 2. In this case, n = 2 and F(n-1) = F1 = 2; F(n+2)*F(1) + F(n-1)*F(2) = F(4)*F(1) + F(1)*F(2) = 3*1 + 1*1 = 4. Once these have been calculated the next terms are obtained by simple addition: 5, 9, 14, 23, 37..., that is a new Fibonacci sequence with initial terms 1 and 4. Notice the first program uses FIBn only because this made the use of the LongFloat library easier.

Using an emulator 1000 digits can be computed in less than 10 seconds @ 2.6 GHz, running the program with parameters 49 and 48. This is only a small fraction of the terms required by the original series, 97/4800 (about 2%). Or about 20% of the somewhat more complicated terms used by the best solution here.

3.359885666243177553172011302918927179688905133731968486495553815325130318996683​38361541621645679008729704534292885391330413678901710088367959135173307711907858​03335503325077531875998504871797778970060395645092153758927752656733540240331694​41799293934610992626257964647651868659449710216558984360881472693249591079473873​67337852332687749976272775794685367691854198146766874299876738209691390121772202​44052081510942649349513745416672789553444707777758478025963407690748474155579104​20067501520341070533528512979263524206226753756805576195566972084884385440798332​42928513680708275226625797511886464640967374615723872362955620536122030246354092​52678424224347036310363201466298040249015578724456176000319551987905969942029178​86694917480809674652368265408693839906987321175216695706385941181455364736426878​24629261666501000989038048233595198931461501082887263928876699171493040530577455​74321561167298985617729731395370735291966884327898022165047585028091806291002444​27701746024104041778606919006503714283529

All digits correct according to that reference.

PS -

I've noticed results don't change when the parameters are swapped. Also, since apparently the maximum efficiency is reached when they're the same, there is no need to compute two different Fibonacci sequences with different sizes as these test programs have been doing. This will improve efficiency even more.
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
RE: Mardi Gras True Fibs - Gerson W. Barbosa - 03-01-2017 04:34 AM



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