Ask Your Question
5

Eigenvalues of matrix with entries in polynomial ring

asked 2012-03-16 20:05:50 +0200

Anne Schilling gravatar image

updated 2018-04-27 19:18:46 +0200

slelievre gravatar image

Hi!

I just wrote some code on the sage-combinat queue which computes a matrix with entries in a polynomial ring R = PolynomialRing(QQ, 'x', n)

sage: P = Poset(([1,2,3,4], [[1,3],[1,4],[2,3]]), linear_extension = True)
sage: L = P.linear_extensions()
sage: M = L.markov_chain_transition_matrix(labeling = 'source')
sage: M
[-x0 - x1 - x2            x3       x0 + x3             0             0]
[      x1 + x2 -x0 - x1 - x3             0            x1             0]
[            0            x1      -x0 - x3             0            x1]
[            0            x0             0 -x0 - x1 - x2       x0 + x3]
[           x0             0             0       x0 + x2 -x0 - x1 - x3]
sage: M.eigenvalues()
---------------------------------------------------------------------------
NotImplementedError                       Traceback (most recent call last)

/Applications/sage-5.0.beta7/devel/sage-combinat/sage/combinat/posets/<ipython console> in <module>()

/Applications/sage-5.0.beta7/local/lib/python2.7/site-packages/sage/matrix/matrix2.so in sage.matrix.matrix2.Matrix.eigenvalues (sage/matrix/matrix2.c:26415)()

/Applications/sage-5.0.beta7/local/lib/python2.7/site-packages/sage/matrix/matrix2.so in sage.matrix.matrix2.Matrix.fcp (sage/matrix/matrix2.c:11089)()

/Applications/sage-5.0.beta7/local/lib/python2.7/site-packages/sage/rings/polynomial/polynomial_element.so in sage.rings.polynomial.polynomial_element.Polynomial.factor (sage/rings/polynomial/polynomial_element.c:22655)()

NotImplementedError:

Is it possible to compute this some other way or is this just not yet implemented (which would surprise me!).

Thanks,

Anne


Edit (originally posted as an answer by the original poster of the question)

Here is an easier example with the question:

sage: R = PolynomialRing(QQ, 'x', 2)
sage: x = R.gens()
sage: M = matrix([[x[0],x[1]],[x[1],x[0]]])
sage: M.eigenvalues()
---------------------------------------------------------------------------
NotImplementedError                       Traceback (most recent call last)

/Applications/sage-5.0.beta7/devel/sage-combinat/sage/combinat/posets/<ipython console> in <module>()

/Applications/sage-5.0.beta7/local/lib/python2.7/site-packages/sage/matrix   /matrix2.so in sage.matrix.matrix2.Matrix.eigenvalues (sage/matrix/matrix2.c:26415)()

/Applications/sage-5.0.beta7/local/lib/python2.7/site-packages/sage/matrix/matrix2.so in sage.matrix.matrix2.Matrix.fcp (sage/matrix/matrix2.c:11089)()

/Applications/sage-5.0.beta7/local/lib/python2.7/site-packages/sage/rings/polynomial/polynomial_element.so in      sage.rings.polynomial.polynomial_element.Polynomial.factor (sage/rings/polynomial/polynomial_element.c:22655)()

NotImplementedError:
edit retag flag offensive close merge delete

Comments

Just for future reference, this site uses markdown for markup, so indenting everything four spaces makes it look like code (or highlighting and using the "code" button).

kcrisman gravatar imagekcrisman ( 2012-03-16 21:37:55 +0200 )edit

2 Answers

Sort by ยป oldest newest most voted
3

answered 2012-03-17 00:34:02 +0200

DSM gravatar image

updated 2018-04-25 20:46:15 +0200

nbruin gravatar image

Could you change the ring to SR as a workaround?

sage: R = PolynomialRing(QQ, 'x', 2)
sage: x = R.gens()
sage: M = matrix([[x[0],x[1]],[x[1],x[0]]])
sage: M.eigenvalues()
---------------------------------------------------------------------------
NotImplementedError                       Traceback (most recent call last)
[...]
sage: M.change_ring(SR)
[x0 x1]
[x1 x0]
sage: M.change_ring(SR).eigenvalues()
[x0 - x1, x0 + x1]

EDIT: You might want to use K=R.fraction_field() and then do something like M.characteristic_polynomial().change_ring(K).roots(). It doesn't get you the eigenvalues that aren't rational over R, but the answer you get back in SR will not be very useful either.

edit flag offensive delete link more

Comments

Thank you! That works! Am I allowed to use this in sage source code?

Anne Schilling gravatar imageAnne Schilling ( 2012-03-18 13:25:35 +0200 )edit

If by that you mean for stuff getting committed to mainline, I'm not sure. Seems a little hacky, and it feels like there should be a way to do it while staying purely in some polynomial ring.

DSM gravatar imageDSM ( 2012-03-18 18:42:31 +0200 )edit
2

answered 2018-04-25 20:42:46 +0200

nbruin gravatar image

Root finding of polynomials over function fields seems to be implemented, so this should work:

sage: M.change_ring(R.fraction_field()).characteristic_polynomial().roots()
[(x0 + x1, 1), (x0 - x1, 1)]

It has the advantage that it should also work in positive characteristic (where SR would not), and hopefully good use is made of specifics of the coefficient domain to provide efficient arithmetic.

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: 2012-03-16 20:05:50 +0200

Seen: 882 times

Last updated: Apr 27 '18