# How to implement a Square root of Swap gate that swaps 2n-qubits on the IBM Q (composer)?

I am looking for an implementation using the quantum gates provided by the IBM composer of the following quantum function:

• input $2n$ qubits
• output $2n$ qubits wherein $50\%$ of the cases the state of the $2$ sets of $n$ qubits are swapped and in the other $50\%$ of the cases the state of the $2n$ qubits remain unchanged. With swapped I mean that qubit $q[i]$ will get the state of qubit $q[n+i]$ and qubit $q[n+i]$ will get the state of $q[i]$. Note also that all the qubits must be swapped or not.

E.g. $n=3$: If input $|000111\rangle$ then output in 50% of the cases is $|000111\rangle$ and in the other 50% of the cases is $|111000\rangle$

We have already a solution when $n=1$ in the following StackOverflow question:

but how can we do that when $n>1$?

• I wonder if we can use a classical coin-flipper, and add an "if" statement in the QASM editor? – user1271772 Jun 8 '18 at 15:19