Tutorial 1: Bell State¶
Time: 10 minutes
Level: Beginner
Concepts: Superposition, entanglement, measurement
Try it interactively
This tutorial is also available as a Jupyter notebook you can run locally:
Open 02_bell_states.ipynb
What You'll Build¶
A Bell State — the simplest example of quantum entanglement. Two qubits become perfectly correlated: measuring one instantly determines the other.
Background¶
The four Bell States are:
We'll create \(|\Phi^+\rangle\), the most common Bell State.
Step 1: Create the Circuit¶
We need 2 qubits, both starting in \(|0\rangle\).
Step 2: Apply Hadamard¶
After this, qubit 0 is in state \(\frac{1}{\sqrt{2}}(|0\rangle + |1\rangle)\), while qubit 1 is still \(|0\rangle\).
Combined state: \(\frac{1}{\sqrt{2}}(|00\rangle + |10\rangle)\)
Step 3: Apply CNOT¶
The CNOT flips qubit 1 when qubit 0 is \(|1\rangle\):
- \(|00\rangle \rightarrow |00\rangle\) (control is 0, no flip)
- \(|10\rangle \rightarrow |11\rangle\) (control is 1, flip target)
Result: \(\frac{1}{\sqrt{2}}(|00\rangle + |11\rangle) = |\Phi^+\rangle\)
Step 4: Measure¶
Step 5: Run and Verify¶
You should see roughly equal counts of 00 and 11, with no 01 or 10 —
that's entanglement!
Complete Code¶
import quantsdk as qs
# Create Bell State |Phi+>
circuit = qs.Circuit(2, name="bell-state")
circuit.h(0).cx(0, 1).measure_all()
# Run
result = qs.run(circuit, shots=1000)
# Analyze
print(f"Counts: {result.counts}")
print(f"Probabilities: {result.probabilities}")
print(f"Most likely: {result.most_likely}")
# Visualize
result.plot_histogram()
Other Bell States¶
Create all four Bell States by adding gates before measurement:
# |Phi+> = (|00> + |11>) / sqrt(2)
phi_plus = qs.Circuit(2).h(0).cx(0, 1).measure_all()
# |Phi-> = (|00> - |11>) / sqrt(2)
phi_minus = qs.Circuit(2).h(0).cx(0, 1).z(0).measure_all()
# |Psi+> = (|01> + |10>) / sqrt(2)
psi_plus = qs.Circuit(2).h(0).cx(0, 1).x(1).measure_all()
# |Psi-> = (|01> - |10>) / sqrt(2)
psi_minus = qs.Circuit(2).h(0).cx(0, 1).x(1).z(0).measure_all()
Key Takeaways¶
- Hadamard creates superposition — one qubit in two states at once
- CNOT creates entanglement — correlating two qubits
- Measurement collapses the state — you only see
00or11, never01or10 - Entanglement is a resource used in teleportation, cryptography, and error correction
Next Tutorial¶
Quantum Teleportation — use entanglement to "teleport" quantum information.