finding real roots of polynomials

16 次查看(过去 30 天)
I have an equation like P=((E*D)/(1-V^2)*M*K^2*B^2)*((H-D/2)*(H-D)*T+T^3). I would like to write this equation as D is output value and P is the input value. Therefore, I have written the code as given below. I have a problem about solution. I obtained just complex roots but I want to obtain just real root.
Can someone help me to find the real roots with this method?
Thanks in advance
syms D E V M K B H T P
eqn = P-((E*D)/(1-V^2)*M*K^2*B^2)*((H-D/2)*(H-D)*T+T^3)==0 ;
sol = solve(eqn)
solD = solve(eqn, D)
S = solve(eqn, D, 'MaxDegree', 3);
pretty(S)
  1 个评论
Walter Roberson
Walter Roberson 2019-9-10
syms D E V M K B H T P
That defines all of the symbols to be complex-valued (with a possibly 0 imaginary part). You are not using operations such as abs() or multiplying by complex conjugates, so it must be assumed that all of your roots are complex.

请先登录,再进行评论。

回答(1 个)

Star Strider
Star Strider 2019-9-10
With only symbolic variables, it is not possible to determine if any of the roots are complex, unless one or more of the variables is initially defined to be complex, or you do a complex operation on them.
With numeric values, as in your earlier Question solving nonlinear equations in matlab, to get the get the real roots, return only those values without an imaginary component.
So starting with:
Ssol =
1.2272645680296059191773342534578
- 0.16363228401480295958866712672892 - 1.5983944082554683248490550151884i
- 0.16363228401480295958866712672892 + 1.5983944082554683248490550151884i
the real roots are:
RealRoots = Ssol(imag(Ssol)==0)
producing:
RealRoots =
1.2272645680296059191773342534578
If you do that with your symbolic code:
RealS = S(imag(S)==0)
the result is:
RealS =
Empty sym: 0-by-1

类别

Help CenterFile Exchange 中查找有关 Equation Solving 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by