[SciPy-User] More elegant way to recover the last iterate of a non-converging newton?

David Goldsmith d_l_goldsmith at yahoo.com
Thu Aug 27 01:11:34 EDT 2009


Hi, folks!  Question re: my own work - I'm using scipy.optimize.minpack.newton with a rather low maxiter (10) so it's frequently terminating with the "Failed to converge after maxiter iterations, value is <last iterate>" RuntimeError, which isn't a problem for now.  What is a problem is I still want to use <last iterate>, and the best I've come up with for "catching" it is:

try:
    result = newton(f, z, fp, tol=tol, maxiter=maxiter)
except RuntimeError, e:
    result = np.complex( e.message.split( '(' )[-1].split( ')' )[0] )

There's got to be a better way, no?

DG


      



More information about the SciPy-User mailing list