I think you are right this is a bug. 
>>> x, y = symbols('x y', commutative=False)
>>> M1 = x*eye(2)
>>> y * (x*M1)
Matrix( [ [x*y, 0], [x*y, 0] ] )

# i think the output should be Matrix( [ [y*x, 0], [0, y*x] ] )

On Tuesday, May 12, 2015 at 1:52:01 AM UTC+5:30, Carsten Knoll wrote:
>
> 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. 
>

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sympy+unsubscr...@googlegroups.com.
To post to this group, send email to sympy@googlegroups.com.
Visit this group at http://groups.google.com/group/sympy.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/e77187e2-18d1-4cf7-9e59-78ba88464ff7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to