[SciPy-User] find zero

nicky van foreest vanforeest at gmail.com
Fri May 30 05:35:55 EDT 2014


Hi,

I am trying to find a zero in an array V that is positive at the left some
index i, say, and negative at the right of i. V is not necessarily
descending, so that numpy.searchsorted does not always find the right
answer. My solution to find i is like this

i = np.searchsorted(V<0, 0.5)

This, however, seems a bit overkill, as the complexity of this algorithm is
at least as large as the length of V, (due to V<0) .

Does anybody know of a smarter, a more direct, solution? Of course, I can
build a function, use scipy.optimize.brentq, but that appears to be even
more overkill.

thanks

Nicky
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.scipy.org/pipermail/scipy-user/attachments/20140530/892f1395/attachment.html>


More information about the SciPy-User mailing list