[SciPy-User] Is this weird answer a bug in optimize.newton?

Thomas Baruchel baruchel at gmx.com
Thu Feb 25 01:32:48 EST 2016


On Wed, 24 Feb 2016, Oscar Benjamin wrote:
> The only thing that jumps out to me is that you've picked an initial
> guess at which the function has a zero second derivative. I'm not sure
> why that would cause the method to fail but Newton solvers are
> sensitive to various singularities in the input function.

First, I thank you all for your answers. I am not absolutely sure it has to do
with initial guess; as I said, the method works correctly when the derivative is
provided or when it is computed by various methods.

Furthermore (I forgot to tell it in my initial message), the function in Scipy
would return the correct answer if some more terms were computed!

By replacing

             if abs(p - p1) < tol:
with
             if abs(p - p1) < tol and abs(p - p0) < tol:

in Scipy's code, the correct answer is returned: of course this would imply
computing one more term in most of the cases, but it wouldn't return too early
in some weird cases where convergence is "fictive".

Regards,

-- 
Thomas Baruchel



More information about the SciPy-User mailing list