MATLAB: Derive an equation from a set of roots

derivepolynomial

the question asks me to set x as a symbolic variable then asks me to derive a equation of a polynomial with the roots x=-2 ,x=-.5, x=2, and x=4.5

Best Answer

syms x
r = [-2 , -.5 2 4.5]; % roots
f = (x-r(1))*(x-r(2))*(x-r(3))*(x-r(4)) ;
p = expand(f)