Nlsolver vs Matlab fsolve

I have some code to solve a system of nonlinear equations given some state variables (both in Matlab and Julia). The solution is quite sensitive and I have to use homotopy to solve it for a variety of points in the state space. Matlab using fsolve runs fast and solves all of the cases except for some extreme examples. Julia’s nlsolver crashs for many more of the points in the state space. I am just running the solvers on their baseline settings. Is there a solver in Julia which can reproduce Matlab’s restults with fsolve?

What do you mean by Julia’s Nlsolver? IMO the best nonlinear solver in julia is NonlinearSolve.jl. is that one of the options you have tried?

Thanks for replying. I noticed similar posts from some time ago, but they did not have any good resolution. Here is what I did:

using NLsolve

nlsolve(…)

So this is what I have used, which is what comes up when I query Google. Interestingly, I first wrote this basic code 5 years ago and the current version of Matlab fsolve runs much better now than it did. So something has changed on their end.

So you did not try NonlinearSolve, which is a different package than NLsolve. Can you give it a try?

Or share the code that does not work well with Julia.

Let me try that. I just googled it and got a github page. I’ll try and find some sort of tutorial or readme and see if that works. Thanks for the suggestion.

Just use the official documentation: NonlinearSolve.jl: High-Performance Unified Nonlinear Solvers · NonlinearSolve.jl

Will do. I ran the same code and it worked. Now I’ll go back to what I was doing and see if it will work too. Thanks very much for your help.

2 Likes