I'm trying to plot the graph of a recursive function in Maple 17 but I keep getting the error Error, (in f) too many levels of recursion.
I need to plot a logarithmic graph in the range of x=1,...40. Here is the code:
with(plots);
f:=x->(2.25*f(x-1)-0.5*f(x-2));
f(1):=1/3;
f(2):=1/12;
logplot(f(x),1..40);
How can I fix this problem? Maybe I need to write it in an iterative form, but I don't know how. Thank you very much for any help!
Considering your comment, if you do the following, then you will get a graph very close to the one you got in Matlab.
Digits:= 15:
f:= proc(n)
option remember;
if not n::posint then 'procname'(args)
else 2.25*thisproc(n-1) - 0.5*thisproc(n-2)
end if
end proc:
f(1):= 1/3: f(2):= 1/12:
f_exact:= proc(n)
option remember;
if not n::posint then 'procname'(args)
else 9/4*thisproc(n-1) - 1/2*thisproc(n-2)
end if
end proc:
f_exact(1):= 1/3: f_exact(2):= 1/12:
plots:-logplot([
[seq([x, abs(f(x))], x= 1..40)],
[seq([x,f_exact(x)], x= 1..40)]
]);