How to get out of the issue showing fsolve stopped because the relative size of the current step is less than the value of the step size tolerance squared.

28 views (last 30 days)
On solving this function
function F = FeMnC_350PEnew(x)
F(1) = -4.59446-11.85189*(x(1)/(1+x(1)))-20.27962*(0.00000001/(1+x(1)))-8.138041734*(x(2)/(1+x(2)))+9.20437*(0.00000001/(1+x(2)))-log(1+x(2))+log(1+x(1))+ ((1-0.00000001)/0.00000001)*(0.49758+log(1+x(1))-log(1+x(2))+(((6559543.388*x(1)^2/2)+11.85189*x(1)*0.00000001+(20.27962*0.00000001^2/2))/(1+x(1))^2)-(((44.16592*(x(2)^2)/2 -8.138041734*0.00000001*x(2)+(9.20437*0.00000001^2)/2))/((1+x(1))^2)));
F(2) = -8.61169-log(x(1)*(1+x(2))/(1+x(1))*x(2))-6559543.388*x(1)/(1+x(1))- 11.85189*(0.00000001/(1+x(1)))+44.16592*(x(2)/(1+x(2)))-8.138041734*(0.00000001/(1+x(2)));
end
With
x0 = [0.000001 0.2]
I am getting the message
x = fsolve(@FeMnC350PEnew4,x0)
Equation solved, solver stalled.
fsolve stopped because the relative size of the current step is less than the
value of the step size tolerance squared and the vector of function values
is near zero as measured by the value of the function tolerance.
<stopping criteria details>
x =
1.77421584383843e-06 0.130327682671628
Please help me out in solving the above function with fsolve or any other function to get good results and also explain to the issue and its solution.

Accepted Answer

Walter Roberson
Walter Roberson on 10 Jun 2021
format long g
x0 = [0.000001 0.2]
x0 = 1×2
1e-06 0.2
[x, fval] = fsolve(@FeMnC_350PEnew, x0);
Equation solved, solver stalled. fsolve stopped because the relative size of the current step is less than the value of the step size tolerance squared and the vector of function values is near zero as measured by the value of the function tolerance.
x
x = 1×2
1.77421584383856e-06 0.130327682671628
fval
fval = 1×2
-2.30330048367478e-08 -8.47251834768908e-13
syms X [1 2]
Fsym = FeMnC_350PEnew(X)
Fsym = 
Fsym1 = subs(Fsym, X(1), x(1));
fplot(Fsym1, x(2)*[.9 1.1])
Fsym2 = subs(Fsym, X(2), x(2));
fplot(Fsym2, x(1)*[.9 1.1])
function F = FeMnC_350PEnew(x)
F(1) = -4.59446-11.85189*(x(1)/(1+x(1)))-20.27962*(0.00000001/(1+x(1)))-8.138041734*(x(2)/(1+x(2)))+9.20437*(0.00000001/(1+x(2)))-log(1+x(2))+log(1+x(1))+ ((1-0.00000001)/0.00000001)*(0.49758+log(1+x(1))-log(1+x(2))+(((6559543.388*x(1)^2/2)+11.85189*x(1)*0.00000001+(20.27962*0.00000001^2/2))/(1+x(1))^2)-(((44.16592*(x(2)^2)/2 -8.138041734*0.00000001*x(2)+(9.20437*0.00000001^2)/2))/((1+x(1))^2)));
F(2) = -8.61169-log(x(1)*(1+x(2))/(1+x(1))*x(2))-6559543.388*x(1)/(1+x(1))- 11.85189*(0.00000001/(1+x(1)))+44.16592*(x(2)/(1+x(2)))-8.138041734*(0.00000001/(1+x(2)));
end
These plots tell you that:
  1. the numeric results you got really are roots, or at least very close to roots
  2. at least one of the function is quite steep near the roots, which makes it difficult to find perfect roots
The fval you see in output shows you are getting roots down to about 2 parts in 10^8 . We can see from the plots that the function is not especially curved near the roots (just steep), so do not bother going looking for the possibility that these are false roots that are only "close" to 0 but curve near and away again. You can see clearly from the plots that the second function in particular definitely crosses 0.
In summary.... there is nothing at all wrong with the numeric results you are getting, and they do not need to be fixed.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!