Please take a look at the following code and output
f[1] = 1; f[2] = 2; f[n_] := f[n - 2] + f[n - 1] f[3] Plot[f[n], {n, 1, 5}] Out[]= 3
During evaluation of
$RecursionLimit::reclim2: Recursion depth of 1024 exceeded during evaluation of f[-2007.-2].
Please help
Thank you
Perfect hint, thank you so much
Plot passes real numbers (head Real) to f. Try evaluating f[0.5]. You might want to try DiscretePlot. It would also be a good idea to define f[n_]... with
Plot
Real
f
f[0.5]
DiscretePlot
f[n_]...
f[n_Integer?Positive] := f[n - 2] + f[n - 1];
Be sure to ClearAll[f] first.
ClearAll[f]
The function f is defined only for integers greater or equal to 1, however Plot can sample any real coordinate in the plot range, which leads to a recursion similarly to f[1.].
f[1.]
Perhaps DiscretePlot[f[n], {n, 1, 5}] is more appropriate.
DiscretePlot[f[n], {n, 1, 5}]
Ilian,
Your post hadn't shown up when I posted mine, at least in my browser, or I wouldn't have answered. Not sure why it didn't since yours was ~2 hrs before mine.