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$
3
  • $\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$ Commented Jun 4, 2018 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$ Commented Jun 4, 2018 at 22:59
  • $\begingroup$ Anyone would do for me. No preference for a particular one. $\endgroup$
    – JanVdA
    Commented Jun 5, 2018 at 6:18

3 Answers 3

12
$\begingroup$

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

enter image description here

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

$\endgroup$
16
  • $\begingroup$ How does one obtain this from first principles? $\endgroup$ Commented Jun 5, 2018 at 2:04
  • $\begingroup$ @user1271772 Which are the "first principles"? $\endgroup$ Commented Jun 5, 2018 at 3:17
  • $\begingroup$ I don't know how to implement $Z^{1/2}$ and $Z^{-1/2}$ using the IBM composer. $\endgroup$
    – JanVdA
    Commented Jun 5, 2018 at 7:31
  • 1
    $\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$ Commented Jun 5, 2018 at 11:39
  • 1
    $\begingroup$ Multiplying matrices is obviously a good skill to have, but I think it is valid to want to get some experience in first. I'd suggest to @JanVdA that you prepare Bell states and test your sqrt(swap) gates on them. If they work, they should have no effect (though this is again not a full proof). $\endgroup$ Commented Jun 6, 2018 at 20:27
5
$\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$
5
  • $\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
    Commented Jun 6, 2018 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$ Commented Jun 6, 2018 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
    Commented Jun 6, 2018 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$ Commented Jun 6, 2018 at 15:25
  • $\begingroup$ Sorry I am referring to the accepted solution for question: mathoverflow.net/questions/301733/… $\endgroup$
    – JanVdA
    Commented Jun 6, 2018 at 15:29
0
$\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$
10
  • $\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
    Commented Jun 4, 2018 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$ Commented Jun 4, 2018 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
    Commented Jun 4, 2018 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$ Commented Jun 4, 2018 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$ Commented Jun 4, 2018 at 19:07

Your Answer

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

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