polynomial in matlab roots
6 次查看(过去 30 天)
显示 更早的评论
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
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
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.
0 个评论
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
2016-1-7
Since we don't know the background of your question, we can not answer it.
Best wishes
Torsten.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Polynomials 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!