Gradient and hessian of $e^{x^Tx}$

hessian-matrixmatrix-calculus

I want to find gradient and hessian of $e^{x^Tx}$

My attempt: $\nabla = 2x^Te^{x^Tx}$

Hessian $= 2e^{x^Tx}I + 2xx^Te^{x^Tx}$

Is that correct?

Best Answer

When in doubt, always use index notation. Then you cannot make any mistakes. Double indices imply summation (Einstein's convention).

$$f(\vec{x})=e^{x_j x_j}$$ $$\partial_i f=e^{x_j x_j} (\delta_{ij} x_j+x_j\delta_{ij})=2 x_i e^{x_j x_j}$$ where I used that derivative of vector components is 1 for the same component and 0 otherwise: $\partial_i x_j=\delta_{ij}$.

Hessian: $$H_{ki}=\partial_k\partial_i f=\partial_k(2 x_i e^{x_j x_j})= 2 (\partial_k x_i) e^{x_j x_j}+2x_i \partial_k e^{x_j x_j}=$$ $$=2\delta_{ki}e^{x_j x_j}+2x_i(2 x_k e^{x_j x_j})=2 (\delta_{ki}+2x_kx_i)e^{x_j x_j} $$ You were missing an extra number $2$ in the second term. In the last step I just used the previous result for the first derivative with $i$ replaced with $k$.

Related Question