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

Gael Varoquaux gael.varoquaux@normalesup....
Sat Sep 29 13:36:23 CDT 2007

On Sat, Sep 29, 2007 at 02:23:03PM -0400, Rob Clewley wrote:
> You can't ever know that you've found all the roots of a general
> function in an interval unless you do a lot of analysis on it. 

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. 

> I don't think you can do better than letting the user set what they
> think is the appropriate number of starting points for the types of
> function they are using on the intervals that they're providing. 

I am the user, in this case.

Actually, I am a bit ashamed of this problem. I need to find all the x
for which:

m_1 * sin(k_2*x) = m_2(k_1*(x + delta_x)

with k_2 ~ 780, k_1 ~ 767, m_1 and m_2 between 0 and 2, and delta_x
taking any value. I need to find all the x over a finite interval (a few
times 2pi/k_2). I gave up on clever analytical solutions (couldn't find
one) and decided to go for the brute force approach. I'd much rather have
an analytical solution, as I have done all the other calculations of the
problem (a Bayesian estimator) analytically, but...

So if anyone has advice on the options for a proper numerical approach
(other than finding a root, and looking for one that pi/(2*k_1) further
away) I'd love to hear.

Thanks for your help,


More information about the SciPy-user mailing list