What can be done if fsolve cannot find solution?

5 views (last 30 days)
I have a large piece of code where I have a loop. In each iteration of the loop I use fsolve to find the solution of relatively large nonlinear system. At some points, fsolve returns
No solution found.
fsolve stopped because the relative size of the current step is less than the
value of the step size tolerance squared, but the vector of function values
is not near zero as measured by the value of the function tolerance.
I have a conditon that uses the exitflag to stop if a solution is not found. However, I don't know what can be done to maybe try resolve the system. I tried changing the initial guess and the alogorithm but no luck. Is there anything that could be done in this case?

Accepted Answer

Walter Roberson
Walter Roberson on 20 Jul 2022
  • sometimes there just are no real-valued solutions
  • sometimes you need to narrow down the search range by using tighter upper and lower bounds
  • sometimes it can help a lot to use the solution from the previous iteration as the initial value for the current iteration
  • if it is low enough dimension, graph to see if there are plausible solutions
  • sometimes switching to symbolic toolbox helps, especially if there are fairly large or fairly small intermediate values. But note that when you use vpasolve() if the next iteration would be projected to be outside the bounds, then vpasolve() might just give up instead of adjusting the guess to be within the bounds
  • sometimes adjusting the tolerence can help

More Answers (0)


Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by