# There exists an efficient gate that swaps values of different superposition kets?

Is there an efficient gate that swaps values of different superposition kets?

Let $$\alpha_i, \beta_i$$ be string in $$\{0,1\}^n$$, I'm wondering if there are a known results about the existence of gate which for given super position, swap only specific segment of it. Namely the following mapping: $$\frac{1}{\sqrt{2}} (\vert{0,\alpha_1, \alpha_2}\rangle +\vert{1,\beta_1, \beta_2}\rangle) \mapsto \frac{1}{\sqrt{2}} (\vert{0,\beta_1, \alpha_2}\rangle +\vert{1,\alpha_1, \beta_2}\rangle )$$

At first glance, it seems that such map would be unitary, but I couldn't figure out how to implement such a gate. So, does this gate exist? Thanks!

• Your mapping is not well defined as a linear map, is it? like, how does it act on just $|0,\alpha_1,\alpha_2\rangle$ state? Apr 20 at 20:43
• Thanks, @Seyed , for your comment. Maybe I'm missing something at the fundamental level, but it seems to me that the above vector set $\{ \vert{0,\alpha_1,\alpha_2}\rangle + \vert{0,\beta_1,\beta_2}\rangle : \alpha_1,\alpha_2,\beta_1,\beta_2 \}$ is indeed a base (although not an orthonormal base) and therefore the operation should be linear. However, I feel that you are right, and there is a problem with the definition; I just can't point out where exactly it fails. Apr 24 at 7:04
• No that set is not a basis because it is not complete; e.g. you can not write |0,𝛼1,𝛼2⟩ as a linear combination of the vectors in that set. But you could extend that set to become a basis (e.g. by adding $|\alpha_1,\alpha_2\rangle-|\beta_1,\beta_2\rangle$ to the set) and define your map on that set. But that map would look like swap only on those specific vectors, not for an arbitrary vector. For example the image of $|\alpha_1,\alpha_2\rangle+2 |\beta_1,\beta_2\rangle$ under that mapping will not be what you expect from a swap of values . Apr 24 at 9:16

If you know $$\alpha_1$$ and $$\beta_1$$, this is easy. Let $$x=\alpha_1\oplus\beta_1$$ (bit-wise addition modulo 2). Let $$X_x$$ apply bit flips on the sites where the bits of $$x$$ are 1, and identity on the other sites. This means that $$X_x|\alpha_1\rangle=|\beta_1\rangle,\qquad X_x|\beta_1\rangle=|\alpha_1\rangle.$$ In this case, the operation $$I\otimes X_x\otimes I$$ does what you need.