Bit-Flip and Phase-Flip Codes

Table of Contents

  1. Introduction
  2. Quantum Errors and the Need for Error Correction
  3. Overview of Quantum Error Correcting Codes
  4. The Bit-Flip Code: Concept
  5. Bit-Flip Code Encoding
  6. Bit-Flip Code Detection and Correction
  7. Bit-Flip Error Correction Circuit
  8. Example: Correcting a Bit-Flip Error
  9. Limitations of Bit-Flip Code
  10. The Phase-Flip Code: Concept
  11. Phase-Flip Code Encoding
  12. Phase-Flip Code Detection and Correction
  13. Phase-Flip Error Correction Circuit
  14. Example: Correcting a Phase-Flip Error
  15. Using Hadamard Basis to Detect Phase Errors
  16. Comparison Between Bit-Flip and Phase-Flip
  17. Composite Codes and Error Combinations
  18. Combined Bit-Flip and Phase-Flip Code
  19. Role in Building the Shor Code
  20. Implementation in Real Hardware
  21. Role of Ancilla Qubits
  22. Syndrome Measurement Process
  23. Fault-Tolerant Considerations
  24. Summary Table of Operations
  25. Conclusion

1. Introduction

Quantum computers are prone to both bit-flip and phase-flip errors due to decoherence and imperfect gates. Unlike classical systems, quantum error correction must preserve coherence and entanglement — making it fundamentally different and more complex.


2. Quantum Errors and the Need for Error Correction

Errors in quantum systems may include:

  • Bit-flip: \( |0\rangle \leftrightarrow |1\rangle \)
  • Phase-flip: \( |+\rangle \leftrightarrow |-\rangle \)
  • Bit-phase flip: combination of both

Quantum error correcting codes (QECC) detect and correct these errors without measuring or collapsing the actual quantum state.


3. Overview of Quantum Error Correcting Codes

QECCs use redundancy to encode a logical qubit into multiple physical qubits. Error detection is performed using ancilla qubits and syndrome measurements.


4. The Bit-Flip Code: Concept

Corrects a single bit-flip error by encoding one logical qubit into three physical qubits:

\[
|0_L\rangle = |000\rangle, \quad |1_L\rangle = |111\rangle
\]


5. Bit-Flip Code Encoding

Given a qubit \( |\psi\rangle = \alpha|0\rangle + \beta|1\rangle \), it is encoded as:

\[
|\psi_L\rangle = \alpha|000\rangle + \beta|111\rangle
\]


6. Bit-Flip Code Detection and Correction

  • Measure parity between qubits (e.g., using CNOTs and ancilla)
  • Detect which qubit is flipped
  • Apply Pauli-X gate to correct

7. Bit-Flip Error Correction Circuit

  1. Encode using two CNOT gates
  2. Detect error via syndrome measurement (e.g., parity checks)
  3. Apply X gate to restore original state

8. Example: Correcting a Bit-Flip Error

If error flips second qubit:
\[
\alpha|010\rangle + \beta|101\rangle
\]

Syndrome identifies 2nd qubit as erroneous. Apply X to fix.


9. Limitations of Bit-Flip Code

  • Does not correct phase errors
  • Cannot protect against multiple simultaneous bit flips

10. The Phase-Flip Code: Concept

Corrects single phase-flip errors by rotating to the Hadamard basis:

\[
|+\rangle = \frac{1}{\sqrt{2}}(|0\rangle + |1\rangle), \quad
|-\rangle = \frac{1}{\sqrt{2}}(|0\rangle – |1\rangle)
\]


11. Phase-Flip Code Encoding

Use Hadamard gates before and after applying the bit-flip code:

  1. Apply Hadamard: \( H|\psi\rangle \)
  2. Encode using bit-flip code
  3. Reverse Hadamard after correction

12. Phase-Flip Code Detection and Correction

Same procedure as bit-flip code, but in Hadamard basis. Detect using parity checks and correct via Pauli-Z gate.


13. Phase-Flip Error Correction Circuit

  1. Apply Hadamard to all qubits
  2. Perform bit-flip detection
  3. Apply correction
  4. Re-apply Hadamard to return to original basis

14. Example: Correcting a Phase-Flip Error

If 2nd qubit flips phase:
\[
\alpha|0\rangle + \beta|1\rangle \rightarrow \alpha|0\rangle – \beta|1\rangle
\]

Encoded:
\[
\alpha|+++\rangle + \beta|—\rangle
\]

Phase error manifests as bit-flip in Hadamard basis, which is correctable.


15. Using Hadamard Basis to Detect Phase Errors

Hadamard transforms:

\[
H Z H = X
\]

This maps phase error to bit error for detection.


16. Comparison Between Bit-Flip and Phase-Flip

FeatureBit-Flip CodePhase-Flip Code
Error Type\( X \) errors\( Z \) errors
Encoding\(000\rangle,
CorrectionPauli-XPauli-Z

17. Composite Codes and Error Combinations

To correct both bit and phase flips, combine codes:

  • Use concatenation
  • Leads to Shor Code (9-qubit code)

18. Combined Bit-Flip and Phase-Flip Code

A logical qubit can be encoded as:

\[
|\psi\rangle \rightarrow \text{Phase-encoded} \rightarrow \text{Bit-encoded}
\]

This results in a 9-qubit protection against both error types.


19. Role in Building the Shor Code

Shor’s Code:

  • First QECC to correct arbitrary single-qubit errors
  • Combines bit-flip and phase-flip ideas into 9-qubit structure

20. Implementation in Real Hardware

Qiskit and other frameworks simulate these codes using ancilla qubits and controlled operations for parity checks.


21. Role of Ancilla Qubits

Ancilla qubits:

  • Do not affect encoded qubit
  • Help extract error syndrome
  • Must be measured and reset for reuse

22. Syndrome Measurement Process

Use stabilizers like:

  • \( Z_1 Z_2 \), \( Z_2 Z_3 \) for bit-flip code
  • \( X_1 X_2 \), \( X_2 X_3 \) in Hadamard basis for phase-flip

23. Fault-Tolerant Considerations

  • Measurement circuits must not propagate additional errors
  • Requires careful gate sequencing and ancilla verification

24. Summary Table of Operations

Code TypeProtects AgainstEncodingCorrection
Bit-Flip\( X \)\(000\rangle \) / \(
Phase-Flip\( Z \)\(+++\rangle \) / \(
Shor Code\( X, Z \)9-qubitFull QECC

25. Conclusion

The bit-flip and phase-flip codes represent foundational steps toward quantum error correction. While they protect against individual types of errors, their principles are extended in larger codes like Shor’s code, making them critical building blocks for quantum fault tolerance.


.