Ask Your Question
2

convert charpoly()-generated characteristic polynom to symbolic expression

asked 2018-06-03 12:33:33 -0500

bekalph gravatar image

A characteristic polynom that is generated by the procedure charpoly() has the type:

sage.rings.polynomial.polynomial_ring.PolynomialRing_field_with_category.element_class.

How can I convert it to one of type 'symbolic expression' without doing 'copy and paste'?

edit retag flag offensive close merge delete

2 answers

Sort by » oldest newest most voted
2

answered 2018-06-04 01:26:24 -0500

Sébastien gravatar image

You can use the

sage: SR
Symbolic Ring

to convert the expression you get:

sage: m = random_matrix(ZZ, 3, 3)
sage: p = m.charpoly()
sage: type(p)
<type 'sage.rings.polynomial.polynomial_integer_dense_flint.Polynomial_integer_dense_flint'>
sage: SR(p)
x^3 + 2*x^2 - 8*x + 5
sage: type(_)
<type 'sage.symbolic.expression.Expression'>

Make sure you really need the symbolic ring. In many cases, you can get what you want more efficiently without converting to symbolic ring.

edit flag offensive delete link more

Comments

Thank you very much for the hint. I need the conversion to SR in order to simplify the expression with canonicalize_radical() or with factor(). This seems not be possible if I apply them on the unconverted expression (unimplemented error or attribute error). I just found that characteristic polynomals of matrices can also be converted to SR by substituting one of their symbols with subs.

bekalph gravatar imagebekalph ( 2018-06-04 13:51:16 -0500 )edit
1

answered 2018-06-04 14:57:09 -0500

bekalph gravatar image

I just found that characteristic polynomals of matrices can also be converted to SR by substituting one of their symbols with subs.

edit flag offensive delete link more

Your Answer

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

Add Answer

Question Tools

Stats

Asked: 2018-06-03 12:33:33 -0500

Seen: 58 times

Last updated: Jun 04