[SciPy-Dev] Return residual and derivative in gradient descent methods like Newton

Mark Alexander Mikofski mikofski at berkeley.edu
Mon Jun 25 10:30:25 EDT 2018


Hi,

Would anyone disagree or would anyone be interested in a proposal to allow
the derivative to be returned from the user supplied function as an
optional second argument in gradient search method like Newton? EG

>>> lambda x,a: (x**3-a, 3*x*"2)
>>> newton(f, x0, fprime='f2', args=(a,))

Some simple tests show that this may have a 2X speed in cases where the
derivative expression requires the value of the original function call.

See this issue in which I proposed this idea and wore a sample test script
https://github.com/scipy/scipy/issues/8354

I proposed a way to keep the existing API and add this new feature.
* If `fprime` is a callable, then same as before
* If it's a string like "f2" the get fprime from second output

Thanks,
Mark
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/scipy-dev/attachments/20180625/9f57736f/attachment.html>


More information about the SciPy-Dev mailing list