[SciPy-User] Fwd:

nicky van foreest vanforeest@gmail....
Sat Feb 18 13:08:46 CST 2012


Is there a general routine in numpy/scipy to find the left most root
of a 1-d function? As an example:

import numpy as np
import pylab as pl

grid = np.arange(0, 120., 0.1)

f = 3 - 0.1*grid + np.sin(grid)

#pl.plot(grid, f)

# simplistic method to find the left root:

# since I know that f(0) > 0:
i = 0
   i+= 1

print i, grid[i], f[i]

This algorithm works, provided a suitable initial condition, but it
not particularly efficient. I know that there are fast root solvers in
scipy.optimize, but they require to provide an a and b such that f(a)
< 0 < f(b) (or the other way around). In my general case, these bounds
are not easy to obtain (and I can easily create more taxing problems
for which I would like to have a general, robust and efficient method
to find the left-most root).



More information about the SciPy-User mailing list