How to change the stop criteria of fsolve?
109 views (last 30 days)
Show older comments
I have a set of nonlinear equations and I am solving them by fsolve. x(1) to x(6) are my unknowns to be determined and X, Y, Z are definite constants. I wrote the following function:
======
function z=equ_set(x)
global X Y Z
z(1)=x(4)-x(5)*x(6)/x(1)-X(1);
z(2)=x(2)-x(6)^2/x(1)-X(2);
z(3)=x(3)-x(5)^2/x(1)-X(3);
z(4)=x(1)-x(6)^2/x(2)-Y(1);
z(5)=x(5)-x(4)*x(6)/x(2)-Y(2);
z(6)=x(3)-x(4)^2/x(2)-Y(3);
z(7)=x(1)-x(5)^2/x(3)-Z(1);
z(8)=x(2)-x(4)^2/x(3)-Z(2);
z(9)=x(6)-x(4)*x(5)/x(3)-Z(3);
end
====== and wrote the followings in command line to solve the eqs. set:
global X Y Z
X=[2/3, 5/3, 2/3];
Y=[5/2, 1/2, 1/2];
Z=[2, 1, 0];
x0=[1,1,1,1,1,1];
fsolve(@equ_set,x0)
=======
Since fsolve is a numeric solver I used it. How can I change the stop criteria of fsolve? (for example error<1e-3) I have seen "relative norm(grad r)" but I am not sure whether this is the case and how to change it. Thanks
0 Comments
Answers (2)
Matt J
on 7 Sep 2014
There is some reading to be done
You can also implement your own stopping criteria using the OutputFcn option
0 Comments
Star Strider
on 7 Sep 2014
If you want to change the default behaviour of fsolve, use the optimoptions function. See the fsolve Options sections for details on what you can change, the 'MaxFunEvals', 'MaxIter', 'TolFun', and 'TolX' possibly being the most relevant for your purposes.
0 Comments
See Also
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!