MATLAB Answers

No solution found when solving 3 non linear equations

16 views (last 30 days)
Manqoba Mazibuko
Manqoba Mazibuko on 21 Jan 2020
Commented: Walter Roberson on 28 Jan 2020 at 17:10
Good day every one
I have been trying to sove 3 non linear equations but i am "No solution found" report.
The code is as follows
I defined a function containing the 3 non linear equations in an mfile called "angle"
function F=myfunction(x)
F(1)=cos(-x(1)+x(2))+cos(-x(1)+x(3));
F(2)=cos(-x(2)+x(1))+cos(-x(2)+x(3));
F(3)=cos(-x(3)+x(1))+cos(-x(3)+x(2));
After running code
deltarad=fsolve(@yyyyy,rand([3 1]))
I get the following report
No solution found.
fsolve stopped because the problem appears regular as measured by the gradient,
but the vector of function values is not near zero as measured by the
default value of the function tolerance.
<stopping criteria details>
deltarad =
-60.5208
-62.8602
-61.6905
fsolve stopped because the sum of squared function values, r, has gradient with
relative norm 7.341307e-07; this is less than options.OptimalityTolerance = 1.000000e-06.
However, r = 7.954251e-01, exceeds sqrt(options.FunctionTolerance) = 1.000000e-03.
Optimization Metric Options
norm(grad r) = 7.34e-07 OptimalityTolerance = 1e-06 (default)
r = 7.95e-01 sqrt(FunctionTolerance) = 1.0e-03 (default)

  4 Comments

Show 1 older comment
Manqoba Mazibuko
Manqoba Mazibuko on 21 Jan 2020
Thank you. Can you please advise of how check the consistency of these equations?
Walter Roberson
Walter Roberson on 21 Jan 2020
Solve any two of them for two of the variables. Substitute into the third. Observe that the result is something that cannot be 0.
Manqoba Mazibuko
Manqoba Mazibuko on 21 Jan 2020
Thank you I just did that. They are inconsistent. Thank you for the help, really appreciate it!!!

Sign in to comment.

Accepted Answer

Matt J
Matt J on 21 Jan 2020
Edited: Matt J on 21 Jan 2020
A numerical sweep also gives evidence that there is no solution
[x1,x2,x3]=ndgrid(linspace(-pi,+pi,512));
F1=cos(-x1+x2)+cos(-x1+x3);
F2=cos(-x2+x1)+cos(-x2+x3);
F3=cos(-x3+x1)+cos(-x3+x2);
F=[abs(F1(:)), abs(F2(:)), abs(F3(:))];
Fmin = min(sum(F,2))
Fmin =
1.0142

  0 Comments

Sign in to comment.

More Answers (1)

Alex Sha
Alex Sha on 28 Jan 2020 at 15:43
Edited: Alex Sha on 28 Jan 2020 at 15:44
Hi, all, how about the solutions below, from the numerical perspective:
1:
x1: -5.21219473201765E21
x2: -0.279500437676178
x3: 1.29129588911872
Fevl:
f1=0
f2=-1.4930819167841E-15
f3=-1.4930819167841E-15
2:
x1: -1.79664678356017E21
x2: 2.02595283616513
x3: 3.59674916296003
Fevl:
f1=0
f2=-3.04739415125932E-15
f3=-3.04739415125932E-15
3:
x1: 2.19768008763813
x2: 5.41140930100612E22
x3: 0.626883760843237
Fevl:
f1=3.61394399649162E-15
f2=0
f3=3.61394399649162E-15

  2 Comments

Matt J
Matt J on 28 Jan 2020 at 15:51
I can't reproduce your f values
x1= -5.21219473201765E21
x2= -0.279500437676178
x3= 1.29129588911872
F1=cos(-x1+x2)+cos(-x1+x3)
F2=cos(-x2+x1)+cos(-x2+x3)
F3=cos(-x3+x1)+cos(-x3+x2)
F1 =
-0.2352
F2 =
-0.1176
F3 =
-0.1176
Walter Roberson
Walter Roberson on 28 Jan 2020 at 17:10
With that range of values, some of your x are within eps() of the others and so the additions lose precision.

Sign in to comment.

Sign in to answer this question.