9
$\begingroup$

I would like to simulate a quantum algorithm where one of the steps is "Square root of Swap gate" between 2 qubits.

How can I implement this step using the IBM composer?

$\endgroup$
  • $\begingroup$ Maybe it can be useful to use simple swap gate as a "brick" to construct square root of swap gate. You can simulate on IBM Q in this way: cx q[1],q[0]; h q[0]; h q[1]; cx q[1],q[0]; h q[0]; h q[1]; cx q[1],q[0]; $\endgroup$ – Lying Dancer Jun 4 '18 at 14:36
  • 1
    $\begingroup$ @JanVdA The square root is not unique. In fact, there should be 2^4=16 possible roots. Which one do you mean? $\endgroup$ – Norbert Schuch Jun 4 '18 at 22:59
  • $\begingroup$ Anyone would do for me. No preference for a particular one. $\endgroup$ – JanVdA Jun 5 '18 at 6:18
9
$\begingroup$

Here is a SQRT(SWAP) construction which only requires CNOTs in one direction, Hadamards, S gates ($Z^{\frac{1}{2}}$), inverse S gates ($Z^{-\frac{1}{2}}$), T gates ($Z^{\frac{1}{4}}$) and inverse T gates ($Z^{-\frac{1}{4}}$):

enter image description here

You should be able to encode it directly into the composer.

$\endgroup$
  • $\begingroup$ How does one obtain this from first principles? $\endgroup$ – user1271772 Jun 5 '18 at 2:04
  • $\begingroup$ @user1271772 Which are the "first principles"? $\endgroup$ – Norbert Schuch Jun 5 '18 at 3:17
  • $\begingroup$ I don't know how to implement $Z^{1/2}$ and $Z^{-1/2}$ using the IBM composer. $\endgroup$ – JanVdA Jun 5 '18 at 7:31
  • $\begingroup$ @user1271772 I started with the CNOT-NOTC-CNOT SWAP circuit, replaced the middle CNOT with a C-sqrt(not) to make the whole thing a sqrt(SWAP), decomposed the C-srt(not) into S+CNOT gates, moved some gates around until I managed to cancel one of the CNOTs, then used Hadamards to flip the direction of any CNOT pointing the wrong way. $\endgroup$ – Craig Gidney Jun 5 '18 at 11:39
  • $\begingroup$ @JanVdA $Z^{1/2}$ is $S$, and $Z^{-1/2}$ is $S^\dagger$ (look at the blue gates in the composer). $\endgroup$ – Craig Gidney Jun 5 '18 at 11:40
2
$\begingroup$

What you want to do is a rotation on the subspace spanned by $|01\rangle$ and $|10\rangle$ which rotates it by $\sqrt{X}$. To this end, you can first do a CNOT, which maps this subspace to $\{|01\rangle,|11\rangle\}$. Now you need to do the $\sqrt{X}$ rotation on the first qubit, conditioned on the second qubit being one. Implementing controlled-$U$ gates using CNOTs is a standard construction, which can be found in a range of places, see e.g. https://arxiv.org/abs/quant-ph/9503016. Depending how you do this step, you might have to fix the "global" phase of the 1st qubit (given the 2nd is $|1\rangle$). Finally, you need to undo the CNOT.

$\endgroup$
  • $\begingroup$ It is not clear to me 1) how you do a $\sqrt{X}$ in composer. 2) how to undo a CNOT in composer 3) you mention controlled-U gates but it is not clear where they should be used in the algorithm. I think that a step wise description of the algorithm would be helpful for implementing this on the IBM composer. $\endgroup$ – JanVdA Jun 6 '18 at 6:38
  • $\begingroup$ @JanVdA I'm afraid you'll have to do some work yourself to familiarize yourself with quantum circuits and their manipulations. Otherwise, what are you going to do once you know the circuit for the sqrt-SWAP? $\endgroup$ – Norbert Schuch Jun 6 '18 at 14:54
  • $\begingroup$ FYI: I have used the above sqrt-SWAP description to test the solution suggested for quantumcomputing.stackexchange.com/questions/2209/… on the IBM composer. $\endgroup$ – JanVdA Jun 6 '18 at 15:14
  • $\begingroup$ @JanVdA Which one? The accepted one? That one only talks about a controlled-SWAP. (For that: journals.aps.org/pra/abstract/10.1103/PhysRevA.53.2855) $\endgroup$ – Norbert Schuch Jun 6 '18 at 15:25
  • $\begingroup$ Sorry I am referring to the accepted solution for question: mathoverflow.net/questions/301733/… $\endgroup$ – JanVdA Jun 6 '18 at 15:29
-1
$\begingroup$

Every 2-qubit gate has a "Paulinomial decomposition" which means it can be written as a polynomial of Pauli matrices.

For the gate you want:

$ \sqrt{ \mbox{SWAP} } = \begin{bmatrix} 1 & 0 & 0 & 0 \\ 0 & \frac{1}{{2}} (1+i) & \frac{1}{{2}} (1-i) & 0 \\ 0 & \frac{1}{{2}} (1-i) & \frac{1}{{2}} (1+i) & 0 \\ 0 & 0 & 0 & 1 \\ \end{bmatrix} = \frac{1-i}{4}\left(X_1X_2+Y_1Y_2+Z_1Z_2\right) +\frac{3+i}{2}I, $

where $X_i$ is an $X$ gate applied to the $i^\textrm{th}$ qubit.

$\endgroup$
  • $\begingroup$ OK, thanks for the answer - I need to study a bit to figure out how I can translate this to the IBM Composer. $\endgroup$ – JanVdA Jun 4 '18 at 17:28
  • $\begingroup$ @JanVdA What's wrong? Can't you drag and drop the X,Y, and Z gates into the circuit? You may wish to ask a separate question about how to multiply a gate by a constant. $\endgroup$ – user1271772 Jun 4 '18 at 17:44
  • $\begingroup$ I can drag and drop X, Y, Z gates but I don't know how to do the multiplications (e.g. $X_1X_2$), the additions (e.g. $X_1X_2+Y_1Y_2$), the multiplication by a constant, I even don't know what you mean by $I$. I guess I must sound like a complete idiot. $\endgroup$ – JanVdA Jun 4 '18 at 18:55
  • $\begingroup$ $X_1X_2$ means you're applying $X$ to qubit 1 and $X$ to qubit 2. However, as I mention in the previous comment, I think you should ask a separate question about how to multiply by a constant. $\endgroup$ – user1271772 Jun 4 '18 at 19:04
  • $\begingroup$ See also Eq. 8 of this paper: arxiv.org/pdf/1805.10478.pdf, and the circuit diagrams in the supplementary material. Eq. 8 of the paper is exactly like what I gave you, except with only $Z$ gates. It's still a "Paulinomial" but with only $Z$ gates, and it is implemented in the IBM composer in that paper. $\endgroup$ – user1271772 Jun 4 '18 at 19:07

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.