# How to switch bit in the quantum state?

I want to transform binary representation from one to other. Here, I have 2 registers one act as control register and another is target register with the same number of qubits $$n$$. Consider $$n = 3$$ qubits state and $$N = 2^{n}$$,

$$\begin{eqnarray} |\psi_{0}\rangle &=& |i\rangle \otimes \sum_{i = 0}^{N} a_{i}|i\rangle \\ |\psi_{0}\rangle &=& |i\rangle \otimes (a_{0}|000\rangle + a_{1}|001\rangle + a_{2}|010\rangle + a_{3}|011\rangle + a_{4}|100\rangle + a_{5}|101\rangle + a_{6}|110\rangle + a_{7}|111\rangle) \end{eqnarray}$$

I want a quantum circuit or algorithm ($$T_{i}|\psi_{0}\rangle = |\psi_{1}\rangle$$) to transform, for example, the target state, $$$$|\psi_{1}\rangle = |101\rangle \otimes (a_{0}|000\rangle + a_{3}|001\rangle + a_{2}|010\rangle + a_{1}|011\rangle + a_{5}|100\rangle + a_{4}|101\rangle + a_{7}|110\rangle + a_{}|111\rangle).$$$$ Please note that the amplitude $$a_{i}$$ still the same as before the operation. How to realize a quantum circuit like that, I know some special case where the operator will shift a bit to the right or left. However, I want a general form of operator $$T$$.

What you seem to be asking for is the general construction of an arbitrary permutation. There’s nothing quantum about this; the equivalent question in classical is how to construct an arbitrary reversible circuit of n bits. There are $$2^n!$$ such circuits, from which it is hopefully obvious that there is not a compact description for the vast majority.

I should also point out that you have a slight notational issue. For each of the states that you write, you’ve put a projector on the first term in the tensor product. This does not correspond to a state. You probably just meant the ket.

• I edited the notation as you point out, thank you very much. What I want is to permute bit in the quantum state, so I wonder if classical mean also works on my case. Since the state is in a superposition of every possible bit too, bit flip on one qubit will affect every bit in the state. – Poramet Pathumsoot Apr 3 at 7:03
• The circuit construction is the same in classical as quantum. You just have to replace the classical circuit elements with the same thing but one that is capable of operating on super positions. The bit flip exam0le that you give, for instance, is both a classical and a quantum operation. But the theory of the circuit construction is easier to understand from the classical perspective. – DaftWullie Apr 3 at 7:10
• By the way, are you assuming that you know the coefficients a or not? (I assumed not. I guess the other answer assumes that you do) – DaftWullie Apr 3 at 7:12
• I know the coefficient a, but instead of modified wave amplitude itself which may involve many controlled rotation gates, I prefer a bit modification approach. – Poramet Pathumsoot Apr 3 at 7:30

You can use a method described in Transformation of quantum states using uniformly controlled rotations.

Authors of the article introduced method how to change an arbitrary state $$|a\rangle$$ to state $$|b\rangle$$ with so-called uniformly controlled rotation, i.e. a rotation which rotational angle depends on combination of zeros and ones in controlling register.

The method uses $$Ry$$ and $$Rz$$ gates to achive this. $$Ry$$ gates are used for changing amplitudes and $$Rz$$ for changing phase. If you want to change only amplitudes, you can neglected part with $$Rz$$ gates.