Borrar filtros
Borrar filtros

polynomial in matlab roots

1 visualización (últimos 30 días)
mar vouz
mar vouz el 6 de En. de 2016
Comentada: mar vouz el 7 de En. de 2016
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 comentario
Roger Stafford
Roger Stafford el 6 de En. de 2016
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.

Iniciar sesión para comentar.

Respuestas (2)

Walter Roberson
Walter Roberson el 6 de En. de 2016
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 el 6 de En. de 2016
Editada: John D'Errico el 6 de En. de 2016
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 comentarios
Torsten
Torsten el 7 de En. de 2016
Since we don't know the background of your question, we can not answer it.
Best wishes
Torsten.
mar vouz
mar vouz el 7 de En. de 2016
thank you very much everyone!

Iniciar sesión para comentar.

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!

Translated by