Matrix works for many different Species. Let us consider
Qubits
.
In[1]:=
Let[Qubit,S]
This is another expression in terms of the implicit Pauli operators.
In[2]:=
expr=S[1,1]**S[2,2]-S[1,2]**S[2,1]+S[1,1]**S[2,3]
Out[2]=
X
S
1
Y
S
2
+
X
S
1
Z
S
2
-
Y
S
1
X
S
2
In[3]:=
mat=Matrix[expr];mat//MatrixForm
Out[3]//MatrixForm=
0
0
1
0
0
0
2
-1
1
-2
0
0
0
-1
0
0
Note that giving an explicit list of systems (qubits in the present case), the order of the specified systems changes the explicit form of the matrix. This is because matrix representation depends on the choice of basis.
The above expression acts non-trivially only on qubits S[1,$] and S[2,$], but trivially on other qubits, say, S[3,$]. Therefore, any implicit Pauli operators S[3,μ] does not appear in the expression. If you want to include the qubit S[3,$] in the matrix expression as well, then just include it in the specification of the qubits.