Curriculum / Quantum Networking / Entanglement Swapping Simulation
Entanglement Swapping Simulation
Simulate the entanglement swapping protocol to extend quantum links across a 3-node network.
Entanglement Swapping Simulation
Entanglement swapping extends entanglement across nodes without transmitting qubits the full distance. It is the fundamental operation of quantum repeaters. Implementing it in simulation builds concrete intuition for how the Bell state measurement works and why the correction operations restore the target state.
The Protocol in Detail
Setup: Three nodes A, B, C.
- •A and B share Bell pair |Φ+⟩₁₂ (qubits 1=A, 2=B₁)
- •B and C share Bell pair |Φ+⟩₃₄ (qubits 3=B₂, 4=C)
The 4-qubit initial state is:
|Φ+⟩₁₂ ⊗ |Φ+⟩₃₄
Node B's goal: measure qubits 2 and 3 in the Bell basis to create entanglement between qubits 1 and 4 (A and C).
Bell Basis Measurement
A Bell basis measurement on two qubits is implemented by:
- 1.Apply CNOT with qubit 2 as control, qubit 3 as target
- 2.Apply Hadamard to qubit 2
- 3.Measure qubits 2 and 3 in the Z basis
The two classical bits (m2, m3) from this measurement indicate which of the four Bell states was measured.
Correction Operations
Based on (m2, m3), node A applies:
- •(0, 0): I (identity, no correction)
- •(0, 1): X on qubit 1
- •(1, 0): Z on qubit 1
- •(1, 1): ZX on qubit 1
After correction, qubits 1 and 4 are in state |Φ+⟩: entangled even though they never interacted.
Why This Works
The four-qubit initial state can be rewritten in the Bell basis of qubits 2 and 3:
|Φ+⟩₁₂ ⊗ |Φ+⟩₃₄ = (1/2) Σ_{m2,m3} |Bell_{m2,m3}⟩₂₃ ⊗ (correction) |Φ+⟩₁₄
When B measures in the Bell basis and gets outcome (m2, m3), qubits 1 and 4 collapse to the state (correction) |Φ+⟩: a Bell pair with a known (and correctable) Pauli rotation. After A applies the correction, A and C share a perfect |Φ+⟩.
Your Challenge
The starter code provides the 4-qubit initial state and utility functions. Implement bell_basis_measurement (the BSM on qubits 2 and 3) and apply_correction (the correction on qubit 1 based on the measurement result).
This is the opening of the lesson. The full walkthrough, the interactive circuit, and the graded challenge continue inside myqubit.
How this lesson works
A hands-on coding challenge. You write Qiskit-compatible Python in the browser editor, run it instantly via WebAssembly, watch the circuit and Bloch sphere react, and pass automatic output checks. The AI tutor Qubitus gives Socratic hints if you get stuck.
Part of: Quantum Networking
Build quantum networks from the ground up, entanglement distribution, quantum repeaters, the quantum internet, and satellite-based QKD.
This lesson is part of Pro
Unlock Quantum Networking and all 10 tracks with Pro: $12.99/month, $79/year, or $97 lifetime. Start with the free track first if you are new.