Fixed the issue. The optimization routine was walking into regions where the equation wasn’t valid.