Group Abstract Group Abstract

Message Boards Message Boards

0
|
5.6K Views
|
2 Replies
|
1 Total Like
View groups...
Share
Share this post:

How to obtain 3x3 matrices as output from the computation of 2x2 matrices

Posted 4 years ago
Attachments:
POSTED BY: Nomsa Ledwaba
2 Replies
Posted 4 years ago

Thank you for responding.
The reason of doing duplication for each computation was to show that the outputs were correct, however, the outputs must be in a 3 x 3 matrix. So that means for , the output ad[A3] should be

ad [A3] = {{0, 0, 0}, {0, 2, 0}, {0, 0, - 2}}

ad [A2] = {{0, 0, 0}, { 0, 2, 0}, {0, 0, 0}} 
ad [A1] = {{0, 0, 0}, {0, 0, 0}, {0, 0, 0}}

See updated attachment. For the rest of the code in terms of using functions you are very correct and I appreciate your helpful input. If I used a similar definition of function array

adjointMatrixCommutator[x_, newlistSym _] := 
 Module[{vars, f}, vars = Array[f, Length[newlistSym ]]

in the earlier part of the code wouldn't that confuse the rest of the code or is it a subsequent computation?

POSTED BY: Nomsa Ledwaba

From reading your code, I suggest that you implement ${\tt adjointMatrixCommutator}$ as a function to avoid code duplication.

adjointMatrixCommutator[x_, basis_] := Module[{vars, f},
    vars = Array[f, Length[basis]];
    Flatten[  vars /. Solve[ Flatten[Plus @@ (vars*basis)] == Flatten[Dot[x, #] - Dot[#, x]], vars]]] &;

In the definition, I have used the built-in functions ${\tt Flatten}$, ${\tt Solve}$ and ${\tt Dot}$. Please use the help menu to learn how these functions work. Next, I will define a function ${\tt adjoint}$ that will generate the matrices that you want.

 adjoint[basis_][x_] := Transpose[Map[adjointMatrixCommutator[x, basis], basis]//MatrixForm;

In the above code, I have used three build-in functions: ${\tt Transpose}$, ${\tt Map}$ and ${\tt MatrixForm}$. As before, use the help menu do see what these functions do. If you wish to use the result of the function ${\tt adjoint}$ in subsequent calculations, remove ${\tt // MatrixForm}$ at the end of the definition.

Finally, let's test the function ${\tt adjoint}$ by using the example that you commented in your file.

a1 = {{1, 0}, {0, -1}}; a2 = {{0, 1}, {0, 0}}; a3 = {{0, 0}, {1, 0}};
basis = {a1, a2, a3};  ad = adjoint[basis];
ad[a1]
ad[a2]
ad[a3]

I hope that, my suggestions address your problem.

POSTED BY: Ta'a Nwa Dombou
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard