Solving 3 equations with 3 unknowns gives Warning: Explicit solution could not be found > In solve at 179
Show older comments
I am very new to Matlab and I wrote this code to find the solutions for x, y and l for three equations. Here is the code I used;
syms x positive
syms y positive
syms m n e f l b c d
S = solve((y/((x+y)^2))*(m+e+l*d*m-l*d*n-((2*l*d+1)*((b*x)/(x+y)))+((2*l*d*b*y)/(x+y)))-l-c == 0,
(x/((x+y)^2))*(n+f+l*d*n-l*d*m-((2*l*d+1)*((b*y)/(x+y)))+((2*l*d*b*x)/(x+y)))-l-c == 0, -x+(d*((m*x/(x+y))-(b/2)*((x/(x+y))^2)+(n*y/(x+y))-(b/2)*((y/(x+y))^2))) == 0, x, y, l )
After about 10 minutes I get the error message;
Warning: Explicit solution could not be found.
> In solve at 179
I have googled the problem and have seen other posts pointing to the use of numerical methods, but have no idea how i would write the code.
I would greatly appreciate any help on this.
Thanks, Kai
Accepted Answer
More Answers (1)
Walter Roberson
on 4 Mar 2014
0 votes
It appears to me that a solution does exist but that it is so long that MATLAB cannot calculate it.
You are working with 4th-order equations (quartics), and symbolic solutions to quartics are seldom profitable.
What were you planning to do with the x, y, z once you had obtained them symbolically ?
6 Comments
Kai
on 4 Mar 2014
Walter Roberson
on 5 Mar 2014
It appears to me that it is possible to get lambda in terms of d, and free of x and y, but that the resulting expression would be several tens of megabytes long at least and would not be humanly comprehensible. It would probably also be fairly sensitive to round-off errors and would probably be numerically sensitive on the inputs. This is a case where making a numeric approximation for specific inputs would probably make more sense. I would even suggest you might well be better using monte carlo methods.
Star Strider
on 5 Mar 2014
When I tried solving for either ‘l’ alone or ‘[l, x, y]’ I got empty matrices ‘[]’ after a few minutes as the result. (This in 2013b.)
There may not be a symbolic solution. The numeric optimisation routines might be your best option.
Kai
on 5 Mar 2014
Star Strider
on 5 Mar 2014
Do you have the Optimization Toolbox? Alan Weiss has posted some ideas. Otherwise, consider the optimisation functions available as MATLAB core functions.
I suggest that first, you see the documentation for the solver you want to use to be sure your objective function is in a form the solver needs. Then with the Symbolic Math Toolbox, use the ‘subs’ function to convert your parameters to a subscripted parameter vector, and use ‘matlabFunction’ to convert your symbolic equations into code the solver can use.
Note that in Alan’s answer, he mentions that the solvers calculate the Lagrange multipliers, so you will have to start with your original equations, rather than the ones you posted here.
Kai
on 5 Mar 2014
Categories
Find more on Symbolic Math Toolbox 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!
