0
|
10138 Views
|
|
5 Total Likes
View groups...
Share
GROUPS:

# Mortal Fibonacci Rabbits - Odd Answers for High Numbers

Posted 11 years ago
 Hi guys - Wolfram Demonstrations has a  nice interactive model of mortal Fibonacci rabbits here: http://demonstrations.wolfram.com/MortalFibonacciRabbits/I've been trying to play with the function used to generate the number of rabbits in some generation n when the rabbits die in month n. I used the summation indicated in the paper that Oleksander links. Here's the code I use:m := 19;wabbits[0] = 0;wabbits[1] = 1;wabbits[2] = 1;wabbits[3] = 2;wabbits[n_] := wabbits[n] = \!$$\*UnderoverscriptBox[\(\[Sum]$$, $$k = \((n - m)$$\), $$n - 2$$]$$wabbits[k]$$\)For small n and m it works nicely. (Try n=6, m=3). But for larger numbers, such as m= 19 and n=90, I start running into trouble. For example, try m=15, n=33:With even larger values, for example n=70 and m=19 it tells me I'm exceeding the recursion depth:I know this should have an actual, computable value (ROSALIND has a problem to that effect, with n up to 100 and m up to 20; problem code: fibd).Is the problem with my function definition? Do I have to add anything to make this work for larger numbers? I already added the part wabbits[n_]:=wabbits[n]to save on recursion operations needed to compute large values. The demonstration project uses an even more complicated function which can take variations in fertility month and starting pairs into account, working just fine.
Sort By:
Posted 11 years ago
 The problem is that in order to calculate wabbits you need information about wabbits[n-m] (the first of the summation).So for m>4 you will need wabbits[-1], which in turn will need wabbits[-1-m] et cetera. In order to solve this you would need to put more initial conditions, either you specify the first m wabbits. Or you add a rule like:wabbits[n_ /; n<0] = 0(no bunnies before)I used this: ClearAll[m,wabbits] m = 19; wabbits[n_/;n<0]=0; wabbits[0] = 0; wabbits[1] = 1; wabbits[2] = 1; wabbits[3] = 2; wabbits[n_] := wabbits[n] = Sum[wabbits[k],{k,n-m,n-2}] wabbits[90]and gives:2192659423743724910hope this helps.
Community posts can be styled and formatted using the Markdown syntax.