This is one of the classic mistakes in Mathematica.
The MatrixForm display MatrixForm takes precedence over the Set ( = ) statement.
Assuming (based on your tag selection) that you wanted to use Dot ( . ) Matrix multiplication 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 enter
c = I a1.a2 // MatrixForm
Then a quick look at FullForm c will show you what the problem is:
In[6]:= FullForm[c] Out[6]
You can see that it has Head[c] == MatrixForm , and therefore it will not play well with other matrices.
source share