Analytic evaluation of the gradient and Hessian of molecular potential energy functions