find_root doesn't throw error



On 11/24/07, van Nek <van.nek at arcor.de> wrote:

> (%i1) f(x):=log(x)+2-x$
> (%i2) find_root( f(x), x,0,1 );
> (%o2)               find_root(log(x) - x + 2, x, 0.0, 1.0)
>
> I was puzzled for some seconds. In any other case I would believe, that
> find_root is not defined. find_root reacts misleading.

> Then plot2d helps me
>
> (%i3) plot2d(f,[x,0,1]);
> log(0) has been generated.
> #0: f(x=0.0)
>  -- an error.  To debug this try debugmode(true);

It turns out that if you call find_root by naming the function, you
get the same error.

find_root (f, 0, 1);
 => log(0) has been generated.

And if you call plot2d with f(x), it doesn't complain (but it does make a plot).

The behavior of both plot2d & find_root depends on the Lisp function
coerce-float-fun. When its argument is a function name, coerce-float-fun
doesn't wrap the function call in an error catch; this is probably a bug.

Also, find_root returns an unevaluated expression if the function
doesn't return a number; it doesn't try to look for a subinterval for
which the function can be evaluated to a number at both endpoints.
I guess find_root could have a heuristic for that.

HTH

Robert