why do lsqnonlin and fmincon give different optimization results when solving a set of nonlinear equations?
Show older comments
I tried to solve a set of nonlinear equations using lsqnonlin and fmincon. All the input parameters (including initial values) are the same and I tried all the embedded algorithms they have, but they gave different optimization results. It is not minor difference, but relatively big difference. I am wondering why this happened.
The codes below includes two functions modeltest1 and modeltest2. Modeltest1 makes use of fmincon, while modeltest2 uses lsqnonlin. All the input parameters (including initial values) are the same. Modeltest1 give result,
Pvalsliding =
0.013820918065572
0.574406473683740
0.003205160530740
fval =
0.158094349821487
exitflag =
2
While the first order optimality is 1244, which is not near 0, I doubt it is the right solution.
Modeltest2 give result,
Pvalsliding =
0.031362654332190
0.600494583113902
0.005429484251305
resnorm =
1.668533048658531
residual =
-0.000006852621127
-1.291690209823506
-0.008333694119595
exitflag =
2
While the first order optimality is 46.5, which is not near 0, I doubt it is the right solution.
Is it possible that the solution is the right answer while the first order optimality is not near 0 ?
By the way, those equations are nonlinear implict equations ,so it's quite difficult to get a stable and reliable solution. Is it reliable to solve this kind of problems using matlab embedded functions like lsqnonlin and fmincon? Should I try some iterative method like Newton’s iteration method (like Newton-Raphson Iteration Method ) when solving a set of nonlinear implict equations? Are there some more efficient methods to solve a set of nonlinear implict equations?
If anyone can help, I appreciate it very much.
Accepted Answer
More Answers (0)
Categories
Find more on Systems of Nonlinear Equations 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!