Solver Equation not giving solution

2 vues (au cours des 30 derniers jours)
Diogo Dias
Diogo Dias le 19 Mai 2020
I want to know the x value of this equation but is giving error i did this:
>> syms x k px
>> eq1 = k == 0.04;
>> eq2 = px ==3.5;
>> eq3 = k== (x./1-x)*sqrt((2*px)./(2+x));
>> sol = solve([eq1,eq2,eq3],[x,k,px]);
>> xsol = sol.x
xsol =
Empty sym: 0-by-1
>>
  1 commentaire
Diogo Dias
Diogo Dias le 19 Mai 2020
eq3 = k== (x./(1-x))*sqrt((2*px)./(2+x)); **
but now it says: Warning: Solutions are valid under the following conditions: (z1 == 1 | signIm(((z1 - 1)*1i)/z1) == -1) & z1^3
- 4375*z1^2 - 3*z1 + 2 == 0 & z1 ~= 1 & z1 ~= -2. To include parameters and conditions in the solution,
specify the 'ReturnConditions' value as 'true'.
> In solve>warnIfParams (line 482)
In solve (line 357)

Connectez-vous pour commenter.

Réponses (1)

David Goodmanson
David Goodmanson le 22 Mai 2020
Hi Diogo,
Matlab syms can solve this, but it needs some help, which is squaring both sides of eqn3 to form a new eqn3. Also since k and px have numeric values there is no need to declare them as syms. An economy sized version of the code is
syms x
k = .04;
px = 3.5;
% eq3 = k == (x./1-x)*sqrt((2*px)./(2+x));
eq3 = k^2 == (x./(1-x)).^2.*(2*px)./(2+x);
sol = solve(eq3,x)
sol =
root(z^3 - 4375*z^2 - 3*z + 2, z, 1)
root(z^3 - 4375*z^2 - 3*z + 2, z, 2)
root(z^3 - 4375*z^2 - 3*z + 2, z, 3)
vpa(sol,10)
ans =
0.02104084079
-0.02172645048
4375.000686
All three roots work for the squared eq3 but it's necessary to go back to the original eq3 and see how many solutions there are. It turns out that the first listed root above works if you take the positive square root in eq3 and the second two listed roots work for the negative square root in eq3.

Community Treasure Hunt

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

Start Hunting!

Translated by