6

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$?

Sanchayan Dutta
  • 18,015
  • 8
  • 50
  • 112
JanVdA
  • 1,158
  • 1
  • 8
  • 17

1 Answers1

3

A general trick for smoothing a big discrete operation into a continuous operation is to apply the phase estimation algorithm, then apply a phase gradient to the phase register, then uncompute the phase estimation. For example, see this blog post on computing the fractional fourier transform.

Because the swap operation has exactly two eigenvalues (+1 and -1), the phase estimation is extremely simple. It only requires a single phase estimation qubit. The resulting circuit looks like this:

Big sqrt swap

Note that the top qubit should start and end in the 0 state. You can continuously vary how much swappery there is by varying the angle of the Z rotation in the middle.

Craig Gidney
  • 47,099
  • 1
  • 44
  • 119