Ask Your Question

polynomial with matrix coefficients

asked 2017-12-06 22:06:14 +0100

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-07 01:46:08 +0100

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 22:06:14 +0100

Seen: 394 times

Last updated: Dec 07 '17