# How to store error caused by circuit manipulation

Given that

is equivalent to

I am interested into not performing the last CNOT. Rather, I want to keep track of the error I intentionally introduced by removing it.

I am trying to do this by means of auxilliary qubits.

Intuitively, I may do this by means of the following protocol:

However, this doesn't seem to me as it does the right correction.

On contrary, I found that the following protocol gives the right density matrix: Here I just removed what it was supposed to be a $$Z$$ correction. I don't get why it is not necessary (or maybe I am just using quirk's tools wrong).

• Hello. I am not sure to understand what you want to do actually. Could you clarify what you mean by "I am interested into storing the last CNOT in auxilliary qubits"? Oct 31, 2022 at 13:42
• Thanks, is it clear now? Oct 31, 2022 at 14:18

If you want to propagate a non-Pauli operator through a stabilizer circuit, a useful conversion is to transform it into a form where all the non-Pauli stuff is hidden away on ancilla qubits.

For example, a CNOT can be rewritten like this:

Which seems like a terrible idea, but because the parts touching the main circuit area are just Pauli product controls you can now easily move it through stabilizer operations by rewriting the Paulis. For example:

Once you've finished moving it to its final destination, you can attempt to convert back to a circuit that doesn't use ancilla qubits. Or just leave it in this form; it's really quite a useful way to understand a CNOT in a more generalized basis-independent way. It negates the amplitude of states in the intersection of the -1 eigenspaces of two Pauli product observables.

This same trick works for any operation you want to move through a circuit, including non-Clifford operations like Toffoli gates and T gates. It's the same underlying idea behind Clifford frame tracking used in "A Game of Surface Codes".

• May you please show how to convert back your example after the moving? Oct 31, 2022 at 16:50
• @DanieleCuomo for such a short example it's just going to be the CNOT conjugated by the Cliffords it moved through. Nov 1, 2022 at 19:43
• May you please explain what you mean by conjugating the CNOT by that Clifford? Nov 21, 2022 at 16:20
• @DanieleCuomo Conjugating means to left-multiply and right-multiply by a matrix and its inverse, respectively. Conjugating A by B means to compute $B A B^{-1}$. Nov 21, 2022 at 18:23
• Thank you. Hence, basically, to eliminate the auxilliary qubits one should insert two copies (one conjugated) of the clifford. Nov 21, 2022 at 18:25