How to return the original polynomial from the calculated roots

1 次查看(过去 30 天)
Hi MATLAB experts,
I have following example:
Solve the equation 3x^2-2x-4
Create a vector to represent the polynomial, then find the roots.
>> p=[3 -2 -4];
>> r=roots(p)
ans =
1.5352
-0.8685
I find the roots and wanted to return back the same polynomial coefficients i used the follwing code:
>> poly(r)
ans =
1.0000 -0.6667 -1.3333
But the coefficients are not the same as the original polynomial coefficients.
The question is how to get or return the original polynomial coefficients?
Thanks & regards,
Basim Touqan

回答(1 个)

Dyuman Joshi
Dyuman Joshi 2021-5-1
So, the coefficients are not the same, but they are similar.
%[1 -0.6667 -1.3333] is equal to [3 -2 4]/3.
This is because, poly() calculates equation in the form of x^2+b*x+c (a=1) instead of the generalised form a*x^2+b*x+c (i.e. the function is written in such a way).
If you want your solution to be in the generalised form, what you can do is multiply the equation with the first member of original equation.
p=[3 -2 4];
r=roots(p);
q=p(1)*poly(r);

类别

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