Five-qubit error correcting code
The five-qubit error correcting code is the smallest quantum error correcting code that can protect a logical qubit from any arbitrary single qubit error. In this code, 5 physical qubits are used to encode the logical qubit. With  and  being Pauli matrices and  the Identity matrix, this code's generators are . Its logical operators are  and  . Once the logical qubit is encoded, errors on the physical qubits can be detected via stabilizer measurements. A lookup table that maps the results of the stabilizer measurements to the types and locations of the errors gives the control system of the quantum computer enough information to correct errors. Measurements 

Stabilizer measurements are parity measurements that measure the stabilizers of physical qubits. For example, to measure the first stabilizer (), a parity measurement of  of the first qubit,  on the second,  on the third,  on the fourth , and  on the fifth is performed. Since there are four stabilizers, 4 ancillas will be used to measure them. The first 4 qubits in the image above are the ancillas. The resulting bits from the ancillas is the syndrome; which encodes the type of error that occurred and its location. A logical qubit can be measured in the computational basis by performing a parity measurement on . If the measured ancilla is , the logical qubit is . If the measured ancilla is , the logical qubit is . Error correction 
It is possible to compute all the single qubit errors that can occur and how to correct them. This is done by calculating what errors commute with the stabilizers. For example, if there is an  error on the first qubit and no errors on the others (), it commutes with the first stabilizer . This means that if an X error occurs on the first qubit, the first ancilla qubit will be 0. The second ancilla qubit: , the third:  and the fourth . So if an X error occurs on the first qubit, the syndrome will be ; which is shown in the table below, to the right of . Similar calculations are realized for all other possible errors to fill out the table. To correct an error, the same operation is performed on the physical qubit based on its syndrome. If the syndrome is , an  gate is applied to the first qubit to reverse the error. Encoding 
The first step in executing error corrected quantum computation is to encode the computer's initial state by transforming the physical qubits into logical codewords. Since the logical codewords for the five qubit code are 

,

Stabilizer measurements followed by a  measurement can be used to encode 5 physical qubits into a logical qubit. To prepare , perform stabilizer measurements and apply error correction. After error correction, the logical state is guaranteed to be a logical codeword. If the ancilla of measuring  is , The logical state is . If it's , applying  will transform it into . References 

Quantum computing