define and := (basic)



My doubt is when the variable is bound and when not.

.................
load(solve_rec);
rec:f(n)=3*f(n-1);
g(n):= rhs(solve_rec(rec,f(n),f(1)=3))  ... ( Is it  equal g(n):=rhs( f(n)=3^n) ? )

 --> 'n' isn't bound by function (why?)
.................

h(n):=rhs(f(n)=3^n );

 --> 'n' is bound by function
.................

i(n):= rhs(x=sqrt(n));  

 --> 'n' is bound by function

.................
thanks.
Date: Wed, 18 Dec 2013 20:39:20 -0500
Subject: Re: [Maxima] define and := (basic)
From: macrakis at alum.mit.edu
To: rcrdjf at hotmail.com
CC: maxima at math.utexas.edu

Why would you expect sqrt(y) etc.? After all, 'y' is bound by the function call.



On Wed, Dec 18, 2013 at 12:55 PM, Ricardo JF <rcrdjf at hotmail.com> wrote:





ok...i was not clear.f(x):= x^2;i(y):= rhs(last( solve(f(x)=y,x)));i(2);i(3);i(4); --> it shoud be sqrt(y);sqrt(y);sqrt(y);

thanks.
Date: Wed, 18 Dec 2013 12:19:18 -0500
Subject: Re: [Maxima] define and := (basic)
From: macrakis at alum.mit.edu

To: rcrdjf at hotmail.com
CC: maxima at math.utexas.edu



On Wed, Dec 18, 2013 at 11:53 AM, Ricardo JF <rcrdjf at hotmail.com> wrote:

f(x):= x^2;i(y):= rhs(last( solve(f(x)=y,x)));i(2);i(3);i(4);

I'm not entirely sure I understand what you're asking. In particular, saying "doesn't work as expected" isn't very explicit: what were you expecting?


But if I'm understanding your question correctly...

In your first example, the variable 'y' is bound by the function. In the second it isn't. Here is a simpler example:



q(w):=w$
q(2) => 2
val: w$

r(w):= val$r(2) => val (not 2)