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.359885666243177553172011302918927179688905133731968486495553815325130318996683383615416216456790087297045342928853913304136789017100883679591351733077119078580333550332507753187599850487179777897006039564509215375892775265673354024033169441799293934610992626257964647651868659449710216558984360881472693249591079473873673378523326877499762727757946853676918541981467668742998767382096913901217722024405208151094264934951374541667278955344470777775847802596340769074847415557910420067501520341070533528512979263524206226753756805576195566972084884385440798332429285136807082752266257975118864646409673746157238723629556205361220302463540925267842422434703631036320146629804024901557872445617600031955198790596994202917886694917480809674652368265408693839906987321175216695706385941181455364736426878246292616665010009890380482335951989314615010828872639288766991714930405305774557432156116729898561772973139537073529196688432789802216504758502809180629100244427701746024104041778606919006503714283529 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. |
|||
« Next Oldest | Next Newest »
|
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
RE: Mardi Gras True Fibs - Gerson W. Barbosa - 03-04-2017, 03:34 PM
RE: Mardi Gras True Fibs - Gerson W. Barbosa - 06-14-2018, 12:41 AM
RE: Mardi Gras True Fibs - Gerson W. Barbosa - 06-17-2018, 06:00 PM
|
User(s) browsing this thread: 1 Guest(s)