# How to construct a quantum circuit for the following state transformation?

I have a certain transformations that goes as follows: Given $$A=|abc\rangle$$, $$B=|xyz\rangle$$, now I have cases as:

$$\text{if }c=1,z=1, b\oplus y=1 \implies \text{flip}(x)$$ $$\text{if }c=1, z=1 \implies \text{flip}(y)$$ $$\text{if }c=1\implies \text{flip}(z)$$ $$\text{if }b=1\implies \text{flip}(y)$$ $$\text{if }a=1\implies \text{flip}(x)$$

Can somebody just tell me the circuit for the bit-wise XOR that I have used between $$b$$ and $$y$$, i.e $$b\oplus y=1$$? The other gates I know are CNOT and Toffoli.

• Hi! What have you done so far and what issues are you having? – Mark S Apr 3 '19 at 17:26
• I can make circuit, but the only problem is how to implement the $b\oplus y=1$ in the circuit? – Upstart Apr 3 '19 at 17:37
• So the circuit you have above is same as what you want but with first line replaced by $c=1,z=1 \implies \text{flip}(x)$? – AHusain Apr 3 '19 at 19:56
• But it looks like they(you?) forgot to uncompute – AHusain Apr 3 '19 at 20:45
• It's not a full answer, it is a part. That is why it is a comment. Can you answer my clarifying question so someone could actually answer it? – AHusain Apr 3 '19 at 23:15

Why not simply try the following? You could have used an ancilla and computed $$y\oplus b$$ (that requires two controlled-nots, one controlled off each of $$b$$ and $$y$$, not a Toffoli) provided you later uncomputed the ancilla to reset it back to 0. But having an ancilla is unnecessary.
Just to explain what's happening in the boxed part of my circuit, both gates only work if $$c=z=1$$. Then the two gates flip $$x$$ depending on the value of $$b$$ or $$y$$ respectively. So, if $$b\oplus y=1$$, only one flip is applied, because one value is 0 and one value is 1. If $$b\oplus y=0$$, then either $$b=y=0$$, and no flip is applied, or $$b=y=1$$ and two flips are applied. But 2 flips cancel each other, so if $$b\oplus y=0$$, no operation is applied.
• Okay, thanx, just out of curiosity, if there had been an OR between $b$ and $y$ then there would have been 3 gates where the first would be controlled by $c=z=b=1$ and target $x$, second would be controlled by $c=z=y=1$ and target $x$, third would be controlled by $b=y=1$ and target as $x$. isn't it? – Upstart Apr 5 '19 at 10:38
• No, i just mean if $b \oplus y=1$ is replaced by $b ~~or~~y=1$ – Upstart Apr 5 '19 at 11:39
• Yes i forgot to write $c=z=1$. Thanx, and can you tell me how these circuit can be drawn. any online source? – Upstart Apr 5 '19 at 13:18