# Hessian Calculations

We can define a search direction in the Newton Optimisation Method as:

$x=-H^{-1}\nabla f$

where $H$ is the Hessian; a matrix of partial second order derivatives, and the $\nabla f$ is the Jacobian matrix stacked into a column vector form.

The partial derivatives of the Hessian matrix can be calculated with the grape algorithm (Gradient Ascent Pulse Engineering)

$\left\langle\sigma\right|\hat{\hat{U}}_N,\dots,\hat{\hat{U}}_{m+1}\frac{\partial^2}{\partial c_m^2}\hat{\hat{U}}_m,\dots,\hat{\hat{U}}_1\left|\psi_0\right\rangle$