I'm a bit confused about in which case the two unitary gates in a quantum circuit could be canceled? I'm reading an example in this paper. In the following diagram, Figure (b) is a simplified circuit of Figure (a): enter image description here I'm wondering if Figure (b) is the simplest optimization result of Fig. a? In their diagram, the first and third part of the circuit are grouped together, I do understand that two Hadamard gates are canceled, but why the two C-NOT gates (acting on the second and the ancilla qubit) are also canceled? (in this case, those two C-NOT gates are not next to each other)

My guess is they're canceled since no unitary gates are directly sandwiched between the two control qubits (despite there's another C-NOT between them targeted at the same ancilla qubit). Is this the right explanation? How can I have a better understanding of what's going on?



1 Answer 1


It is true that these two circuits are equivalent:

enter image description here

as the the controlled qubit $q_1$ is the same. So if $q_1$ is a $|1\rangle$ then you can see that it will apply two $X$ gates to $q_2$ and they will cancel each other out.

  • $\begingroup$ Thanks, that really helps :) $\endgroup$
    – ZR-
    Nov 20, 2020 at 14:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.