1
votes

I'm using MATLAB's fsolve function to solve systems of nonlinear equations. I have two nonlinear equations with two variables (x,y);

I'm trying to find the all possible roots for the both variables. I noted that the fsolve gives just one root. How it possible to get the all roots for the equations?

My code as the following:

function F = fun(guess)
    x = guess(1); 
    y = guess(2);

    F = [2*x -y - exp(-x));
        -x + 2*y - exp(-y) ];
end

call the function:

guess = [-5 -5]
fsolve(@fun,guess);
2
Check out this question. I think you can modify Rody's answer, by changing the second and third input variables. - Stewie Griffin

2 Answers

0
votes

Prove that there is only one root, so you don't need to search further.

From the second equation,

  -x + 2·y - exp(-y) = 0
⇒ x = 2·y - exp(-y)

Substitute x into the first equation:

  2·x - y - exp(-x) = 0
⇒ 2·(2y-exp(-y)) - y - exp(-(2y-exp(-y)) = 0

which is a function of y only. Standard calculus will show this f(y) is monotonically increasing, starts negative at y=-∞ and is positive at y=+∞. The result is the same for when you do the substitution the other way around. This implies there is only 1 simultaneous root to both equations.

QED.

0
votes

fsolve is not a global solver. There are global solvers (like genetic algorithms and simulated annealing), but they have to run for an infinite amount of time to guarantee that the returned solutions comprise all of the minimizers. On the hand, almost all other optimization solvers are local, meaning that they will only guarantee that a local minimizer is returned.

Furthermore, in addition to not knowing whether the returned solution is a global or local minimizer, there is, in general, no way of determining how many roots a problem has. So basically, there is no way of doing what you want except for 2 well known cases:

1) If the problem is convex, then there are no local minimizers that are not global minimizers. So anything returned by fsolve will be a global minimizer. Furthermore, this minimizer is almost always unique. The exception is that technically, there can exist an infinite number of solutions, but they will all be connected (like on a specific plane). There cannot exist a finite number of distinct minimizers that are not connected.

2) Polynomials have a distinct number of roots that we can uniquely determine.