Real Roots of a Polynomial
146 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I have used "solve" to factor a fourth order polynomial. It has four roots with three complex numbers. I used:
xf = solve(x^4+7*x^3-8*x^2+5*x+2,x)
if (isreal(xf)==1)
...
end;
to try to pull out the real roots but it did not work.
Is there a better way?
2 comentarios
Matt Kindig
el 18 de Sept. de 2013
Editada: Matt Kindig
el 18 de Sept. de 2013
Are you sure there are real roots to the polynomial? It is not a given that there are.
Azzi Abdelmalek
el 18 de Sept. de 2013
Polynomial with real coefficient can not have an odd number of complex roots,
Respuesta aceptada
Roger Stafford
el 18 de Sept. de 2013
Editada: Roger Stafford
el 18 de Sept. de 2013
Use 'roots' to find the roots of polynomials.
r = roots([1,7,-8,5,1]); % Get all the roots
r = r(imag(r)==0); % Save only the real roots
The 'isreal' function is true only if All elements of a vector are real, so it isn't appropriate for sorting out the real roots.
A polynomial with all real coefficients such as yours cannot have an odd number of complex roots. They must occur in conjugate pairs. As you see, in your particular polynomial there are just two complex roots, which are conjugates of one another.
1 comentario
Philosophaie
el 18 de Sept. de 2013
Editada: Philosophaie
el 18 de Sept. de 2013
Más respuestas (1)
Azzi Abdelmalek
el 18 de Sept. de 2013
%P=x^4+7*x^3-8*x^2+5*x+2
p=[1 7 -8 5 2]
result=roots(p)
2 comentarios
Azzi Abdelmalek
el 18 de Sept. de 2013
If all your roots are real,
syms x
factor(x^4+7*x^3-8*x^2+5*x+2)
should work
Roger Stafford
el 18 de Sept. de 2013
Only two of the roots are real. The other two are a complex conjugate pair. However the polynomial can still be factored using these complex values.
Ver también
Categorías
Más información sobre Polynomials en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!