Quantum counting is a quantum algorithm that estimates the number of marked solutions M among N possible inputs of a search problem, using quantum phase estimation applied to the Grover iteration. Among quantum algorithms in quantum computing, it bridges two central techniques: the amplitude amplification of Grover’s algorithm and the eigenvalue extraction of phase estimation.
Proposed by Brassard, Høyer and Tapp in 1998, quantum counting achieves a quadratic speedup over classical sampling for approximate counting. It needs on the order of √N oracle calls to estimate M with useful accuracy, whereas a classical method must examine a number of inputs that grows linearly with N for comparable precision.
How quantum counting extracts the number of solutions
Quantum counting works because the Grover operator acts as a rotation by a fixed angle in a two-dimensional subspace, and that angle depends only on the fraction of marked items. If θ satisfies sin²(θ/2) = M/N, each Grover iteration rotates the state by θ, and the operator has eigenvalues e^(±iθ) in that subspace.
Phase estimation reads out θ directly. A register of t counting qubits is put into superposition, each qubit controls a power of the Grover operator (G, G², G⁴ and so on), and an inverse quantum Fourier transform converts the accumulated phases into a binary estimate of θ. Computing M = N·sin²(θ/2) then gives the count.
The algorithm proceeds in a fixed sequence of steps, summarized in the table below.
| Stage | Operation | Purpose |
|---|---|---|
| Initialization | Hadamards on counting and search registers | Uniform superposition over inputs and phases |
| Controlled Grover powers | Apply G to the power 2^k controlled by qubit k | Encode θ into the counting register |
| Inverse QFT | Quantum Fourier transform in reverse | Convert phases into a binary number |
| Measurement | Read the counting register | Obtain an estimate of θ |
| Classical post-processing | Compute N·sin²(θ/2) | Turn the angle into a count |
The search register does not need to be prepared in an eigenstate of G. The uniform superposition is an equal mixture of the two relevant eigenvectors, so phase estimation returns either +θ or −θ, and both lead to the same value of M after post-processing.
Precision, cost and success probability
The accuracy of quantum counting is set by the number of counting qubits t, because the largest Grover power applied is 2^(t−1). With roughly √N Grover iterations, the estimate of M has an error of order √M, and with more iterations the error shrinks in proportion. Each additional counting qubit doubles the oracle calls and roughly halves the angular error.
The following table shows how the main resources scale with the desired precision.
| Parameter | Typical scaling | Effect on the result |
|---|---|---|
| Counting qubits t | About log₂(1/ε) plus a few extra | Sets angular resolution |
| Oracle calls | About 2^t, of order √N for √M error | Dominates the runtime |
| Relative error ε | Needs about (1/ε)·√(N/M) calls | Smaller ε costs more queries |
| Success probability | At least 8/π² per run | Raised by repetition or extra qubits |
| Search register size | log₂ N qubits | Fixed by the problem |
A single run succeeds with probability of at least 8/π², about 81 percent, in the sense that the estimate falls within the guaranteed error bound. Adding a few extra counting qubits or taking the median of several runs pushes the failure probability down exponentially, a standard technique borrowed from phase estimation analysis.
Quantum counting compared with related algorithms
Quantum counting is a special case of quantum amplitude estimation, in which the amplitude of interest is the square root of M/N. It relies on Grover’s algorithm for the operator, on phase estimation for the readout and on the quantum Fourier transform for the final decoding, which places it at the junction of several neighboring topics.
The table contrasts quantum counting with the algorithms it is most often confused with.
| Algorithm | Question answered | Typical query cost |
|---|---|---|
| Quantum counting | How many solutions exist | O(√N) for √M error |
| Grover’s algorithm | Find one solution | O(√(N/M)) |
| Amplitude estimation | Estimate a probability amplitude | O(1/ε) |
| Quantum phase estimation | Estimate an eigenphase | O(1/ε) controlled calls |
| Classical sampling | Estimate M/N statistically | O(1/ε²) |
A practical bond between counting and search is the unknown-M problem. Grover’s algorithm overshoots if it runs too many iterations, so the optimal number of steps, about (π/4)·√(N/M), depends on M. Running quantum counting first supplies an estimate of M and therefore the correct iteration count.
Applications and practical use
Quantum counting matters wherever a problem asks how many rather than which one. Typical uses include deciding whether any solution exists (M = 0 or M > 0), estimating the size of a constraint-satisfaction solution space and providing the iteration count for Grover search.
- Existence testing: distinguishing zero solutions from at least one with O(√N) queries, a decision version of search.
- Approximate model counting: estimating the number of satisfying assignments of a Boolean formula, a hard problem in classical complexity.
- Monte Carlo style estimation: counting the fraction of samples that meet a criterion, closely related to amplitude estimation in finance and risk analysis.
- Search calibration: tuning the number of Grover iterations when M is unknown.
Variants without phase estimation have also been developed. Iterative and maximum-likelihood approaches run Grover powers of different lengths, measure the search register directly and fit θ classically. These versions avoid the controlled Grover powers and the inverse QFT, which makes them more suitable for near-term hardware.
Limitations of quantum counting
The quadratic speedup of quantum counting is provably optimal for black-box oracles, so no quantum algorithm can count unstructured solutions exponentially faster. The real cost also includes building the oracle, and an expensive oracle can erase the advantage for moderate N.
The table lists the main practical obstacles and their usual mitigations.
| Obstacle | Cause | Typical mitigation |
|---|---|---|
| Deep circuits | Controlled Grover powers up to 2^(t−1) | Iterative or likelihood-based variants |
| Noise sensitivity | Errors accumulate over many oracle calls | Error correction for useful scales |
| Oracle construction cost | Reversible logic for the predicate | Optimize the oracle before counting |
| Limited speedup | Only quadratic, not exponential | Use where N is very large |
On current noisy devices, quantum counting has been demonstrated only on small instances with a handful of qubits. A meaningful advantage requires fault-tolerant quantum computing, because the controlled Grover powers produce circuits far deeper than present coherence times allow.
A plain-language summary
Imagine a huge box of tickets. Some are winners, and you want to know how many winners there are. A normal approach checks tickets one by one, or samples many of them.
Quantum counting takes a different path. It turns the share of winners into a rotation angle. A quantum computer can measure that angle with fewer checks than sampling needs. From the angle, a simple formula gives the number of winners.
The gain is a square-root saving. For a million tickets, about a thousand quantum steps can give a useful estimate. That is a solid improvement, though not magic.
An example from practice
A research group studies a scheduling problem encoded as a Boolean formula with 20 variables, giving about one million possible assignments. Before searching for a valid schedule, the group wants to know roughly how many valid schedules exist, because that number sets the Grover iteration count.
In simulation, the team builds a reversible oracle that marks valid assignments and runs quantum counting with 10 counting qubits. The measured angle gives an estimate of about 240 valid schedules, within the expected error bound. Using this value, the group sets Grover search to about 50 iterations and finds a valid schedule with high probability on the first attempt, avoiding the overshoot that a guessed iteration count would risk.