sme_contrib.optimize.hessian(f, x0, rel_eps=0.01, processes=None)

Approximate Hessian of function f at point x0

Uses a finite difference approximation where the step size used for each element i of x0 is rel_eps * x[i].

Requires \(N^2 + N + 1\) evalulations of f, where \(N\) is the number of elements of x0

The evaluations of f are done in parallel, so f must be a thread-safe function that can safely be called from multiple threads at the same time.


This choice of step size allows the different elements of x0 to have vastly different scales without causing numerical instabilities, but it will fail if an element of x0 is equal to 0.

  • f – The function to evaluate, it should be callable as f(x0) and return a scalar

  • x0 – The point at which to evaluate the function, a flot or list of floats.

  • rel_eps – The relative step size to use

  • processes – The number of processes to use (the default None means use all available cpu cores)


The Hessian as a 2d numpy array of floats

Return type