# Characteristic polynomial wont be used in solve

When I try to find roots in a characteristic polynomial it gives me errors:

sage: #Diagonalmatrix
....:
....:
....: A=matrix([[1,-1,2],
....:         [-1,1,2],
....:         [2,2,-2]])
....: var('x')
....: poly=A.characteristic_polynomial()
....: eq1=solve(poly==0,x)
....:
x
--------------------------------------------------
TypeError        Traceback (most recent call last)
<ipython-input-86-fee7a7de2ea1> in <module>()
7 var('x')
8 poly=A.characteristic_polynomial()
----> 9 eq1=solve(poly==Integer(0),x)

/usr/lib/python2.7/site-packages/sage/symbolic/relation.pyc in solve(f, *args, **kwds)
816
817     if not isinstance(f, (list, tuple)):
--> 818         raise TypeError("The first argument must be a symbolic expression or a list of symbolic expressions.")
819
820     if len(f)==1:

TypeError: The first argument must be a symbolic expression or a list of symbolic expressions.
sage:


What can I do in order to use the polynomial in an equation I wish to solve?

edit retag close merge delete

Sort by » oldest newest most voted

As you can see, poly is a genuine polynomial, not a symbolic expression:

sage: poly.parent()
Univariate Polynomial Ring in x over Integer Ri


You can get its roots as follows:

sage: poly.roots()
[(-4, 1), (2, 2)]


So, you can see, that it has root -4 wirh multiplicity 1 anr roor 2· with multiplicity 2.

Note that poly. == 0 is the boolean False, since the polynomial is not the zero polynomial:

sage: poly == 0
False


If you really want to use solve, you need to transform the polynomial into a symbolic expression as follows:

sage: SR(poly)
x^3 - 12*x + 16
sage: SR(poly).parent()
Symbolic Ring


Then, you can do:

sage: solve(SR(poly),x)
[x == -4, x == 2]

more

Thanks a lot!

( 2017-11-23 11:34:58 -0600 )edit