# More efficient implementation of $4$-qubit gate

While working on an error detection algorithm, I stumbled upon the problem of simplifying the following implementation

Here, the $$S$$ gate is defined by

$$S=\left( \begin{array}{cc} \frac{\sqrt{3}}{2} & -\frac{1}{2} e^{\frac{i \pi }{3}} \\ \frac{1}{2} e^{\frac{i \pi }{3}} & \frac{1}{2} \sqrt{3} e^{\frac{2 i \pi }{3}} \\ \end{array} \right)$$

The issue with this implementation is that I am basically de-encoding the state (the $$C_{not}$$s and $$S^\dagger$$s in the beginning), performing the required logical gates (the $$C_{not}$$s and $$X$$ gate in the middle), and then re-encoding the state afterwords (the $$C_{not}$$s and $$S$$s at the end). Instead of this de-encoding re-encoding procedure, I would like to find some implementation that is equivalent to the above set of gates that uses less $$C_{not}$$s and single-qubit gates overall. I would greatly appreciate if anyone knew of an efficient way to implement this type of gate or some papers I could research in order to further my understanding of said gate.

EDIT: In response to @ryanhill1: It is an error detection algorithm that I am developing. The basic idea is to use two qubits (and therefore expanding the hilbert space) to represent a single qubit through the encoding

$$|0\rangle_L=-\frac{1}{4} \sqrt{3} e^{\frac{i \pi }{3}}|00\rangle+\frac{3}{4} e^{\frac{2 i \pi }{3}}|01\rangle-\frac{\sqrt{3}}{4}|10\rangle-\frac{1}{4} e^{\frac{2 i \pi }{3}}|11\rangle$$

$$|1\rangle_L=-\frac{1}{4} \sqrt{3} e^{\frac{i \pi }{3}}|00\rangle-\frac{1}{4} e^{\frac{2 i \pi }{3}}|01\rangle-\frac{\sqrt{3}}{4}|10\rangle+\frac{3}{4} e^{\frac{2 i \pi }{3}}|11\rangle$$

This encoding is actually achieved using a pair of $$S$$ gates and a single $$C_{not}$$ gate. Hence the issue I have: I want to make a gate that acts on $$|0\rangle_L$$ and $$|1\rangle_L$$ like a $$C_{not}$$ acts on $$|0\rangle$$ and $$|1\rangle$$ without de-encoding and the re-encoding the entire state.

• What gates do you have at your disposal? Feb 13 '21 at 22:25
• @Adam_Zalcman $C_{not}$s and general single qubit gates (over three continous variable angles) . Or the base gates available in qiskit for those who use IBMs system. Feb 14 '21 at 4:29
• Which error detection algorithm is this circuit part of? Knowing the circuits function would help Feb 16 '21 at 15:50

As I now understand the question, it is more a question of "can logical controlled-not be implemented without decoding the states first?" which is a thoroughly different question to simply "can this circuit be simplified?". In fact, what that question really means is that, throughout the whole circuit, a single-qubit error should never be able to create a logical error in the code.

I don't believe that this can be done for this specific code. Usually, one has to build the facility into the code by design. This is one of the key things that the stabilizer formalism helps you with.

Let me try to explain my thinking a bit (not that this is a rigorous proof of impossibility). First, we need to know the logical-$$X$$ for the code. This is reasonably straightforward: if we group terms $$|0\rangle_L=-\frac{\sqrt{3}}{4}(e^{i\pi/3}|0\rangle+|1\rangle)|0\rangle+\frac{e^{i2\pi/3}}{4}(3|0\rangle-|1\rangle)|1\rangle$$ and $$|1\rangle_L=-\frac{\sqrt{3}}{4}(e^{i\pi/3}|0\rangle+|1\rangle)|0\rangle+\frac{e^{i2\pi/3}}{4}(3|1\rangle-|0\rangle)|1\rangle.$$ To convert between the two, we need a controlled-not controlled off the second qubit targeting the first.

Thus, to make logical controlled-not, you need to apply (physical) controlled-not on the second pair of qubits controlled off the state of the first pair of qubits. This already suggests that you need something of the complexity of at least Toffoli, so in terms of simple gate counts, it seems unlikely that your circuit could be bettered.

But how might we implement that control? The most obvious is to decode the qubit first and control off that. That's what we're trying to avoid. The next most natural idea is a little trick: find local unitaries $$U$$ and $$V$$ such that \begin{align*} U\otimes V|0\rangle_L&=\alpha|00\rangle+\beta|11\rangle \\ U\otimes V|1\rangle_L&=\gamma|01\rangle+\delta|10\rangle \end{align*} I haven't verified whether such a transformation exists, but chances are fair because we choose $$U,V$$ to find the Schmidt decomposition of $$|0\rangle_L$$, guaranteeing the first line. Then, of course, $$U\otimes V|1\rangle_L$$ must be orthogonal to $$U\otimes V|0\rangle_L$$ so you're only worrying if it contains a component $$\beta|00\rangle-\alpha|00\rangle$$. So, let's assume such a transformation exists (if it doesn't, then I think you have very little hope). If so, then once we've applied $$U\otimes V$$ to the first pair of qubits, the parity of the two qubits tells us the logical state. Hence, we'd be able to implement the logical controlled-not using a pair of Toffolis: This looks not too bad. However, even in this case, given that your logical states have the same Schmidt coefficients, that rather suggests that $$\{\alpha,\beta\}=\{\gamma,\delta\}$$ (perhaps up to some phases). But if that's the case, then applying Pauli $$X$$ on just one of the qubits will inter-convert the logical states, i.e. you've got the same error susceptibility that you're trying to avoid. I think there's very little hope of avoiding this for a two-qubit code.

• Thank you for the in depth answer +100 Feb 20 '21 at 22:51