Question 1) You can call real(ans) to keep only the real part and remove the imaginary part.
Question 2) On the basis of the question 1, even if real is called, only the real part is kept, so that the result of roots seems to be-1.0000, and the result of calling polyval will not be 0. This is because matlab shows only a limited number of decimal places, which looks like-1.0000, but it may actually be-1.000000000000091,so using polyval will only get a small enough number (you have 65438+ here). And calling polyval with [-1-1] will get 0, because-1is an exact integer.