Hi,
I apologize if having used and got used to mathematica I am here asking
questions that might be not completely pertinent.
In mathematica, you have two scoping devices, namely block and module.
The block device works similarly to the one in maxima. Module by converse
generates local variable names on the fly. I am currently missing the
module behavior in maxima and I wonder what is the best way to achieve
what I would like to.
Consider the following. Suppose I want to build a function to return a
solution of exp(x)+x=y given y. I would tend to write
foo(y):=block([x],find_root(exp(x)+x=y,x,0,1));
if I pass a numeric value it is ok
foo(2);
.4428544010023886
if I pass some variable it is also ok, keeping the stuff symbolic
foo(z);
find_root(%e^x+x=z,x,0.0,1.0)
however if the variable happens to be 'x', the way the block scoping
constructor works makes things break
foo(x);
find_root: function has same sign at endpoints: f(0.0)=1.0,
f(1.0)=2.718281828459045
Since maxima substitutes
find_root(%e^x+x=x,x,0.0,1.0)
which is obviously not what one wants.
By using a module rather than a block, mathematica creates variable on
the fly, so you actually get something like
find_root(%e^x$0134+x$0134=x,x$0134,0.0,1.0)
where the '$0134' is some unique subscript that mathematica generates
each time the function is invocated.
Is there anything like that or a proper way to do it?
Thanks
Sergio