Ask Your Question

polynomial with matrix coefficients

asked 2017-12-06 15:06:14 -0500

charleslebarron gravatar image

Is there a way in sage to work with polynomials or power series over a ring of matrices? For example, I can write something like:

z=var('z') A=matrix([[z^2+z+1,z],[0,z^2]])

But then lets say I do some transformations and want to recover from the result the matrix coefficient of a particular term. With the matrix above I can write something like




to try to get the individual entries. But what I want is a function that takes A.coefficient(z,2) and returns

[1 0] [0 1]

Is there a way to do this?

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2017-12-06 18:46:08 -0500

tmonteil gravatar image

You if you want the quadratic coefficient of a polynomial symbolic expression P, you can do P.coefficient(z^2), so what you can do is to apply that map to each entry of the matrix:

sage: A.apply_map(lambda e : e.coefficient(z^2))
[1 0]
[0 1]
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

1 follower


Asked: 2017-12-06 15:06:14 -0500

Seen: 30 times

Last updated: Dec 06 '17