intermediate · Programming · Multi-Qubit Registers & State Simulation
Preparing Uniform Superpositions
A quantum register of n qubits has 2n computational-basis states. Feeding every
algorithm with a uniform superposition over all of them is the starting point of
Deutsch–Jozsa, Grover, the quantum Fourier transform, and most other quantum algorithms.
Building that superposition costs exactly n gates.
One Hadamard per qubit
Recall what the Hadamard gate does to a single-qubit basis state:
H∣0⟩=2∣0⟩+∣1⟩,H∣1⟩=2∣0⟩−∣1⟩.
When every qubit starts in ∣0⟩ and we apply one H to each, the n-qubit state factors into
a tensor product:
H⊗n∣0⟩⊗n=k=0⨂n−12∣0⟩+∣1⟩=2n1x=0∑2n−1∣x⟩.
Each amplitude equals 1/2n, so by the Born rule every basis state is equally likely with
probability
(2n1)2=2n1.
For n=3 that is 1/8≈0.125 for each of the eight strings ∣000⟩ through
∣111⟩.
Counting amplitudes
It is worth building intuition with small n:
n=1: H∣0⟩ has 2 amplitudes, each 1/2.
n=2: H⊗2∣00⟩=21(∣00⟩+∣01⟩+∣10⟩+∣11⟩), each amplitude 1/2.
n=3: 8 amplitudes, each 221≈0.354.
n=10: 1024 amplitudes, each 1/32.
The preparation cost grows only as O(n) gates, while the number of states encoded grows as
O(2n) — this exponential encoding is the resource that quantum algorithms exploit.
Try it
Prepare the uniform superposition on 3 qubits and measure. The grader checks that
all 8 outcomes appear with equal probability 1/8.
Run your code to see the quantum state.
After running, open the Probabilities tab: every bar should reach exactly 0.125.
Sign in on the full site to ask questions and join the discussion.