How could a $\sqrt{SWAP}$ circuit be expressed in terms of CNOT gates & single qubit rotations?


  • CNOT & $\sqrt{SWAP}$ Gates

Any quantum circuit can be simulated to an arbitrary degree of accuracy using a combination of CNOT gates and single qubit rotations.

Both CNOT and $\sqrt{SWAP}$ are universal two-qubit gates and can be transformed into each other.


The questions are not identical, and are likely to attract different audiences. -DaftWullie

Can the difference be regarded as applied vs theoretic?

  • 2
    $\begingroup$ quantumcomputing.stackexchange.com/questions/2228/… $\endgroup$ – Nelimee Jun 26 '18 at 5:53
  • $\begingroup$ Possible duplicate of How to implement the "Square root of Swap gate" on the IBM Q (composer)? $\endgroup$ – Sanchayan Dutta Jun 26 '18 at 6:55
  • $\begingroup$ @Blue I think that while the answers are essentially the same, the questions are not identical, and are likely to attract different audiences. $\endgroup$ – DaftWullie Jun 26 '18 at 7:01
  • $\begingroup$ May have been better to post edit as comment? Also, to be clear, the circuit that @DaftWullie posted at the end is what I was after (which I did not see in the other post). $\endgroup$ – meowzz Jun 26 '18 at 7:55
  • $\begingroup$ @Blue It is indeed a candidate for closure. But given there are slight differences and willing answerers, I'll let it live. $\endgroup$ – James Wootton Jun 26 '18 at 8:42

As pointed out by @Nelimee, this question is essentially answered in this question, even if that question seems more specific. However, for the sake of completeness... (Note that I make no claims about minimality of construction with respect to, for example, number of controlled-not gates.)

Let's start with a unitary matrix for the square root of SWAP: $$ \left( \begin{array}{cccc} 1 & 0 & 0 & 0 \\ 0 & \frac{1}{2}+\frac{i}{2} & \frac{1}{2}-\frac{i}{2} & 0 \\ 0 & \frac{1}{2}-\frac{i}{2} & \frac{1}{2}+\frac{i}{2} & 0 \\ 0 & 0 & 0 & 1 \\ \end{array} \right) $$ Note that if we pre- and post-multiply by a controlled NOT, controlled off qubit 2, this transforms into the form of a controlled-$U$ gate: $$ \left( \begin{array}{cccc} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & \frac{1}{2}+\frac{i}{2} & \frac{1}{2}-\frac{i}{2} \\ 0 & 0 & \frac{1}{2}-\frac{i}{2} & \frac{1}{2}+\frac{i}{2} \\ \end{array} \right) $$ There are standard constructions for this controlled-$U$ gate. So, overall, we have a circuit that looks like enter image description here where $ABC=\mathbb{I}$ and $AXBXC=e^{i\pi/4}\sqrt{X}$. Again, there are standard routes towards finding $A$, $B$ and $C$. For instance, we can define $R_Y(\theta)$ to be a rotation about the $Y$ axis by an angle $\theta$, i.e. $R_Y(\theta)=e^{i\theta Y}$ (there may be a factor of $\frac12$ here compared to some definitions). Then, if $$ A=R_Y(\theta)R_Z(\phi)\qquad B=R_Z(-2\phi)\qquad C=R_Z(\phi)R_Y(-\theta), $$ then it's easy to verify that $ABC=\mathbb{I}$. Furthermore, $AXBXC=R_Y(\theta)R_Z(4\phi)R_Y(-\theta)$ since $XR_Z(\phi)X=R_Z(-\phi)$. You can think of this as $R_Z(4\phi)$ specifying the eigenvalues that we want, and the $R_Y(\theta)$ is changing the basis from the computational basis into something else. In the present case, we have $\theta=\pi/2$ and $4\phi=\pi/4$.

The one little thing that we haven't got right yet is a phase factor. Our $AXBXC$ is creating the correct rotation up to an overall phase of $e^{i\pi/4}$: $$ \left( \begin{array}{cccc} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & \frac{1}{\sqrt{2}} & -\frac{i}{\sqrt{2}} \\ 0 & 0 & -\frac{i}{\sqrt{2}} & \frac{1}{\sqrt{2}} \\ \end{array} \right) $$ The trick to get this right is to apply an $R_Z(\pi/8)$ on the first qubit and remove a global phase of $e^{i\pi/8}$. Thus, we have enter image description here


I think that you want answers to explicitly use full cnots, rather than partial versions. But since you already have an answer for that, I'll contribute a different perspective.

A $\mathrm{SWAP}$ can be thought of as a cnot that has been conjugated by oppositely oriented cnots.

$$\mathrm{SWAP} = {\rm cx}(k,j) \,\, {\rm cx}(j,k) \,\, {\rm cx}(k,j) $$

To make a $\sqrt{\mathrm{SWAP}}$, we can instead use a square root of cnot conjugated by oppositely oriented cnots.

$$ \sqrt{\mathrm{SWAP}} = {\rm cx}(k,j) \,\, \sqrt{{\rm cx}(j,k)} \,\, {\rm cx}(k,j) $$

To verify that this is indeed a $\sqrt{\mathrm{SWAP}}$, you can simply square it and verify that it ends up in the way we expect (using the fact that cnots square to identity).

  • $\begingroup$ Awesome! Your $\mathrm{SWAP}$ approach makes me think of an unanswered question.. $\endgroup$ – meowzz Jun 26 '18 at 9:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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