4
$\begingroup$

I have a generic function $g(x)$ where $x$ is an 6-dimensional vector. Now I want to compute the Hessian of this function for a point $x_0$. What is the most efficient way to do this? Can I do this with finite differences and which formulas do I need?

The diagonal entries are no problem when following the formulas from http://en.wikipedia.org/wiki/Finite_difference, but how the compute the off-diagonal entries?

1 Answers 1

1

You can approximate the entries in the Hessian with finite differences: $ f_{ij} \doteq \left(f(x_1,x_2,\dots,x_i+h,\dots,x_j+k,\dots,x_n) -f(x_1,x_2,\dots,x_i+h,\dots,x_j,\dots,x_n) -f(x_1,x_2,\dots,x_i,\dots,x_j+k,\dots,x_n) +f(x_1,x_2,\dots,x_i,\dots,x_j,\dots,x_n)\right)/(hk) $ for small $h,k$.

The formula above is just a finite difference ratio in the $i^\text{th}$ variable combined with a finite difference ratio in the $j^\text{th}$ variable.