The Newton solver, based on KINSOL, is now exposed to the Stan language and in the master branch of stanc3. Its signature is identical to the previous solver:
algebra_solver_newton(system, y_guess, theta, x_r, x_i,
rel_tol, f_tol, max_num_steps)
You can still use the original solver, based on Powell’s dogleg method, via algebra_solver()
. In my experience, the Newton method is better to much better than Powell, so I recommend using it as a default.
This update is long overdue, so sorry for the delay. I wasn’t sure there’d be much use for it (but folks have been requesting this feature) and was also holding off to add the belowdescribed features, but it seems better to go at it stepbystep. Thank you, @rok_cesnovar for reviewing the PR!
Where we go next
We’ll use two signatures and deprecate the original signature, much like was done for the ode integrator:
algebra_solver_newton()
algebra_solver_powell()

algebra_solver()
(deprecated)
Still following the example of the ODE integrators, the algebraic solver will take in variadic arguments (and/or closures). Using @bbbales2’s work on nested backward autodiff, we’ll also improve the differentiation, using an adjoint method.