On Dec 8, 2007 1:39 AM, Paul Zimmermann <[EMAIL PROTECTED]> wrote: > > > One interesting thing is that I made it so that > > > > f.find_root(a,b) > > > > works even if the sign of f(a) and f(b) are the same. In that case, > > it will find a min or max of f on the interval, and use that as a new > > endpoint as input to the root finding algorithm. The root finder > > itself is some serious numerical code from scipy... > > I wonder how this can work. Assume f has no root on [a,b], for example > f = 1/2 + sin(x) on [0,3]. What does f.find_root(0,3) return?
I'm sorry -- I didn't mean to imply that it finds a root even when there isn't one! In cases where there is no root, it raises an exception: sage: f = 1/2 + sin(x) sage: find_root(f, 0, 3) Traceback (most recent call last): ... RuntimeError: f appears to have no zero on the interval > Another interesting example to try is f = 1-2*exp(-6*((x-1)^2)^(1/6)) > on [0,2] (or replace 6 by any larger even integer). It's not a total disaster: sage: f = 1-2*exp(-6*((x-1)^2)^(1/6)) sage: find_root(f, 0, 2) 1.0015417807962606 sage: show(plot(f, 0, 2, plot_points=1000)) Definitely look at http://trac.sagemath.org/sage_trac/ticket/1235 and apply both patches. Any comments are greatly appreciated! By the way, we'll definitely want to create an arbitrary precision find_root using MPFR etc. at some point -- that will be very exciting. (The above is just supposed to do some wimpy machine precision root finding.) -- William --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sage-support URLs: http://sage.math.washington.edu/sage/ and http://sage.scipy.org/sage/ -~----------~----~----~----~------~----~------~--~---