Skip to content

3-qubit repetition code that encodes 1 logical qubit and corrects single bit-flip (X) errors.

Notifications You must be signed in to change notification settings

iniestarchen/bit-flip-code

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

Bit-Flip Error Correction Code

Category: error-correction  |  Difficulty: intermediate  |  Qubits: 3  |  Gates: 8  |  Depth: 6

The 3-qubit bit-flip code encodes a logical qubit |ψ⟩_L = α|0⟩_L + β|1⟩_L into the physical state α|000⟩ + β|111⟩. If any single qubit undergoes a bit-flip (X error), the syndrome measurement identifies the faulty qubit and a correction is applied. This circuit encodes the initial state, applies a simulated error on q[1], then performs syndrome-based majority-vote correction.

Expected Output

c[0]=0 (logical |+⟩ decoded correctly despite X error on q[1])

Circuit

The OpenQASM 2.0 circuit is in circuit.qasm.

OPENQASM 2.0;
include "qelib1.inc";
// Bit-flip (repetition) code: encode |+> and correct one X error
qreg q[3];
creg c[1];
// Prepare logical |+> on data qubit q[0]
h q[0];
// Encode: spread to q[1] and q[2]
cx q[0],q[1];
cx q[0],q[2];
// Simulate a bit-flip error on q[1]
x q[1];
// Syndrome extraction and majority-vote correction
cx q[0],q[1];
cx q[0],q[2];
ccx q[1],q[2],q[0];
// Decode: measure logical qubit
h q[0];
measure q[0] -> c[0];

Tags

error-correction bit-flip repetition-code fault-tolerant

References

License

MIT — part of the OpenQC Algorithm Catalog.

About

3-qubit repetition code that encodes 1 logical qubit and corrects single bit-flip (X) errors.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published