How can I solve three non-linear equations having 3 unknowns in MATLAB?

2 views (last 30 days)
My non-linear equations are---
cos(a)-cos(b)+cos(c)=0.725
cos(5a)-cos(5b)+cos(5c)=0.5
cos(7a)-cos(7b)+cos(7c)=0.5
  2 Comments
Walter Roberson
Walter Roberson on 6 Sep 2015
You can see immediately that the solutions will need to be complex, since the sum or difference of three cos() of rational values must be in the range 3*(-1..+1) but the result is required to be -27.27
Rishikesh Datar
Rishikesh Datar on 10 Sep 2015
Edited: Rishikesh Datar on 10 Sep 2015
The correction is made in the question. It is 0.725 instead of -27.27. But is it having unique solution or infinite solutions?

Sign in to comment.

Accepted Answer

Star Strider
Star Strider on 5 Sep 2015
Use the Optimization Toolbox fsolve function:
% MAPPING: x(1) = a, x(2) = b, x(3) = c
fcn = @(x) [cos(x(1))-cos(x(2))+cos(x(3)) + 27.27; cos(5*x(1))-cos(5*x(2))+cos(5*x(3)) - 0.5; cos(7*x(1))-cos(7*x(2))+cos(7*x(3)) - 0.5];
x0 = [1; 1; 1];
[x, fv] = fsolve(fcn, x0);
Be sure to see the documentation for optimoptions and specifically MaxFunEvals, since fsolve encountered that limit before it was happy with the solution (assuming one exists).
  1 Comment
Walter Roberson
Walter Roberson on 6 Sep 2015
There are 18 sets of solutions, and in every solution all of the values are complex -- not a single real-valued variable anywhere in any of the solutions.

Sign in to comment.

More Answers (1)

Walter Roberson
Walter Roberson on 10 Sep 2015
For the revised question, there are 18 real-valued solutions, none of which have a closed form solution, as they involve the roots of a polynomial of degree 9. You might be able to find them using the Symbolic Toolbox and solve(), followed with double()
The solutions are approximately
a = 1.347290041624088, b = 1.487303536560025, c = .9437620688704266
a = .9437620688704266, b = 1.487303536560025, c = 1.347290041624088
a = 1.460079617010332, b = 1.179429186973846, c = 0.8989807405828178e-1
a = 0.8989807405828178e-1, b = 1.179429186973846, c = 1.460079617010332
a = .9096157489766238, b = .6148549454499392, c = .3823026965271043
a = .3823026965271043, b = .6148549454499392, c = .9096157489766238
a = 0.8989807405828178e-1, b = 1.681513036579461, c = 1.962163466615947
a = 1.962163466615947, b = 1.681513036579461, c = 0.8989807405828178e-1
a = .9437620688704266, b = 1.794302611965706, c = 1.654289117029769
a = 1.654289117029769, b = 1.794302611965706, c = .9437620688704266
a = 1.347290041624088, b = 2.197830584719367, c = 1.654289117029769
a = 1.654289117029769, b = 2.197830584719367, c = 1.347290041624088
a = .3823026965271043, b = 2.231976904613169, c = 2.526737708139854
a = 2.526737708139854, b = 2.231976904613169, c = .3823026965271043
a = .9096157489766238, b = 2.759289957062689, c = 2.526737708139854
a = 2.526737708139854, b = 2.759289957062689, c = .9096157489766238
a = 1.460079617010332, b = 3.051694579531511, c = 1.962163466615947
a = 1.962163466615947, b = 3.051694579531511, c = 1.460079617010332
  1 Comment
Rishikesh Datar
Rishikesh Datar on 10 Oct 2015
Are the values in radians or degree? The values of a, b and c are angles of firing for particular device so they should lie form 0 to 90 degree maximum and good initial guess is required.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!