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.