Hi, Yep, there are definitely easy ways of doing this. Here's one way:
sage: var('a b c d') (a, b, c, d) sage: A = matrix(2,[2,1,1,1]) sage: B = matrix(2,[a,b,c,d]) sage: C = A*B - B*A sage: [ e == 0 for e in C.list() ] [c - b == 0, d + b - a == 0, -d - c + a == 0, b - c == 0] sage: solve([ e == 0 for e in C.list() ], N.list()) [[a == r2 + r1, b == r2, c == r2, d == r1]] -cc On Sat, Feb 7, 2009 at 9:45 AM, mb <bestv...@gmail.com> wrote: > > Hi, > > Say I want to compute the centralizer of a matrix. > > sage: P.<a,b,c,d>=PolynomialRing(QQ) > sage: A=matrix(P,2,2,[2,1,1,1]) > sage: B=matrix(P,2,2,[a,b,c,d]) > sage: C=A*B-B*A > sage: C > > [ -b + c -a + b + d] > [ a - c - d b - c] > sage: var('a b c d') > (a, b, c, d) > sage: solve([-b + c==0,-a + b + d==0,a - c - d==0,b - c==0],[a,b,c,d]) > [[a == r2 + r1, b == r2, c == r2, d == r1]] > > Here I had to manually copy the entries of C into solve, which is a > problem for larger matrices. Ideally, something like > > solve(C==0,[a,b,c,d]) > > should work, but of course it doesn't. Is there any way of doing this? > > Mladen > > > --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URLs: http://www.sagemath.org -~----------~----~----~----~------~----~------~--~---