[Numpy-discussion] any interest in including a second-ordergradient?
Tue Oct 28 23:14:34 CDT 2008
On 28-Oct-08, at 5:57 PM, Fabrice Silva wrote:
> Are there some parts of the code that may be used only once to
> both the gradient and the second derivative (isn't it called the
> hessian, at least in the N-d case) ?
Probably. I'd imagine depends on your differencing scheme; central
differences on the second derivative might imply a need to do two non-
central differences to sample the gradient at +eps and -eps on each
And yes, the square matrix of second derivatives of an N-d scalar
function is typically called the Hessian, but some of the properties
one typically expects from a "Hessian" (i.e. symmetry) are not
necessarily true unless all of the the partial second derivatives are
> If a common function would fasten the computation of the gradient and
> the hessian with a single call to a new function gradients(), it is
> If the intent is just a reduction of the total length of the file
> containing the gradient and gradient2 functions, I do not understand
> modifying the existent code. Why not creating a new function hessian()
> having the same signature than gradient?
As Stefan mentioned, the number of functions that get included when
you type "from numpy import *" is already pretty large, and it'd be
nice not to make it larger. Though you do raise a good point -- if
it's known that the user wants both the gradient and the Hessian, and
you can get the first for free while computing the second, then that's
preferable to having to make two calls and duplicate work.
More information about the Numpy-discussion