I am using sympy for the first time, and attempting to do matrix 
multiplication like the following

sum_{l,m} U[i,l] G[l,m] D[j,m]

I want to do regular matrix multiplication, but only on one of the two 
indices for the objects U and D, in my case for a known G (I want to put 
numerical entries for the matrix G).  I was hoping to have this print out a 
symbolic expression.  I found sympy.MatrixSymbol to create a symbolic 
representation for U and D, but it seems I need some functionality from 
sympy.tensor class to handle this type of multiplication.

Does anyone have, or could anyone write down a simple example doing such a 
multiplication?  Let me make a simple specific example.

G = sympy.Matrix([[0,1], [-1,0]]) #
# [ 0  1 ]
# [ -1 0 ]

So, in the above example, leaving i,j arbitrary, this would result in

U[i,0] D[j,1] - U[i,1] D[j,0]

I also want to multiply this by a G[i,j], but knowing how to do the above I 
think will be sufficient for the complete multiplication.


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 post to this group, send email to
Visit this group at
To view this discussion on the web visit
For more options, visit

Reply via email to