Group Abstract Group Abstract

Message Boards Message Boards

0
|
3.8K Views
|
3 Replies
|
2 Total Likes
View groups...
Share
Share this post:

Commutation of several matrices using Do?

Posted 3 years ago

Hello Wolfram Community

I have a list of lists. That is a matrix (listSym) containing matrices (A[1], A[2], .... , A[6]).

A[1] = {{0, 0, 2, 0, 0, 0}, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}};
A[2] = {{0, 0, 0, 1, 0, 0}, {0, 0, 1, 0, 0, 0}, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}};
A[3] = {{0, 0, 2, 0, 0, 0}, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}};
A[4] = {{0, 0, 0 , 1, 0, 0}, {0, 0, 1, 0, 0, 0}, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}};
A[5] = {{0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 2, 0}, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}};
A[6] = {{0, 0, 0, 0, 0, 0}, {0, 0, 0, 1, 0, 0}, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}};
listSym = {A[1], A[2], A[3], A[4], A[5], A[6]};
dim = Length[listSym];

The matrix commutation of A[5] with listSym is:

AdjointMatrixCommutator [i_] :=  TableForm[ Dot[A[5], listSym[[i]]] - Dot[ listSym[[i]], A[5]], {i, 1, dim}, TableHeadings -> Automatic]

I want to do a commutation of A[1] with listSym, A[2] with listSym, A[3] with listSym, etc.

The matrix commutation of each A[i] with listSym (using a Do Loop) is:

Do[Print[TableForm[   Dot[A[i], listSym[[i]]] - Dot[listSym[[i]], A[i]], {i, 1, 
    dim}]], {i, 1, dim}]; 

I am getting matrices which are all zeros and that is incorrect. Can anyone show how to use a Do loop with lists (of matrix commutation).

Ps: I can provide more information for a better answer.

POSTED BY: Nomsa Ledwaba
3 Replies
Posted 3 years ago

Yes indeed it is sorted. Thank you.

POSTED BY: Nomsa Ledwaba
Posted 3 years ago

May I ask why listSym varies in this case, meaning why you used listSym[j], { j, 1, dim} instead of listSym only ?

POSTED BY: Nomsa Ledwaba
Posted 3 years ago

Dot is commutative so this will always be zero.

Dot[A[i], listSym[[i]]] - Dot[listSym[[i]], A[i]]

Perhaps you meant

Do[Print[
   Table[
    Dot[A[i], listSym[[j]]] - Dot[listSym[[j]], A[i]], {i, 1, dim}]], {j, 1, dim}];

Note that TableForm, as with most Form wrappers is not computable. The definition of AdjointMatrixCommutator should not use TableForm, use Table instead, and apply TableForm to the result if you want formatted output.

POSTED BY: Rohit Namjoshi
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard