# Matlab gives wrong solution of a nonlinear system of equations.

9 views (last 30 days)
F.O on 2 Jan 2020
Commented: F.O on 9 Jan 2020
I had bigger (6 equations) system of ODE and reduced it to the follwing system to check if we cand find equilibruim points .
The code:
syms x y1 y2 real;
assume (x>=0,y1>=0,y2>=0);
syms m1 m2 epsilon1 epsilon2 positive;
syms omega11 omega12 omega 21 omefa22 positive;
syms b12 p12 gamma12 beta1 beta2 positive;
F2=x*(1-x-y1/(m1*y1+x)-y2/(m2*y2+x))==0;
F6=y1*(-epsilon1*(1+omega11*y1+omega12*y2)-(b12*y2)/(p12*y2+y1)+(beta1*x)/(m1*y1+x))==0;
F7=y2*(-epsilon2*(1+omega21*y1+omega22*y2)+(gamma12*y1)/(p12*y2+y1)+(beta2*x)/(m2*y2+x))==0;
eqns=[F2,F6,F7];
diary('SolutionOfEquation_Subsystem_NonDim_RDFR_Condition.txt')
S = solve(eqns,[x,y1,y2], 'returnconditions', true);
x=latex(S.x)
y1=latex(S.y1)
y2=latex(S.y2)
S.x
S.y1
S.y2
However Matlab gave one solution in term of z and others in terms of parameters ,what does that mean and how I can use the results? Is (z,z1,z2) a free solution?
Is it possible to get z's in terms of parameters ?
The solution is in the attached file.
I also tried to check if the solution is satisfies the equations but find out that just the first and second do and others no.

darova on 8 Jan 2020
Use ode45 or dsolve
F.O on 8 Jan 2020
@darova I am solving the steady state system not ODE system here. Analytical solution using dsolve is not possible because I tried.
Walter Roberson on 8 Jan 2020
The poster is not looking for results for any one set of specific numeric values for the 13 parameters: the poster is looking for the symbolic solution in 13 parameters and is looking for all of the solutions, not just one.
Unfortunately, some of the solution branches require solving polynomial of degree 5 and other branches require solving polynomial of degree 7.
It would perhaps be acceptable to state some of the variables in terms of the roots of high degree polynomials, but the poster also has a need to characterize all the conditions under which the solutions are valid. That is not exactly the same as solving the polynomial, but it does require characterizing the conditions under which the roots of the polynomial are real valued which appears to be approachable (with some work) for numeric coefficients but not so much for symbolic coefficients https://mathoverflow.net/questions/20946/criteria-to-determine-whether-a-real-coefficient-polynomial-has-real-root (symbolic eigenvalues are not realistically calculable for 5x5 or larger especially for coefficients as complicated as would be required here)

Walter Roberson on 7 Jan 2020
The answer to the question is, NO, it is not possible to get z in terms of the parameters.
... At least not if, like me, you only have 32 gigabytes of memory.
Your system generates many different branches of conditional cases. Working all of the cases through takes a lot of time to figure out how to proceed, and takes even more memory. I ended up having to kill the process after it started swapping my system.
I suspect you just might be able to get further if you were to remove some of the constraints to positive, as that would reduce the number of different cases to consider. You would then weed through through the results after you had the general framework.

Show 3 older comments
Walter Roberson on 8 Jan 2020
How many parameters does the author have to work with in that paper?
F.O on 8 Jan 2020
10 after nondimensionallizing
F.O on 9 Jan 2020
I tried to replace (b12*y2)/(p12*y2+y1) by just b12*y2 and (gamma12*y1)/(p12*y2+y1) by gamma12*y1 i.e using linear functional response but still got parametrized solution in case of imposing condition and error in case not imposing any condition.

### More Answers (1)

James Browne on 7 Jan 2020
Looks like you have quite a bit going on there. I am not very familiar with doing symbolic maths with MATLAB, but I can tell you that you have a syntax error in the first line of your code.
Here is a link to the help page for the syms function:
Note that the input variables are separated by spaces in all of the examples, not commas. I am not really sure what this is causing MATLAB to do, but it does not seem to be working correctly and you can tell this by looking at your input arguments on line 1. They should all be highlighted in purple, like the examples on the help page, but only the variable "x" is highlighted, along with your variable type selection.
I would try deleting your commas and use spaces to separate your input aruments in the syms function on line 1.

#### 1 Comment

F.O on 7 Jan 2020
it is a typo here sorry. In my atual code I don't have comma. I will edit the question.

R2019b

### Community Treasure Hunt

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

Start Hunting!