# fsolve, fmincon producing different results

17 vues (au cours des 30 derniers jours)
Ara Jo le 20 Sep 2021
Hi,
I am wondering how to think about fsolve and fmincon producing different results when solving the same system of nonlinear equations. To explain, fsolve finds a solution that sets x, y, z simultaneouly to zero when x, y, z are some equations.
To run the same routine in fmincon, I set the objective as [x y z]*[x y z]' to be minimized (tolerance 1e-15). And these two routines produce very different solutions, even when they start from the same initial value.
Best,
Ara
##### 0 commentairesAfficher -1 commentaires plus anciensMasquer -1 commentaires plus anciens

Connectez-vous pour commenter.

### Réponses (2)

Matt J le 20 Sep 2021
Do they both achieve the same objective value? If so, you simply have multiple solutions.
##### 0 commentairesAfficher -1 commentaires plus anciensMasquer -1 commentaires plus anciens

Connectez-vous pour commenter.

Sargondjani le 20 Sep 2021
I believe fmincon could also be stuck in a local minimum, due to the quadratic terms. This solution might not actually solve the equations.
And in addition to what Matt says: if you start fmincon from a point close to the solution of fsolve, does it converge to the same point then?
On a side note:
• do you need fminconsince you have no constraint. Maybe fminunc suffices?
• lsqnonlin is a special function to minimize vector valued functions in least square sense. It can also handle bounds, so this might be useful too.
##### 0 commentairesAfficher -1 commentaires plus anciensMasquer -1 commentaires plus anciens

Connectez-vous pour commenter.

### Catégories

En savoir plus sur Solver Outputs and Iterative Display dans Help Center et File Exchange

### Community Treasure Hunt

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

Start Hunting!

Translated by