[SciPy-user] Partial Derivatives

Alan G Isaac aisaac at american.edu
Fri Feb 25 21:29:37 CST 2005

On Fri, 25 Feb 2005, "R. Padraic Springuel" apparently wrote:
> Is there a way to use the "derivative" function to take a partial
> derivative?

Is scipy.optimize.approx_fprime serviceable here?

I notice it fails to account for
epsilon != (x+espilon)-x
so the line
grad[k] = (apply(f,(xk+ei,)+args) - f0)/epsilon
should I believe be changed to
grad[k] = (apply(f,(xk+ei,)+args) - f0)/((xk[k]+epsilon)-xk[k])
to improve accuracy.  

Of course this still uses 'apply' which is deprecated since 
Python 2.3.  (I don't claim to know if this is a good idea, 
but it reputedly slows things down:
http://www.python.org/doc/2.3.3/lib/non-essential-built-in-funcs.html )

Also, just out of curiosity since we're here:
why the strange argument order (function 2nd)
for the gradient (and hessian) here?

Alan Isaac

More information about the SciPy-user mailing list