Effacer les filtres
Effacer les filtres

How to return the original polynomial from the calculated roots

1 vue (au cours des 30 derniers jours)
Basim Touqan
Basim Touqan le 28 Avr 2021
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

Réponses (1)

Dyuman Joshi
Dyuman Joshi le 1 Mai 2021
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);

Catégories

En savoir plus sur Polynomials dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by