[SciPy-user] All the roots of a function in an interval

Anne Archibald peridot.faceted at gmail.com
Sat Sep 29 15:51:30 EDT 2007


On 29/09/2007, Gael Varoquaux <gael.varoquaux at normalesup.org> wrote:

> Fully agreed. I have done the analysis. I can give a minimal distance
> between the roots, which means I can scan the function over an interval
> and find all the roots.

The easiest and most reliable method here is to simply sample the
function at equispaced points the nearest distance apart they can be;
then every sign change gives you an interval bracketing a root.

More generally, it should be possible to take advantage of analytic
bounds on the first and second derivatives to reliably find all the
roots of a function in an interval (for example, if you know f(x0)=y0
and in the interval I |f'(x)|<A for all x, then you know there's no
root within |y0|/A of x0; if you have a root at x1, f'(x1)=yp1, and
you know that on I |f''(x)|<B for all x, then the next root is at
least 2|yp1|/B away).

Anne



More information about the SciPy-User mailing list