Edit: The big problem is that it scipy.optimize.brentqrequires the limits of the search interval to have the opposite sign. If you cut your search interval into arbitrary sections and run brentqin each section, as I do below, and, as Dan says in the comments, you throw a lot of worthless ValueErrors. Is there an affordable way to handle this in Python?
Original post: I repeatedly look at functions for their largest zero in python. Right now I am using scipy.optimize.brentqto search for the root, and then using the cruel search method if my initial grades do not work:
def bigRoot(func, pars):
try:
root = brentq(func,0.001,4,pars)
except ValueError:
s = 0.1
while True:
try:
root = brentq(func,4-s,4,pars)
break
except ValueError:
s += 0.1
continue
return root
There are two big problems with this.
, , brentq . , , -, , , .
, script , , , bigRoot, 0. 0,1 0,01, . , , bigRoot, , , .
, python?
, ; .
, , , . ( ).

0 (, , ), , . 1, . , ( , 10 ^ -3).
from numpy import exp as e
def V(r):
return 27.2*(
23.2*e(-43.8*r) +
8.74E-9*e(-32.9*r)/r**6 -
5.98E-6*e(-0.116*r)/r**4 +
0.0529*( 23*e(-62.5*r) - 6.44*e(-32*r) )/r -
29.3*e(-59.5*r)
)
def f(r,b,E):
return 1 - b**2/r**2 - V(r)/E