# Where (in the algorithm) is the logical qubit encoded in Q.E.C?

I have a basic question about the encoding of logical information into physical qubits.

I only know the 3 qubit code (I have very limited knowledge in QEC).

The 3 qubit code is usually presented as: we have a data defined on a single qubit, we want to protect it.

To do it, we encode it on 3 physical qubits :

$$a|0\rangle + b |1\rangle \rightarrow a|000\rangle + b |111\rangle$$

And then by using ancillas, we check the parity and we know if a bit flip-occurred (in very short summary).

My question is:

In practice when we have a quantum computer, we encode the input in physical qubits (3 in this example), and then if we want to run a quantum algorithm, it will apply unitary on these 3 physical qubits?

Or is it more: we do everything with the single qubit and then at the end of the algorithm we protect by encoding the result on physical qubits.

For me, it would make sense that it is the first explanation but I would like to check this, like how and where are implemented Q.E.C in a quantum computer.

An example :

For example imagine that my quantum algorithm is just applying a unitary $$U$$ on an input $$a|0\rangle + b |1\rangle$$, would it work as :

• I apply $$U$$ on $$a|0\rangle + b |1\rangle$$ : $$U a|0\rangle + b |1\rangle = c |0\rangle + d |1\rangle$$
• I encode and protect it with QEC

or

• I encode : $$a|0\rangle + b |1\rangle \rightarrow a|000\rangle + b |111\rangle$$
• I apply the "logical equivalent" $$U_L$$ to the encoded data : $$U_L a|000\rangle + b |111\rangle = c |000\rangle + d |111\rangle$$