# Performing a simple operation with operators [closed]

I have a map defined as

$$\qquad \Phi(X) = a^2\, Tr[X] |0\rangle \langle 0| + b^2\, Tr[X] |1\rangle \langle 1| + a\,b\, Tr[\sigma_z X] |0\rangle \langle 1| + a\,b\, Tr[\sigma_z X] |1\rangle \langle 0|$$

Here $$|0 \rangle = \begin{pmatrix} 1 \\0 \end{pmatrix}$$ and $$|1 \rangle = \begin{pmatrix} 0 \\1 \end{pmatrix}$$. I want to perform the following operation

$$\sum\limits_{j=0}^{1} \sum\limits_{k=0}^{1} \Psi(|j\rangle \langle k|) \otimes |j\rangle \langle k|.$$

How can this operation be done on Mathematica?

• Tr, Dot, KroneckerProduct (or TensorProduct), Sum. – Henrik Schumacher Mar 29 '19 at 7:27

I am assuming $$\Psi = \Phi$$ in your question. This is a program that would do that, with self-explanatory names.

ket[0] = {1, 0};
ket[1] = {0, 1};

ketbra[i_, j_] := KroneckerProduct[ket[i], ket[j]]

σz = PauliMatrix[3];

Phi[X_]:= a^2 Tr[X] ketbra[0,0] + b^2 Tr[X] ketbra[1,1] + a b Tr[σz.X] (ketbra[1,0] + ketbra[0,1])


And then compute

In[1]:= Sum[KroneckerProduct[Phi[ketbra[j, k]], ketbra[j, k]], {j, 0, 1}, {k, 0, 1}];
%//MatrixForm


Out[1]//MatrixForm= $$\left( \begin{array}{cccc} a^2 & 0 & a b & 0 \\ 0 & a^2 & 0 & -a b \\ a b & 0 & b^2 & 0 \\ 0 & -a b & 0 & b^2 \\ \end{array} \right)$$