<html><head></head><body><div style="font-family:courier new, courier, monaco, monospace, sans-serif;font-size:13px;"><div>PR #8357 proposes vectorizing `scipy.optimize.zeros.newton`. Several options have been discussed in the PR, and I would like to get more feedback from the mailing list. </div><div><br></div><div><br></div><div>(1) The vectorized version causes a speed reduction for the scalar case. Benchmarks using tests from `test_zeros.py` show from 3X to 9X slowdown. For example `test_newton` with a scalar runs in 46[us] but as a numpy 1-item array takes 408[us]. </div><div><br></div><div><br></div><div>A suggested option was to move the vectorized approach to a private function, to check the inputs in the `newton()`, and call the private vectorized version if the input is not scalar. In this case should we just check the initial guess or all of the extra args? IMO we can't know that all of the args are actually used for calculating the objective, although they probably are, so the only value we know will be used is the initial guess. So if implementing this option, I propose only checking the initial guess. </div><div><br></div><div><br></div><div>(2) Halting conditions are also a concern. The current implementation in PR #8357 will raise a RuntimeWarning and return the current guess, if any derivative becomes zero, even though the other items in the array may not have converged. </div><div><br></div><div><br></div><div>A suggested option is to continue to iterate until either all of the derivatives are zero, or the max newton step of the items with a non-zero derivative is less than the specified tolerance. A RuntimeWarning would still be raised if any of the items had a zero derivative, and the message would provide the indices of those items. </div><div><br></div><div><br></div><div>An additional option I considered was to add a flag to allow the user to specify either early or delayed termination in the situation where zero-derivatives exist. Early termination corresponds to the current implementation in PR #8357 (as of 2f2b3df) and delayed corresponds to the option suggested above. </div><div><br></div><div><br></div><div>(3) There may be other issues and options I haven't considered. </div><div><br></div><div><br></div><div>Thanks for your feedback</div><div><br></div><div><br></div><div class="ydpc0c2ff51signature"><div>“As I breath in, I calm my body, as I breath out, I smile” - <a href="http://en.wikipedia.org/wiki/Thich_Nhat_Hanh" rel="nofollow" target="_blank">Thich_Nhat_Hanh</a></div></div></div></body></html>