the root finding using fsolve

25 views (last 30 days)
ela
ela on 18 Nov 2015
Commented: John D'Errico on 30 Nov 2015
is there any way using fsolve to get 'all' possible solutions for equations? it just shows me the closest root to the initial guess!

Accepted Answer

John D'Errico
John D'Errico on 20 Nov 2015
Edited: John D'Errico on 20 Nov 2015
There are essentially no tools that are absolutely assured to generate ALL solutions to a fully general nonlinear problem. Such global optimization problems (root finding is in that general family) can be made arbitrarily difficult.
In particular, fsolve is designed to return ONLY one solution. So it is working exactly as designed, and you cannot tell it to find multiple solutions.
On top of all this, one can easily generate problems with infinitely many solutions. For a trivial example, find all roots of the equation
sin(x) == 0.5
While you can write those solutions in a general form, that would not be a numerical solution then, so fsolve could not do so. And do you have enough memory to store infinitely many numerical solutions? The last time I checked, infinity was a big number. As well, it is as trivial to give an example where there is no easily written solution in general.
You can use the global optimization toolbox. Or you can use a multi-start method, so restart the optimizer from a variety of random places, then make sure you recognize that some of those solutions will be essential replicates to within slop.
  2 Comments
ela
ela on 30 Nov 2015
Thanks for your answer. I tried an interval and increments for my initial points to get 'all' the solution in small region but fsolve didn't work, it might be something that fsolve is not designed for.
John D'Errico
John D'Errico on 30 Nov 2015
fsolve is not designed to compute only solutions in an interval.
If this is a 1-dimensional problem, then use fzero. Search in your interval for each zero crossing. Then pass the bracketed root to fzero, which will converge to the solution in that interval. Of course, if the problem is one in multiple dimensions, then fzero will not suffice either.

Sign in to comment.

More Answers (0)

Categories

Find more on Optimization in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!