Because rhs(s) does not substitute the current value of n.
Compare a simpler case:
var: x$
f(x):=var$
f(23) => x (not 23)
x: 45$ f(23) => x (not 45)
Maxima evaluates the function body exactly once. If you want to evaluate
things more than once, you can:
q:r$ r:s$ s:t$
q => r <<< normal evaluation
ev(q) => s <<< re-evaluate
ev(q,infeval) => t <<< keep evaluating until it converges
Hope this helps.
-s
On Wed, Dec 18, 2013 at 9:35 AM, Ricardo JF <rcrdjf at hotmail.com> wrote:
> hi,
>
> why the result of g(2),g(3),g(4) is 3^n,3^n,3^n ?
>
> .........
> load(solve_rec);
> rec:f(n)=3*f(n-1);
> s:solve_rec(rec,f(n),f(1)=3);
> g(n):= rhs(s);
> g(2);g(3);g(4);
>
> -->3^n,3^n,3^n
> i know that define(g(n),rhs(s)) works
>
> ........
>
> f(x):= x^2;
> i(y):= rhs(last( solve(f(x)=y,x)));
> i(2);i(3);i(4);
>
> Here works!
> ........
> thanks.
>
> _______________________________________________
> Maxima mailing list
> Maxima at math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima
>
>