Order of solutions with symbolic solver seems to be arbitrary
3 views (last 30 days)
Show older comments
Hi,
I am using symbolic toolbox to solve a set of 5 equations with 5 variables over a range of input conditions. I have made the assumption that the solutions are real and positive and I get two valid roots. I assign these two solutions to two variables and plot them. The resulting plot is shown below. As can be seen, there is a point where the solutions appear to switch "position", i.e. [x1;x2] becomes [x2;x1] - as I assume the variable does not display the characteristics of the observed curves.
Is there any rule that dictates the order of solutions produced from solve? I have been working with another set of 6 equations and have never seen this switching phenomenon. I need to test the validity of these solutions, so it would be good to understand how solve works when producing output from the solver.
Regards, matt
Code snippet:
eq1_2 = alpha*(uf - s0) - mu0*x0;
eq2_2 = -alpha*x0 + mu0*x0 - A*x0;
eq3_2 = -alpha*s1 + omega1*mu0*x0 - mu1*x1;
eq4_2 = -alpha*x1 + mu1*x1 - B*x1;
eq5_2 = -alpha*s2 + omega2*mu1*x1 - mu0*rho*x0;
solveB=solve(eq1_2,eq2_2,eq3_2,eq4_2,eq5_2,'Real',true);
if ~isempty(solveB)
for k=1:length(solveB.x0)
eval(['S2_xch' num2str(k) '(mm,nn)=vpa(solveB.x0(k));'])
eval(['S2_sch' num2str(k) '(mm,nn)=vpa(solveB.s0(k));'])
eval(['S2_xph' num2str(k) '(mm,nn)=vpa(solveB.x1(k));'])
eval(['S2_sph' num2str(k) '(mm,nn)=vpa(solveB.s1(k));'])
eval(['S2_sh' num2str(k) '(mm,nn)=vpa(solveB.s2(k));'])
end
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/148351/image.png)
0 Comments
Answers (1)
Walter Roberson
on 11 Jun 2013
In the general case, NO, the solutions do not have any order between themselves, but they will be consistent within the variables (e.g., the third solution for x0 will correspond to the third solution for s2)
I think I have encountered some cases where the solutions were said to be ordered by absolute magnitude, or by phase angle within absolute magnitude.
When I use the 5 equations you give, and solve for x0, s0, x1, s1, s2, then the solution I get is s0 = uf and everything else is 0.
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!