First time here? Check out the FAQ!

Ask Your Question
2

convert charpoly()-generated characteristic polynom to symbolic expression

asked 6 years ago

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'?

Preview: (hide)

2 Answers

Sort by » oldest newest most voted
2

answered 6 years ago

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.

Preview: (hide)
link

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 ( 6 years ago )
1

answered 6 years ago

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.

Preview: (hide)
link

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: 6 years ago

Seen: 897 times

Last updated: Jun 04 '18