The coefficients of the polynomial usually come from R; this will be our default assumption. If you want everything to be a matrix, change a coefficient, like 5, into 5 times the identity matrix. Now 5 can be multiplied by x2 using matrix multiplication. It's really the same whether you turn 5 into a matrix or leave it as a scalar, as long as you know how to apply the action of 5 to x2.