Solver Equation not giving solution

조회 수: 2 (최근 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 CenterFile Exchange에서 Calculus에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by