2
$\begingroup$

I need to write the tensorial representation of the Controlled Swap Gate, what I have written is $\operatorname{CSWAP}=|0\rangle\langle0|\otimes I\otimes I+|1\rangle\langle1|\otimes U$, where U is the matrix of $\operatorname{CSWAP}$ gate transformation, i.ethat is $$|00\rangle\to |00\rangle=1|00\rangle+0|01\rangle+0|10\rangle +0|11\rangle $$ $$ |01\rangle=0|00\rangle+0|01\rangle+1|10\rangle +0|11\rangle $$ $$|10\rangle=0|00\rangle+1|01\rangle+0|10\rangle +0|11\rangle $$ $$|11\rangle=0|00\rangle+0|01\rangle+0|10\rangle +1|11\rangle,$$ so the matrix becomes $$U=\begin{bmatrix} 1 &0&0&0\\ 0&0&1&0\\ 0&1&0&0\\ 0&0&0&1 \end{bmatrix},$$ Is this the correct implementation? Just to add a bit, how do I make this $2$-qubit gate as a tensor product of $1$-qubit gate so that there is uniformity in the equation above?

$\endgroup$

2 Answers 2

3
$\begingroup$

SWAP is a two-qubit gate and needs to be written as $$ \text{SWAP}=|00\rangle\langle 00|+|11\rangle\langle 11|+|01\rangle\langle 10|+|10\rangle\langle 01|. $$ If you want to write this in terms of Pauli-operators, for example, you might write $$ \text{SWAP}=\frac12\left(\mathbb{I}\otimes\mathbb{I}+Z\otimes Z+X\otimes X+Y\otimes Y\right). $$

$\endgroup$
1
$\begingroup$

Yes, that is the correct matrix representation of the CSWAP (also often referred to as Fredkin gate).

Regarding writing it as a "tensor product of $1$-qubit gates", the only missing step is writing the swap in braket notation, which you can do as follows: $$\operatorname{SWAP}=\lvert00\rangle\!\langle00\rvert+\lvert11\rangle\!\langle11\rvert+\lvert01\rangle\!\langle10\rvert+\lvert10\rangle\!\langle01\rvert,$$ so that the overall gate reads \begin{align} \operatorname{CSWAP}&=|0\rangle\!\langle0|\otimes I\otimes I+|1\rangle\!\langle1|\otimes \operatorname{SWAP}\\ &=|0\rangle\!\langle0|\otimes I\otimes I+|1\rangle\!\langle1|\otimes(\lvert00\rangle\!\langle00\rvert+\lvert11\rangle\!\langle11\rvert+\lvert01\rangle\!\langle10\rvert+\lvert10\rangle\!\langle01\rvert). \end{align}

$\endgroup$
3
  • $\begingroup$ okay, that is what i was missing. $\endgroup$
    – Upstart
    Apr 24, 2019 at 8:56
  • $\begingroup$ I think your "tensor product of $1$-qubit gates" representation is incorrect. As this representation will give a simple $X$-gate, not a $\text{SWAP}$-gate $\endgroup$
    – nippon
    Apr 24, 2019 at 9:37
  • $\begingroup$ @nippon it most definitely is, yes. I probably wasn't quite awake yet. Thanks $\endgroup$
    – glS
    Apr 24, 2019 at 9:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.