Craig Citro wrote: > 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]]
Just to point out for those that need a guide through the above, Craig is basically creating a list of equations from each entry in the matrix. He doesn't show it, but I suppose that N is a matrix of the variables. You could also do: solve([ e == 0 for e in C.list() ], C.variables()) That said, I think it would be a great thing if solve could recognize matrices and that two matrices are equal if each entry is equal. I believe MMA does this (but it's easier there; matrices are nothing more than nested lists). It'd certainly make certain things I do more natural if I could do: solve(matrixA==matrixB) and that was equivalent to: solve([i==j for i,j in zip(matrixA.list(), matrixB.list())]) if the matrices were of the same dimensions. Okay, so now that I've written my piece, I suppose the next step is to open a trac ticket, write a patch to implement it, and post it for review :). The ticket is http://trac.sagemath.org/sage_trac/ticket/5201 I won't cry if someone submits a patch before I get to it :). Jason --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---