# 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?

## closed as off-topic by Henrik Schumacher, MarcoB, Alex Trounev, eyorble, rhermansApr 11 at 9:11

This question appears to be off-topic. The users who voted to close gave these specific reasons:

• "This question cannot be answered without additional information. Questions on problems in code must describe the specific problem and include valid code to reproduce it. Any data used for programming examples should be embedded in the question or code to generate the (fake) data must be included." – MarcoB, rhermans
• "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – Henrik Schumacher, Alex Trounev, eyorble
If this question can be reworded to fit the rules in the help center, please edit the question.

• Tr, Dot, KroneckerProduct (or TensorProduct), Sum. – Henrik Schumacher Mar 29 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)$$