finding real roots of polynomials

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 Commento

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.

Accedi per commentare.

Risposte (1)

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

Categorie

Scopri di più su Mathematics in Centro assistenza e File Exchange

Richiesto:

il 10 Set 2019

Commentato:

il 10 Set 2019

Community Treasure Hunt

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

Start Hunting!

Translated by