How do I generate a polynomial from roots that are repeated?

5 次查看(过去 30 天)
So I've got the roots of a polynomial from which I want to design the polynomial.
The thing is that I've got 8 roots, 4 of which are repeated. These are the roots I have:
-0.7437 - 1.4178i
-0.7437 - 1.4178i
-1.1031 + 0.1267i
-1.1031 + 0.1267i
-0.4571 + 0.9526i
-0.4571 + 0.9526i
-0.0977 + 1.0976i
-0.0977 + 1.0976i
When I do the polynomial by using the function poly, I get the polynomial that corresponds to the 8 roots but I'd like the polynomial for only the 4, non-repeated roots.
How could I do this? (I know I could probably eliminate the repeated, but I'd like a function that considers repeated roots or something).
Thanks in advance

采纳的回答

Star Strider
Star Strider 2020-11-28
编辑:Star Strider 2020-11-28
Iinteresting. I would expect no repeats, and complex conjugate values instead.
Try this:
rts = [ -0.7437 - 1.4178i
-0.7437 - 1.4178i
-1.1031 + 0.1267i
-1.1031 + 0.1267i
-0.4571 + 0.9526i
-0.4571 + 0.9526i
-0.0977 + 1.0976i
-0.0977 + 1.0976i];
Urts = unique(rts);
p1 = poly(Urts);
Ucrts = [Urts; conj(Urts)];
p2 = poly(Ucrts);
.
  4 个评论

请先登录,再进行评论。

更多回答(1 个)

Image Analyst
Image Analyst 2020-11-28
Did you try just multiplying them all together?
x = linspace(-8, 5, 1000);
r1 = -0.7437 - 1.4178i
r2 = -0.7437 - 1.4178i
r3 = -1.1031 + 0.1267i
r4 = -1.1031 + 0.1267i
r5 = -0.4571 + 0.9526i
r6 = -0.4571 + 0.9526i
r7 = -0.0977 + 1.0976i
r8 = -0.0977 + 1.0976i
y = (x-r1).*(x-r2).*(x-r3).*(x-r4).*(x-r5).*(x-r6).*(x-r7).*(x-r8)
plot(x, real(y), 'r-', 'LineWidth', 2);
hold on;
plot(x, imag(y), 'b-', 'LineWidth', 2);
grid on;
legend('Real', 'Imaginary');
  2 个评论
Guillem Campins
Guillem Campins 2020-11-28
Hmm the problem with that is that I need the value of the polynomial in a straight form (as in x^3+2x^2+1) more than I need the plot, and the polynomial is expressed in a very non-straight form by doing that.
Thanks for the effort, though :)
Image Analyst
Image Analyst 2020-11-28
Maybe might have to use the symbolic toolbox, which I don't have, to do the multiplication.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Polynomials 的更多信息

产品


版本

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by