polynomial in matlab roots

조회 수: 5 (최근 30일)
mar vouz
mar vouz 2016년 1월 6일
댓글: mar vouz 2016년 1월 7일
Hey ,I have a matrix
X= 0 0,142857142857143 0,285714285714286 0,428571428571429 0,571428571428571 0,714285714285714 0,857142857142857 1
and a matrix
Y=185654
189978
189202
192877
196255
200642
201231
206046
so I created the polynomial by p=polyfit(X,Y,7) and I was asked to find the real solutions of this so I used r=roots(p) and all i get are imaginary numbers. Why?
  댓글 수: 1
Roger Stafford
Roger Stafford 2016년 1월 6일
It is not clear what "real solutions" you are trying to find. Solutions to what? The expression "roots(p)" would give you the points where p has a zero value and presumably there are none that are real-valued.
Since you have used degree 7 with 8 points, your polynomial p should match the values of Y at the points X precisely except for tiny round-off errors. Is that the "solution" you are seeking? In that case you already have it.

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

답변 (2개)

Walter Roberson
Walter Roberson 2016년 1월 6일
Polynomials with an odd number of roots always enter through one side of the Y axis and exit through the other side of the Y axis (because -infinity to an odd power is still negative infinity, opposite sign of +infinity to an odd power, whereas for even number of roots, -infinity to an even power is positive infinity same as +infinity to an even power so with an even number of roots the graph will start and end on the same side.)
The graph plot(X,Y) enters from the lower left so it has to exit through the upper right. It does not cross 0 anywhere in the range of values so there are no internal real roots. The first value is positive. Therefore there must be a single real root that is to the lower left of the graph at an X smaller than any given value.
There would have to be some visible zero crossings within the defined range for there to be multiple real roots.

John D'Errico
John D'Errico 2016년 1월 6일
편집: John D'Errico 2016년 1월 6일
A 7th degree polynomial (with real coefficients) has at least ONE real root.
p = polyfit(X,Y',7);
roots(p)
ans =
1.0951 + 0.20415i
1.0951 - 0.20415i
0.63639 + 0.47627i
0.63639 - 0.47627i
0.10224 + 0.36777i
0.10224 - 0.36777i
-0.15631 + 0i
Note that the last root is NOT complex. It has a zero imaginary part. It is the only real root, at x=-0.15631...
  댓글 수: 6
Torsten
Torsten 2016년 1월 7일
Since we don't know the background of your question, we can not answer it.
Best wishes
Torsten.
mar vouz
mar vouz 2016년 1월 7일
thank you very much everyone!

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

카테고리

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