How to use scipy.optimize.minimize function when you want to compute gradient along with the objective function?
<p><code>scipy.optimize.minimze</code> takes <code>obj</code> and <code>jac</code> functions as input. and I believe it will call them separately as and when needed. But more often than not we come across objective functions whose gradient computation shares a lot of computations from the objective function. So ideally I would like to compute the <code>obj</code> and <code>grad</code> simultaneously. But this doesn't seem to be the case with this library? What is the way to deal with it if one still wants to use <code>scipy.optimize.minimze</code> if at all there is?</p>