Sign in
← Atlas
Strong empiricalAlgorithmsQuantum counting (QPE + Grover)

Quantum counting

Estimates how many items in an unstructured search space satisfy an oracle, without checking them one by one.

countingphase estimationgroveramplitude amplification

Atlas stars stay in the public catalog. Saving this entry to your workspace starts an unstarred private copy.

Quantum counting combines Grover's amplitude amplification with phase estimation: instead of finding a marked item, it estimates how many marked items exist.

Circuit & simulation
Peak near φ=1/6 (3-bit QPE, N=4, M=1)60%
Adjacent phase-bin leakage40%
What this takes and returns
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 →

Where 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.

How it works

Quantum counting answers "how many of the N=2nN=2^n basis states satisfy an oracle" without checking each one, by running quantum phase estimation on the Grover iterator G=AS0A1SχG=-AS_0A^{-1}S_\chi built from that oracle.

Why it works. In the 2-dimensional subspace spanned by the uniform superposition of marked ("good") and unmarked ("bad") states, GG acts as a rotation by angle θ\theta where

sin2 ⁣(θ2)=MN,\sin^2\!\left(\frac{\theta}{2}\right) = \frac{M}{N},

so GG has eigenvalues e±iθe^{\pm i\theta} on the two eigenvectors of that rotation. Phase estimation with tt counting qubits applied to (controlled powers of) GG estimates θ\theta to tt-bit precision; the count is recovered as M~=Nsin2(θ~/2)\tilde M = N\sin^2(\tilde\theta/2).

Small worked instance. Take N=4N=4 (n=2n=2 system qubits) with M=1M=1 marked state. Then sin2(θ/2)=1/4sin(θ/2)=1/2θ/2=π/6θ=π/3\sin^2(\theta/2)=1/4 \Rightarrow \sin(\theta/2)=1/2 \Rightarrow \theta/2=\pi/6 \Rightarrow \theta=\pi/3. In units of 2π2\pi, the phase to be estimated is φ=θ/2π=1/6\varphi=\theta/2\pi=1/6. A 3-bit counting register (t=3, giving 1/81/8-resolution phase bins) would place the estimate near the bin closest to 1/60.1671/6\approx 0.167, i.e. bin 0.1250.125 or 0.250.25 out of 88 — illustrating why more counting qubits are needed as M/NM/N gets small or precise counts are required.

Complexity. With tt counting qubits the circuit uses O(2t)O(2^t) controlled applications of GG (each one Grover-oracle call), giving an estimate of MM with additive error O(N/2t)O(N/2^t) with high probability — a quadratic improvement in oracle calls over classical sampling-based estimation of M/NM/N to the same precision, matching the standard Grover speedup structure it is built from.

Implementation
Native
quantum_counting.py
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 = qc
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.

Declared gaps

Nobody has reviewed this record for gaps yet.

Literature & references
Quantum Counting1998 · Gilles Brassard, Peter Hoyer, Alain Tapp

Introduces the quantum counting algorithm combining Grover's iterator with phase estimation.

arxiv.org/abs/quant-ph/9805082
A fast quantum mechanical algorithm for database search1996 · Lov K. Grover

Defines the Grover iterator whose eigenphase this algorithm estimates.

arxiv.org/abs/quant-ph/9605043