Ask Your Question

Factorize characteristic polynomial in SR base ring

I am total newbie to SAGE so this question might be trivial. How can I factorize the characteristic polynomial obtained by a symbolic matrix in SAGE 8.6? Is there a workaround the fact that factor() is not defined on the base ring SR which is the one inherited from the symbolic matrix?

For example I have in a SAGE/Jupyter notebook something like:

a,b,c = var('a','b','c')
M = Matrix(SR,3,3)
M[0] = [a, -b, 0]
M[1] = [c, a+b, 0]
M[2] = [0, 0, 1]
e = M.eigenvalues()
f = M.charpoly()
factor(f)


The last instruction raises a NotImplementedError as expected from the fact that factor is not defined on SR... In my real problem I am computing characteristic polynomials of large (8x8) symbolic matrices and I would like to get at glance all the factors, so as to quickly isolate negative real roots and instead easily discuss conditions for existence and sign of symbolic ones.

edit retag close merge delete

1 answer

Sort by » oldest newest most voted

Actually, it's just that factor isn't defined on univariate polynomials over SR. If charpoly were returned as an element of SR, there could be trouble if the matrix already contains an x, as in matrix([SR('x')]).charpoly(). You can put it in SR and then you can factor it:

sage: factor(f(SR('x')))
(a^2 + a*b + b*c - 2*a*x - b*x + x^2)*(x - 1)


As you can see:

sage: parent(f)
Univariate Polynomial Ring in x over Symbolic Ring


the polynomial f doesn't lie in SR, but in a univariate polynomial over SR. By evaluating the polynomial in an element of SR we can map it into SR, though. With SR('x') you create the symbol x. You can also use SR.var('x') if you prefer. It's different from the variable in which f is expressed, even though they print the same:

sage: parent(f).0
x
sage: parent(f).0 == SR('x')
False

more

Comments

Awesome thanks. @nbruin if you don't mind, I was missing the possibility for this command: SR('x'). This tells Sage basically to use the unknown x within the SR field? Or how should I interpret it? 'Cause it is not completely immediate for me that I am using a base ring class as a method, unless I think of it as a short way to instantiate a variable of that class (something like : in C++ class definers).

( 2019-01-31 14:30:24 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Stats

Asked: 2019-01-31 11:26:46 -0500

Seen: 93 times

Last updated: Jan 31 '19