Add gradient and Hessian functions