Complete the code to evaluate the polynomial p at x = 2.
p = [1 -3 2]; y = polyval(p, [1]);
The function polyval evaluates the polynomial p at the given value. Here, we want to evaluate at 2.
Complete the code to find the roots of the polynomial p.
p = [1 -3 2]; r = [1](p);
polyval instead of roots.find which is for arrays, not polynomials.The roots function returns the roots of the polynomial defined by the vector p.
Fix the error in the code to correctly evaluate the polynomial p at x = 5.
p = [2 0 -1 3]; y = polyval([1], 5);
polyval.The first argument to polyval must be the polynomial coefficients vector p, not the evaluation point.
Fill both blanks to create a polynomial vector for p(x) = 3x^2 - 4x + 1 and evaluate it at x = 3.
p = [[1] [2] 1]; y = polyval(p, 3);
The polynomial coefficients are in descending powers: 3 for x^2, -4 for x, and 1 constant.
Fill all three blanks to create a polynomial vector for p(x) = x^3 - 6x^2 + 11x - 6 and find its roots.
p = [[1] [2] [3] -6]; r = roots(p);
The polynomial coefficients are for x^3, x^2, and x terms respectively: 1, -6, and 11.