Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|cite|improve this question

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.

share|cite|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.