Beginner5 min read
Bell State: Quantum Entanglement
Create two qubits that are perfectly correlated - the foundation of quantum computing and "spooky action at a distance."
What You'll Learn
- • How to create quantum superposition with the Hadamard gate
- • How to entangle qubits using CNOT
- • Why entangled qubits always give correlated results
The Code
bell.ql
# Bell State - Quantum EntanglementQUBIT q1, q2c1 = 0c2 = 0 # Create superpositionH(q1) # Entangle qubitsCNOT(q1, q2) # MeasureMEASURE q1 -> c1MEASURE q2 -> c2Step-by-Step Explanation
1. Declare Qubits
QUBIT q1, q2 creates two quantum bits. Unlike classical bits (always 0 or 1), qubits can exist in superposition.
2. Hadamard Gate
H(q1) puts q1 into superposition - it's now both |0⟩ and |1⟩ simultaneously with 50% probability each.
3. CNOT Gate (Entanglement)
CNOT(q1, q2) entangles the qubits. If q1 is |1⟩, q2 flips. Now their fates are linked!
4. Measurement
When measured, you only get 00 or11 - never 01 or 10. Measuring one qubit instantly determines the other!
Key Insight
Einstein called entanglement "spooky action at a distance" because measuring one qubit instantly affects the other - even if they're light-years apart. This is the foundation of quantum cryptography and the quantum internet.
Try It Yourself
python qubitlang_cli.py run bell.ql --shots 10000Request Files