Custom rule for differentiating through Newton solver using ForwardDiff: works for gradient, fails for hessian

Thanks for the recommendations! I ended up manually coding the gradient and hessian for the function and using the ForwardDiffChainRules.jl package to enforce this rule, now it’s working.