How do I derive polynomial using given roots?
17 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Victor
am 1 Mär. 2012
Kommentiert: Steven Lord
am 10 Aug. 2023
Given the known roots -2 -0.5 2 4.5
I am asked to define a symbolic variable 'x'
and derive the symbolic polynomial for the given roots
I have searched google several times to no avail, can anyone help me with this?
0 Kommentare
Akzeptierte Antwort
Andrei Bobrov
am 1 Mär. 2012
v = [-2 -0.5 2 4.5]
x= sym('x')
yourpoly = expand(prod(x-v))
2 Kommentare
Steven Lord
am 10 Aug. 2023
Try it!
r = [-1 1+3i 1-3i];
x = sym('x');
yourpoly = expand(prod(x-r))
check = solve(yourpoly)
Looks good to me. [Yes, the elements in check are in a different order than they appear in r. This is not a bug.]
Another approach, if you want to do this numerically, is to use the poly function in MATLAB. This returns the vector of coefficients, but we can write it as an expression in the symbolic variable using poly2sym.
p2 = poly(r)
yourpoly2 = poly2sym(p2, x)
Let's make sure the two results are the same.
check = isAlways(yourpoly == yourpoly2)
Weitere Antworten (0)
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
