can anyone explain this result ?

i have a polynomial p = [ 3 -5 2 ]
i have calculated his roots r = roots(p) r= 1.0000 0.6667
then i wanted to obtain the expression of my polynomial i get:
expression=poly(r)
expression= 1.0000 -1.6667 0.6667
which is not my first polynomial, can anyone explain to me?

回答 (2 件)

Cam Salzberger
Cam Salzberger 2017 年 10 月 23 日

1 投票

Hello Diadalina,
According to the poly function's documenation, poly and roots are inverses, but allowing for roundoff error, ordering, and scaling. If you notice in your code, expression == p/3, which is just p scaled by its first element. It's still solves the same equation:
3*x^2 - 5*x + 2 = 0
or
x^2 - (5/3)*x + 2/3 = 0
-Cam

1 件のコメント

Walter Roberson
Walter Roberson 2017 年 10 月 23 日
Note that this means that given the roots of an polynomial, you can only recreate the equation to within a non-zero constant multiple.
Andrei Bobrov
Andrei Bobrov 2017 年 10 月 23 日

0 投票

:)
>> expression= [1.0000 -1.6667 0.6667]
expression =
1.0000 -1.6667 0.6667
>> expression*3
ans =
3.0000 -5.0001 2.0001
>>

4 件のコメント

diadalina
diadalina 2017 年 10 月 23 日
thank you sir, now I understand why, but if I want to go the opposite way, from the roots I want to find the expression of the polynom which command should I use
Andrei Bobrov
Andrei Bobrov 2017 年 10 月 23 日
編集済み: Andrei Bobrov 2017 年 10 月 23 日
Through two points on the axis 0x there passes an infinite set of polynomials. You need a third point for a single polynomial.
diadalina
diadalina 2017 年 10 月 23 日
that's mean that the found roots are not exacts?
Cam Salzberger
Cam Salzberger 2017 年 10 月 23 日
If you are asking that because there are multiple possible polynomials with the same roots, then no, they can be exact answers. If you multiple any polynomial by a constant, you will have a new polynomial. However, they will all have the same roots. So while you can't necessarily expect to get the exact same polynomial out of "poly" based solely on the original roots, you can expect to get a multiple of it (at least for vectors).
If you're asking that because the result of "expression*3" was -5.0001 instead of exactly -5, that's simply due to Andrei's example vector including -1.6667 instead of -5/3. Always bear in mind, however, that machine precision is a thing. There is no infinite accuracy, so you may run into precision errors sooner or later.

この質問は閉じられています。

質問済み:

2017 年 10 月 23 日

閉鎖済み:

2021 年 8 月 20 日

Community Treasure Hunt

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

Start Hunting!

Translated by