<div dir="ltr"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On Mon, Jun 25, 2018 at 10:30 AM, Mark Alexander Mikofski<br>
<<a href="mailto:mikofski@berkeley.edu" rel="noreferrer noreferrer noreferrer" target="_blank">mikofski@berkeley.edu</a>> wrote:<br>><br>
> Would anyone disagree or would anyone be interested in a proposal to allow<br>
> the derivative to be returned from the user supplied function as an optional<br>
> second argument in gradient search method like Newton? EG<br>
><br>
>>>> lambda x,a: (x**3-a, 3*x*"2)<br>
>>>> newton(f, x0, fprime='f2', args=(a,))<br>
><br>
> Some simple tests show that this may have a 2X speed in cases where the<br>
> derivative expression requires the value of the original function call.<br></blockquote></div></blockquote><div><br></div><div>The `minimize` function does something like this for the `jac` keyword: "<span style="color:rgb(51,51,51);font-family:"Open Sans",sans-serif;text-align:left;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">If<span> </span></span><em class="gmail-xref gmail-py gmail-py-obj" style="font-style:italic;color:rgb(51,51,51);font-family:"Open Sans",sans-serif;text-align:left;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial">jac</em><span style="color:rgb(51,51,51);font-family:"Open Sans",sans-serif;text-align:left;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline"><span> </span>is a Boolean and is True,<span> </span></span><em class="gmail-xref gmail-py gmail-py-obj" style="font-style:italic;color:rgb(51,51,51);font-family:"Open Sans",sans-serif;text-align:left;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial">fun</em><span style="color:rgb(51,51,51);font-family:"Open Sans",sans-serif;text-align:left;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline"><span> </span>is assumed to return the gradient along with the objective function.".</span></div><div><span style="color:rgb(51,51,51);font-family:"Open Sans",sans-serif;text-align:left;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">If something like this is desirable, then I suggest that the same minimize pattern is used.</span></div></div></div>