Before revision:  To speedup the optimization, we derive the analytical derivatives  , up to second order, in closed form.
After revision:  To speedup the optimization, we derive the analytical derivatives of the cost function , up to second order, in closed form.