# Fsolve- equation solved, inaccuracy [possible

22 views (last 30 days)
Arpita Nehra on 30 Sep 2019
Answered: Alex Sha on 17 Oct 2019
This is my function:
function F = root3d(x, alpha_1, alpha_2, beta_a1, beta_a2, beta_c1, beta_c2, gama_1, gama_2, theta_1, theta_2)
F(1) = alpha_1*x(1) - x(7)^-2;
F(2) = 1000 - x(2) - (x(7)/(alpha_1^2));
F(3) = (x(10)*(((x(9)/x(8))*(beta_a1/(1-beta_a1)))^(1-beta_a1))/(gama_1*x(3)));
F(4) = (x(10)*(((((1-beta_a1)/beta_a1)*(x(8)/x(9)))^beta_a1)/(gama_1*x(5))));
F(5) = (x(11)*(((x(9)/x(8))*(beta_c1/(1-beta_c1)))^(1-beta_c1))/(theta_1*x(4)));
F(6) = (x(11)*(((x(8)/x(9))*((1-beta_c1)/beta_c1))^(beta_c1))/(theta_1*x(6)));
F(7) = x(7)*x(10) -x(8)*x(3)-x(9)*x(5);
F(8) = x(5)+x(6)-650;
F(9) = x(3)+x(4)-650;
F(10) = x(1)-x(10);
F(11) = x(2)-x(11);
F(12) = alpha_2*x(12) - x(18)^-2;
F(13) = 1000 - x(13) - (x(18)/(alpha_2^2));
F(14) = (x(21)*(((x(20)/x(19))*(beta_a2/(1-beta_a2)))^(1-beta_a2))/(gama_2*x(14)));
F(15) = (x(21)*(((((1-beta_a2)/beta_a2)*(x(19)/x(20)))^beta_a2)/(gama_2*x(16))));
F(16) = (x(22)*(((x(20)/x(19))*(beta_c2/(1-beta_c2)))^(1-beta_c2))/(theta_2*x(15)));
F(17) = (x(22)*(((x(19)/x(20))*((1-beta_c2)/beta_c2))^(beta_c2))/(theta_2*x(17)));
F(18) = x(18)*x(21) -x(19)*x(14)-x(20)*x(16);
F(19) = x(16)+x(17)-650;
F(20) = x(14)+x(15)-650;
F(21) = x(12)-x(21);
F(22) = x(13)-x(22)
end
And my code is this:
alpha_1 = 0.1;
beta_a1 = 0.2;
beta_c1 = 0.5;
theta_1 = 0.4;
gama_1 = 0.2;
alpha_2 = 0.1;
beta_a2 = 0.2;
beta_c2 = 0.25;
theta_2 = 0.4;
gama_2 = 0.2
x0 = [70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70];
options=optimset('disp','iter','LargeScale','off','TolFun',.001,'MaxIter',100000,'MaxFunEvals',100000);
[SS, fval, exitflag, output]=fsolve(@(x) root3d(x,alpha_1,alpha_2, beta_a1, beta_a2, beta_c1, beta_c2, theta_1, theta_2, gama_1, gama_2),x0,options);
SS
However I get this message in Matlab- Equation solved, inaccuracy possible.
The vector of function values is near zero, as measured by the value
of the function tolerance. However, the last step was ineffective.
<stopping criteria details>
Can you give me some ideas that I can try? Thanks in advance !
-Arpita
##### 2 CommentsShowHide 1 older comment
Arpita Nehra on 3 Oct 2019
But then, does it mean that it should not be included or is it creating any issue? These equations are coming from a set of optimization problems.

Raunak Gupta on 3 Oct 2019
Hi,
This problem can be arrived if fsolve found a point where sum of squares of function values is less than the square root of the FunctionTolerance. This means the optimization should stop at this step however, the sum of squares changed very little in the last step even though gradient of the sum was larger than OptimalityTolerance (that is the first order condition to stop the optimization process). Thus, this suggests that the point found out by fsolve is not near an actual solution. This can happen if the optimization function is not smooth or fsolve have arrived at a Local minimum.
It’s suggested to proceed with the step given in Local Minimum Possible to check whether the solver has succeeded in finding a solution. Also, the exitflag gives good indication of where the solver has stopped.
Arpita Nehra on 4 Oct 2019
So, I am getting an exitflag of 3 or 4. Does that mean that I don't have a solution?

Alex Sha on 5 Oct 2019
a set of approximate solutions：
x1 0.0999971283199049
x2 -0.0143540751799935
x3 -1439252.41946883
x4 1439902.41946883
x5 -527282.99010789
x6 527932.99010789
x7 10.0001435407518
x8 -2.74840022211214E-7
x9 -1.14629426928716E-6
x10 0.0999971283124376
x11 -0.0143540751790788
x12 0.0999998530092107
x13 -2.71657239163275E-7
x14 -2444.18053646169
x15 3094.18053646169
x16 122870.151252869
x17 -122220.151252869
x18 10.0000000027164
x19 0.239014034293751
x20 0.00476269821181569
x21 0.0999998515396455
x22 -2.71660836684954E-7
Arpita Nehra on 16 Oct 2019
So, the answer needs to be positive- may be in tens or hundreds- I tried changing parameters and initial values, however few of my variables are always close to zero which is not correct- can anyone suggest me something that I can try?

Alex Sha on 17 Oct 2019
If want all are positive, refer the results follow:
x1: 0.0990335590812945
x2: 1.27592369827812E-11
x3: 650.000000000022
x4: 2.72057930783573E-10
x5: 650.000000001122
x6: 5.53147931778252E-11
x7: 10.0000000000192
x8: 0.000507814844408164
x9: 0.00101562968901066
x10: 0.0990238946721448
x11: 5.86346295731603E-21
x12: 0.099033559078221
x13: 3.9554649355099E-12
x14: 650.000000000205
x15: 8.92562451814302E-11
x16: 650.000000001166
x17: 1.17219410734425E-11
x18: 10.0000000000193
x19: 0.000507814844347538
x20: 0.00101562968902337
x21: 0.0990238946690532
x22: 6.03438668649515E-26