Algorithms · Quantum counting (QPE + Grover)
Quantum counting
Estimates how many items in an unstructured search space satisfy an oracle, without checking them one by one.
Strong empiricalUpdated
Open on the mapView frozen graph
3 steps across 5 wires. Hover a step, or press play to go through them in order.
Expected outcomes
- Peak near φ=1/6 (3-bit QPE, N=4, M=1)60%
- Adjacent phase-bin leakage40%
- Steps3
- Wires5
- Qubits5 (3 counting + 2 system, N=4)
- Toy instanceN=4, M=1 → θ=π/3
- Query complexityO(√(N/M)) oracle calls
- Papers2
A part this method uses, worked through
This page says Grover's amplitude amplification
— here is a concrete, runnable instance of it.
Grover's algorithm finds |101⟩
3 qubits, searching for |101⟩ among 8 states, with 2 Grover iterations.
Where it ends up
- 10195%
- 0001%
- 1101%
- 0011%
- 4 more outcomes3%
Measuring gives 101, the marked state, with high probability.
One of its steps changes only phase: the outcome probabilities stay put while the state does not.
Open this part in StudioA part this method uses, worked through
This page says phase estimation
— here is a concrete, runnable instance of it.
Phase estimation of P(3*pi/4)
3 counting qubits estimating the phase of P(3π/4), which is 2π·3/8 exactly: a phase 3-bit QPE can represent exactly.
Where it ends up
- 1011100%
The counting register reads 011 = 3 with probability 1: angle/(2π) = 3/8, recovered exactly.
One of its steps changes only phase: the outcome probabilities stay put while the state does not.
Open this part in StudioQuantum counting combines Grover's amplitude amplification with phase estimation: instead of finding a marked item, it estimates how many marked items exist.
TakesNothingWhat joins here
No input port at this edge: the record publishes no gate sequence and no register, so there is nothing here to read one off — and unlike a declared hole, nothing has been recorded about what belongs here.
Nothing in the Atlas meets this end.
ReturnsNothingWhat joins here
No output port at this edge: the record publishes no gate sequence and no register, so there is nothing here to read one off — and unlike a declared hole, nothing has been recorded about what belongs here.
Nothing in the Atlas meets this end.
This record publishes no gate sequence and no register, so there is nothing here to read an interface off. Absent rather than empty. See all 152 →
Quantum counting answers "how many of the basis states satisfy an oracle" without checking each one, by running quantum phase estimation on the Grover iterator built from that oracle.
Why it works. In the 2-dimensional subspace spanned by the uniform superposition of marked ("good") and unmarked ("bad") states, acts as a rotation by angle where
so has eigenvalues on the two eigenvectors of that rotation. Phase estimation with counting qubits applied to (controlled powers of) estimates to -bit precision; the count is recovered as .
Small worked instance. Take ( system qubits) with marked state. Then . In units of , the phase to be estimated is . A 3-bit counting register (t=3, giving -resolution phase bins) would place the estimate near the bin closest to , i.e. bin or out of — illustrating why more counting qubits are needed as gets small or precise counts are required.
Complexity. With counting qubits the circuit uses controlled applications of (each one Grover-oracle call), giving an estimate of with additive error with high probability — a quadratic improvement in oracle calls over classical sampling-based estimation of to the same precision, matching the standard Grover speedup structure it is built from.
TakesNothingWhat joins here
No input port at this edge: the record publishes no gate sequence and no register, so there is nothing here to read one off — and unlike a declared hole, nothing has been recorded about what belongs here.
Nothing in the Atlas meets this end.
ReturnsNothingWhat joins here
No output port at this edge: the record publishes no gate sequence and no register, so there is nothing here to read one off — and unlike a declared hole, nothing has been recorded about what belongs here.
Nothing in the Atlas meets this end.
This record publishes no gate sequence and no register, so there is nothing here to read an interface off. Absent rather than empty. See all 152 →
- Qubits
- 5 (3 counting + 2 system, N=4)
- Toy instance
- N=4, M=1 → θ=π/3
- Query complexity
- O(√(N/M)) oracle calls
- Eigenphase relation
- sin²(θ/2) = M/N
- Counting precision
- t bits → error O(N/2^t)
- Built from
- Grover iterator G
H×5on c[0], c[1], c[2], s[0], s[1]Controlled Grover powerson c[0], c[1], c[2], s[0], s[1]Inverse QFT (counting reg.)on c[0], c[1], c[2]
Quantum vs classical
Classical baseline
Exact classical counting requires checking all N items, O(N) oracle evaluations, to determine M exactly.
Quantum claim
Quantum counting estimates M to a given precision using O(√N) oracle-equivalent calls via phase estimation on the Grover iterator, at the cost of only an estimate rather than an exact count.
How to compare
Compare the number of counting qubits (precision), total controlled-oracle calls, and the resulting confidence interval on M against classical sampling or exhaustive counting for the same N.
Nobody has reviewed this record for gaps yet.
from qiskit import QuantumCircuit
from qiskit.circuit.library import QFT, GroverOperator
# Oracle marking |11> out of N=4 basis states (M=1)
oracle = QuantumCircuit(2)
oracle.cz(0, 1)
grover_op = GroverOperator(oracle)
t = 3 # counting qubits
qc = QuantumCircuit(t + 2, t)
qc.h(range(t))
qc.h(range(t, t + 2))
for i in range(t):
power = 2 ** i
controlled_g = grover_op.repeat(power).to_gate().control(1)
qc.append(controlled_g, [i] + list(range(t, t + 2)))
qc.append(QFT(t, inverse=True), range(t))
qc.measure(range(t), range(t))
FINAL_CIRCUIT = qcWhere this sits
This record is named by the layer graph at:
- Estimate the eigenphase of a unitary Slot
Takes A circuit for U that can be applied as controlled U^(2^j), a preparation routine for a state whose overlap with the target eigenvector is not negligible, the number of bits of the phase wanted, and the failure probability that may be tolerated. Returns An estimate of the eigenphase to the requested number of bits, with the failure probability it was obtained at, plus the two costs that actually differ between routes: how many ancillas were held at once, and how many sequential rounds were run.
Related entries
- Grover unstructured search
Algorithms
- Amplitude amplification
Algorithms
- Quantum amplitude estimation
Algorithms
- Quantum phase estimation
Algorithms
References
- Quantum Counting
Gilles Brassard, Peter Hoyer, Alain Tapp · 1998
Introduces the quantum counting algorithm combining Grover's iterator with phase estimation.
- A fast quantum mechanical algorithm for database search
Lov K. Grover · 1996
Defines the Grover iterator whose eigenphase this algorithm estimates.