Carsten Knoll
unread,May 11, 2015, 4:22:01 PM5/11/15Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to sy...@googlegroups.com
Hello,
I wonder about the following behavior
In [1]: import sympy as sp
In [2]: x, y = sp.symbols('x, y', commutative = False)
In [3]: M1 = x*sp.eye(2)
In [4]: M2 = y*x*sp.eye(2)
In [5]: y*M1-M2
Out[5]:
Matrix([
[x*y - y*x, 0],
[ 0, x*y - y*x]])
I would have expected that the two matrices are equal.
However, multiplying y from the right to M1 results in products where y
is on the left side:
In [6]: y*M1
Out[6]:
Matrix([
[x*y, 0],
[ 0, x*y]])
For reference two other results:
In [7]: M2
Out[7]:
Matrix([
[y*x, 0],
[ 0, y*x]])
In [8]: M1*y
Out[8]:
Matrix([
[x*y, 0],
[ 0, x*y]])
Questions:
1. Is this behavior intended?
2. Is there any (easy) way to achieve my intended behavior, i.e.
respecting multiplication order when using matrix multiplication.
Thanks,
Carsten.