How do you evaluate a matrix polynomial with Sage ? The obvious way doesn't work :
sage: P=x^2 sage: P(x=4) 16 sage: M=matrix([(1, -3, -1),(0, 1, 1),(-1, 2, 1)]) sage: P(x=M) --------------------------------------------------------------------------- TypeError Traceback (most recent call last) <ipython-input-17-8ee97bd86c6b> in <module>() ----> 1 P(x=M) /usr/lib/sagemath/local/lib/python2.7/site-packages/sage/symbolic/expression.so in sage.symbolic.expression.Expression.__call__ (sage/symbolic/expression.cpp:19165)() /usr/lib/sagemath/local/lib/python2.7/site-packages/sage/symbolic/ring.so in sage.symbolic.ring.SymbolicRing._call_element_ (sage/symbolic/ring.cpp:7589)() /usr/lib/sagemath/local/lib/python2.7/site-packages/sage/symbolic/expression.so in sage.symbolic.expression.Expression.substitute (sage/symbolic/expression.cpp:18422)() /usr/lib/sagemath/local/lib/python2.7/site-packages/sage/symbolic/expression.so in sage.symbolic.expression.Expression.coerce_in (sage/symbolic/expression.cpp:13293)() /usr/lib/sagemath/local/lib/python2.7/site-packages/sage/structure/parent_old.so in sage.structure.parent_old.Parent._coerce_ (sage/structure/parent_old.c:3652)() /usr/lib/sagemath/local/lib/python2.7/site-packages/sage/structure/parent.so in sage.structure.parent.Parent.coerce (sage/structure/parent.c:8850)() TypeError: no canonical coercion from Full MatrixSpace of 3 by 3 dense matrices over Integer Ring to Symbolic Ring sage: Q=M.charpoly() sage: Q(x=M) [0 0 0] [0 0 0] [0 0 0] sage: Thanks -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/groups/opt_out.
