필터 지우기
필터 지우기

Real Roots of a Polynomial

조회 수: 62 (최근 30일)
Philosophaie
Philosophaie 2013년 9월 18일
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
Matt Kindig
Matt Kindig 2013년 9월 18일
편집: Matt Kindig 2013년 9월 18일
Are you sure there are real roots to the polynomial? It is not a given that there are.
Azzi Abdelmalek
Azzi Abdelmalek 2013년 9월 18일
Polynomial with real coefficient can not have an odd number of complex roots,

댓글을 달려면 로그인하십시오.

채택된 답변

Roger Stafford
Roger Stafford 2013년 9월 18일
편집: Roger Stafford 2013년 9월 18일
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
Philosophaie
Philosophaie 2013년 9월 18일
편집: Philosophaie 2013년 9월 18일
I get:
acp1 =
[ empty sym ]
There is a real root to the polynomial in question.
It works my mistake.
Is there any way of getting Matlab to complete the addition,subtraction, mult and divide?

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Azzi Abdelmalek
Azzi Abdelmalek 2013년 9월 18일
%P=x^4+7*x^3-8*x^2+5*x+2
p=[1 7 -8 5 2]
result=roots(p)
  댓글 수: 2
Azzi Abdelmalek
Azzi Abdelmalek 2013년 9월 18일
If all your roots are real,
syms x
factor(x^4+7*x^3-8*x^2+5*x+2)
should work
Roger Stafford
Roger Stafford 2013년 9월 18일
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.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Polynomials에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by