Solver Equation not giving solution

1 回表示 (過去 30 日間)
Diogo Dias
Diogo Dias 2020 年 5 月 19 日
回答済み: David Goodmanson 2020 年 5 月 22 日
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 件のコメント
Diogo Dias
Diogo Dias 2020 年 5 月 19 日
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)

サインインしてコメントする。

回答 (1 件)

David Goodmanson
David Goodmanson 2020 年 5 月 22 日
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.

カテゴリ

Help Center および File ExchangeCalculus についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by