Say I have a SymPy PurePoly, how can I evaluate its value for a given square matrix? Just passing it to eval raises an exception. Here's what I have tried:
import sympy as sp
from sympy.matrices import Matrix
from sympy.polys.polytools import PurePoly
x = sp.symbols('x')
P = PurePoly(x**2 + 3 * x + 4, x)
M = Matrix([[1,2],[3,4]])
P.eval(M) # does not work!
I know that this is possible for an expression built from MatrixSymbols, but I do not know how to transform a PurePoly into this representation.