Velvet Star Monitor

Standout celebrity highlights with iconic style.

general

Computing the elements of a Hessian matrix with finite difference

Writer Olivia Zamora
$\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 , but how the compute the off-diagonal entries?

$\endgroup$

1 Answer

$\begingroup$

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.

$\endgroup$

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy