How to use different solver of NonlinearSolve.jl?

I am using NonlinearSolve but have some stupid problem.

I can run the following example script:

using NonlinearSolve, StaticArrays

f(u, p) = u .* u .- p
u0 = @SVector[1.0, 1.0]
p = 2.0
probN = NonlinearProblem(f, u0, p)
sol = solve(probN, NewtonRaphson(), reltol = 1e-9)

However, when I want to use other methods, for example the trust-region method or the Broyden method, I simply change the last line to

sol = solve(probN, TrustRegion(), reltol = 1e-9)

or

sol = solve(probN, Broyden(), reltol = 1e-9)

But the REPL simply tells me that neither Trustregion nor Broyden is defined.
Why is that and How can I use these methods?

Also, the example code only works if u0 is static. What can I do if I want to use normal (non-static) array?

The documentation says that Broyden() is included, however, maybe you also need SimpleNonlinearSolve. You could try to install the latter package, and to add it to your code. Regarding TrustRegion(), I have no clue. EDIT: it is written in the docs that TrustRegion() is still in development.

1 Like

What version do you have? Those should just work.

Thank you!
After adding using SimpleNonlinearSolve, the broyden method works.

Great. Btw.: you are more likely to get help on such topics, if you post them in the category Optimization (Mathematical).