define and := (basic)



ok...thank you...
and why this works:
f(x):= x^2;i(y):= rhs(last( solve(f(x)=y,x)));i(2);i(3);i(4); 	......................................l:[-sqrt(y),sqrt(y)];i(y):=l[2];i(2);i(3);i(4);
doesn't work as expected....................................
thanks
Date: Wed, 18 Dec 2013 09:52:04 -0500
Subject: Re: [Maxima] define and := (basic)
From: macrakis at alum.mit.edu
To: rcrdjf at hotmail.com
CC: maxima at math.utexas.edu

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