Zach wrote:
> Dear Maxima people,
...
> f(y) := find_root(exp(x) - y, x, 0, 100);
> plot2d(f(x), [x, .1, .9]);
>
> This will plot a constant value at 0.56..., however, f(.1) is not equal
> to f(.2) if I just type them in. And,
>
> plot2d(f(y), [y, .1, .9]);
>
> will plot the root wrt. x of exp(x) - y.
I think this is somehow close to the problem i've been having. Here's
another simple example that shows that quad_qag has a similar problem.
foo(x) := sin(x-.1);
bar(x) := first(quad_qag(foo(z-x),z,-1,1,3));
baz(z) := find_root(bar(x)-z,x,0,1);
baz(0);
Now in theory, baz(0) should return -.1. It's finding the shift required
to foo to balance the integral of foo
instead I get:
Variable of integration not a variable: 0
#0: bar(x=x)
#1: baz(z=0)
-- an error. To debug this try debugmode(true);
I don't expect that if bar(x) is called from an environment where z is
bound that it would fail... because z is a dummy variable. I also don't
really expect to have to gensym my own dummy variable. But I don't know
how this should work....
now I define this:
quux(qqq) := find_root(bar(x)-qqq,x,0,1);
(%i432) quux(0);
Maxima encountered a Lisp error:
Error during processing of --eval option "(cl-user::run)":
The value ((MTIMES SIMP) -1.0 ((%SIN SIMP) ((MPLUS SIMP) 0.1 $X)))
is not of type
REAL.
Automatically continuing.
To reenable the Lisp debugger set *debugger-hook* to nil.
This is the kind of error I was getting in my complicated example...
Except in my complicated example the error only shows up when I do this
from plot2d not at the command prompt.
Thanks,
Dan