In the following bit of mathematica code
a1 = {{0, -I}, {I, 0}}
a2 = {{0, 1}, {1, 0}}
a3 = {{1, 0}, {0, -1}}
c = I*a1*a2 // MatrixForm
d = c*a3 // MatrixForm
The display of d shows up as a two by two matrix, where the 1,1 and 2,2 elements are themselves 2x2 matrixes, whereas I expect it to be a plain old 2x2 matrix of scalars?
use () to protect expression from MatrixFrom which is a wrapper.
use '.' for matrix multiplication. Not '*'
a1 = {{0, -I}, {I, 0}}
a2 = {{0, 1}, {1, 0}}
a3 = {{1, 0}, {0, -1}}
(c = I a1.a2) // MatrixForm
(d = c.a3) // MatrixForm
This is the output I get for d:
(1 0
0 1)
This is one of the classic gotchas in Mathematica.
The MatrixForm
display wrapper has a higher precedence than the Set
operator (=
).
Assuming (based on your tag selection) that you meant to use matrix multiplication Dot
(.
) instead of Times (*
), I would write
a1 = {{0, -I}, {I, 0}}
a2 = {{0, 1}, {1, 0}}
a3 = {{1, 0}, {0, -1}}
(c = I a1.a2) // MatrixForm
(d = c.a3) // MatrixForm
which returns for c
and d
respectively:
(1 0
0 -1)
(1 0
0 1)
Edit:
I forgot to mention if you do enter
c = I a1.a2 // MatrixForm
Then a quick look at the FullForm
of c
will show you what the problem is:
In[6]:= FullForm[c]
Out[6]//FullForm= MatrixForm[List[List[1,0],List[0,-1]]]
You can see that it has the Head[c] == MatrixForm
and so it won't play nice with the other matrices.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With