Skip to content

3-qubit code that corrects single phase-flip (Z) errors by encoding in the X basis.

Notifications You must be signed in to change notification settings

iniestarchen/phase-flip-code

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

Phase-Flip Error Correction Code

Category: error-correction  |  Difficulty: intermediate  |  Qubits: 3  |  Gates: 11  |  Depth: 7

The phase-flip code is the dual of the bit-flip code, operating in the X basis. A logical qubit is encoded as α|+++⟩ + β|---⟩ using CNOT + Hadamard. A Z error on any physical qubit flips the X-basis eigenvalue; the syndrome measurement detects and corrects it. This code cannot correct both bit and phase errors — that requires the Shor or Steane codes.

Expected Output

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

Circuit

The OpenQASM 2.0 circuit is in circuit.qasm.

OPENQASM 2.0;
include "qelib1.inc";
// Phase-flip code: encode |+> in X basis, correct one Z error
qreg q[3];
creg c[1];
// Prepare logical |+>
h q[0];
// Encode in X basis: spread then Hadamard
cx q[0],q[1];
cx q[0],q[2];
h q[0]; h q[1]; h q[2];
// Simulate a phase-flip error on q[1]
z q[1];
// Decode: reverse encoding
h q[0]; h q[1]; h q[2];
cx q[0],q[1];
cx q[0],q[2];
ccx q[1],q[2],q[0];
h q[0];
measure q[0] -> c[0];

Tags

error-correction phase-flip x-basis fault-tolerant

References

License

MIT — part of the OpenQC Algorithm Catalog.

About

3-qubit code that corrects single phase-flip (Z) errors by encoding in the X basis.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published