[Maxima] find_root and variable capture?
elzacho at gmail.com
Fri Mar 7 15:52:04 CST 2008
> Thanks Stavros. I think the problem is not understanding when I need to
I am not ready to give up on this possibility.
> I suspect this is the usual quoting issue that has been explained many
> times on this list. I am not sure why it is hard to understand the
> problem -- perhaps because Maxima tolerates shortcuts like
> find_root(sin(x),x,-1,1) in many cases....
I was unable to find any posts on quote or quoting in the maxima list
archives. I'm sure they are there, but when I type in quote or quoting in
the little google search box I get nothing back. It might be really helpful
to people like myself (who are relatively new to the list and not a maxima
expert) to have a mailing list FAQ. It doesn't even have to be good, maybe
just provide links into archive posts. That way I can embarrass myself
Since I am apparently writing a wish list of documentation I would like:
one thing the language Lisp excels at is its plethora of articles/books on
why things are designed the way they are (as opposed to how they are
designed). This gives the user an intuitive understanding of how things
should be written in the language, which in turn allows him/her to stop
bugging mailing list gurus. Anything like that out there for Maxima?
> If you don't quote the arguments, they will be evaluated when you
> *call* find_root, not when find_root calls them. This is intentional,
> correct, behavior, so that you can write find_root(%o23,'x,...) and so
> you can write programs like my_rootfinder( expr, var ) := ...
> find_root( expr, var, ...).
Okay, I do not understand this... I guess I don't have a strong
understanding (scratch that, any understanding) of the maxima evaluation
procedure. In the Lisp evaluator (if we ignore special forms and macros),
it goes arguments left to right then call the function with those
arguments. I am not sure when find_root calls an argument. I read the
little wiki page on maxima internals and my understanding of this seems
shaky. Is there any other source besides the, err, source?
It looks like quoting is not always the right thing to do, like if I want to
write a wrapper for find_root. My example was pretty much writing a
my_rootfinder function (with the exception that part of the function was
already specified). So I shouldn't quote the expression, but maybe the
variable. I don't know.
f(y) := find_root('(exp(-x)-y), 'x, 0, 100);
f(.1); => some correct number
f(y); => find_root(exp(-x)-y, x, 0, 100) (as expected)
f(q); => find_root(exp(-x)-y, x, 0, 100) (huh? It makes sense, but I don't
Or if there is a true variable capture problem, that is,
> interference between the internal variable names of find_root and baz
> and quux. In that case, the problem should be fixed by changing
> find_root's variable names to, e.g. fr_bar, fr_baz, etc. (yes, it
> would be better to have static scope, but...)
Am I to read from this that maxima doesn't use lexical scoping? It seems
that the block facility allows for something like lexical scoping. However,
without the capability of generic symbols, I suppose one is forced to use
obscure names to reduce the chances of name collisions.
In case the tone comes off negative, Maxima is great! Developers, thank you
With the highest respect,
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Maxima