Function navtk::filtering::calc_numerical_hessians

Function Documentation

std::vector<Matrix> navtk::filtering::calc_numerical_hessians(const std::function<Vector(const Vector&)> &f, const Vector &x, const Vector &eps)

Calculate the numerical Hessians of a multivariate function.

Given a function g(x) that maps the N elements of vector x to a vector of M elements (v), we treat the function g(x) as a composite of M functions, each of which maps x to a scalar value (an element of v): \(g(x) = {f_0(x), f_1(x)... f_{m-1}(x)}\). Then the second derivative of g(x) can be viewed as a collection of the NxN Hessians of each f(x).

The Hessian has the form:

\(\begin{bmatrix} \frac{\delta f}{\delta^2x_0} & \frac{\delta f}{\delta x_0 \delta x_1} & \frac{\delta f}{\delta x_0 \delta x_2} & \dots & \frac{\delta f}{\delta x_0 \delta x_{n-1}} \\ \frac{\delta f}{\delta x_1 \delta x_0} & \frac{\delta f}{\delta^2 x_1} & \frac{\delta f}{\delta x_1 \delta x_2} & \dots & \frac{\delta f}{\delta x_1 \delta x_{n-1}} \\ \vdots & \vdots & \vdots & \ddots & \vdots \\ \frac{\delta f}{\delta x_{n-1} \delta x_0} & \frac{\delta f}{\delta x_{n-1}\delta x_1} & \frac{\delta f}{\delta x_{n-1} \delta x_2} & \dots & \frac{\delta f}{\delta^2 x_{n-1}} \end{bmatrix}\)

Parameters
  • f – A function mapping a column vector of N inputs into a column vector of M outputs.

  • x – A N-element column vector at which to compute the Hessians of f.

  • eps – A column vector of steps the same size as x with which to perturb the function f.

Returns

An M-sized collection of NxN matrices of the Hessians of f evaluated at x.