# Restoring an initial state after computation

Let me first tell my problem statement. Suppose I have a uniform superposition of states $$|A\rangle=\dfrac{1}{2^{9}}\sum_{i,j,k=0}^{2^6-1}|0\rangle^{\otimes 8}|i\rangle|j\rangle|k\rangle,$$ where $$|0\rangle^{\otimes 8}$$ is pre-defined for each $$i,j,k$$. So suppose for a particular instance in this superposition state we have the $$|0\rangle^{\otimes 8}$$ register as $$|b_7b_6b_5b_4b_3b_2b_1b_0\rangle$$ where each $$b_i\in\{0,1\}$$. Now I want to transform this register by a certain rule and that rule is: $$|b_7b_6b_5b_4b_3b_2b_1b_0\rangle\to |b_6~ b_5 b_4 (b_3\oplus b_7) (b_2\oplus b_7)~b_1~(b_1\oplus b_7) ~b_7\rangle$$ so for this transform I initialize a register $$|0\rangle^{\otimes 8}$$. So to do this computation I first

1. Modify my original superposition state as $$\displaystyle |\tilde{A}\rangle=\dfrac{1}{2^{9}}\sum_{i,j,k=0}^{2^6-1}|0\rangle^{\otimes 8}|0\rangle_B^{\otimes 8}|i\rangle|j\rangle|k\rangle$$, then

2. I start the transformation process by first applying the controlled NOT gate operation between the working register and the output register i.e $$|b_7b_6b_5b_4b_3b_2b_1b_0\rangle$$ and $$0\rangle_B^{\otimes 8}$$. This C-NOT gate changes the 3 qubit of $$0\rangle_B^{\otimes 8}$$ from the right to $$b_7$$. To do this I apply the transform $$U_1= P_1\otimes I^{\otimes 12}\otimes X\otimes I^{\otimes 2}\otimes I^{\otimes 3l}+P_0\otimes I^{\otimes 15+3l}$$ So after this step i have the superposition state as $$\displaystyle\dfrac{1}{2^{9}}\sum_{i,j,k=0}^{2^6-1}|b_7b_6b_5b_4b_3b_2b_1b_0\rangle|00000b_700\rangle|i\rangle|j\rangle|k\rangle.$$

3. Next, I apply controlled not operation between the working and output registers to change the state of the output register as $$|000b_7b_70b_7b_7\rangle$$, the operator I define is $$U_2=\prod_{i=0}^{4}(P_1\otimes I^{\otimes 10+i}\otimes X\otimes I^{\otimes 4-i}\otimes I^{\otimes 3l}+ P_0\otimes I^{\otimes 10+i}\otimes I\otimes I^{\otimes 4-i}\otimes I^{\otimes 3l})$$ At the end of this step I have the working register as $$|b_7b_6b_5b_4b_3b_2b_1b_0\rangle$$ and the output register as $$|000b_7b_70b_7b_7\rangle$$.

The final step is I apply the C-NOT between these two registers with control starting from $$b_6$$. So I define the operator $$U_3=\prod_{i=1}^{8}I^{\otimes i}\otimes P_1\otimes I^{\otimes 6}\otimes X\otimes I^{\otimes 8-i}\otimes I^{\otimes 3l}$$ after this step I have the state as $$\dfrac{1}{2^{9}}\sum_{i,j,k=0}^{2^6-1}|b_7b_6b_5b_4b_3b_2b_1b_0\rangle~ |b_6~ b_5 b_4 (b_3\oplus b_7) (b_2\oplus b_7)~b_1~(b_1\oplus b_7) ~b_7\rangle~\rangle|i\rangle~|j\rangle~|k\rangle$$ So the overall operation need to reach the desired state would be $$\mathbf{U}=U_3U_2U_1$$ operated on $$|\tilde{A}\rangle$$. Now I have a few question about this whole transformation process:

Q1. Are the transformation that I have written correct? Can somebody check?

Q2. If it is correct, then am I able to convey the operation that I am trying to do, by the explanations including the quantum computing terms like qubit, register, working, output register?

Q3. As we can see, the classical transformation is itself invertible, since given $$|b_6~ b_5 b_4 (b_3\oplus b_7) (b_2\oplus b_7)~b_1~(b_1\oplus b_7) ~b_7\rangle$$ we can get $$|b_7b_6b_5b_4b_3b_2b_1b_0\rangle$$ but for this to be done via quantum computation we had to introduce the ancillary register $$|0\rangle_B$$ to store the output, but given the output since I can always get back the input, why do I keep that working register now so is there some unitary/non unitary transform that does resets the first register to the state $$|00000000\rangle$$ and after that to get the superposition as $$|B\rangle=\dfrac{1}{2^{9}}\sum_{i,j,k=0}^{2^6-1}|0\rangle^{\otimes 8}|i\rangle|j\rangle|k\rangle$$ where the register $$|0\rangle^8$$ here has the modified output from the transform $$\mathbf{U}$$.

Edit: Do i just measure the first register and then throw them away ?

• Did you figure this out? For the last point, are you familiar with the partial trace operation? Something looks fishy to me that your final expression is a product state in the first 2 registers (i.e. they're not entangled) – bRost03 Jun 10 at 3:53
• I wrote what i wanted to implement, where does your doubt come can you explain? – Upstart Jun 10 at 20:46