Gradient Ascent Pulse Engineering (GRAPE) fidelity, gradient and Hessian.
[traj_data,fidelity,grad,hess]=grape(spin_system,drift,controls,... waveform,dt,rho_init,rho_targ,... fidelity_type)
Propagates the system through a user-supplied shaped pulse from a given initial state and projects the result onto the given final state. The fidelity is returned, along with its gradient and Hessian with respect to amplitudes of all operators in every time step of the shaped pulse.
drift - The drift Liouvillian (matrix). controls - Control operators in Liouville space (cell array of matrices). waveform - Control coefficients for each control operator, rad/s (vector array) dt - Size of time steps in the piecewise constant approximation used within grape, seconds. rho_init - Initial state of the system as a vector in Liouville space. rho_targ - Target state of the system as a vector in Liouville space. fidelity_type - 'real' (real part of the overlap) 'imag' (imaginary part of the overlap) 'square' (absolute square of the overlap)
fidelity - fidelity of the control sequence grad - gradient of the fidelity with repect to the control sequence hess - Hessian of the fidelity with respect to the control sequence traj_data.forward - Forward trajectory of the grape simulation of control amplitudes from the initial state. traj_data.backward - Backward trajectory of the grape simulation of control amplitudes from the desired target state.