`optim` has an argument (`hessian`) that should hopefully make this pretty painless.
optimhas an argument (hessian) that should hopefully make this pretty painless.