Skip to content
Current section
The Quantum Computing Enthusiast’s Hub
Saved
All sections

All sections

Saved
Skip Learn navigation
Encyclopedia
Topic

Quantum counting

The estimation of the number of marked inputs by estimating the amplitude associated with their fraction.

Also called approximate quantum counting

Edition released Coverage: Overview · Technical
On this page

Definition and significance

Quantum counting combines a search predicate with amplitude estimation. For a uniform input over N candidates and M marked ones, the success probability is a=M/N. Estimating that probability supplies an estimate of M without explicitly listing every solution.

Mechanism and mathematical treatment

The Grover angle obeys sin^2(theta)=M/N, so M=N sin^2(theta). The sensitivity is dM/dtheta=N sin(2theta). Error guarantees should distinguish additive error in M, relative error in M and confidence. These are not interchangeable near M=0.

Fully worked reference example

Let N=64 and M=16. Then a=1/4 and theta=pi/6. If theta is estimated as pi/6+delta, the first-order count error is approximately 64(sqrt(3)/2)delta. With delta=0.001 radians, that is about 0.0554. This local sensitivity estimate is not a standalone probabilistic guarantee.

Limitations and common misconceptions

An estimate of count does not supply the marked items themselves. Unknown solution number also affects the optimal number of Grover iterations, so counting can inform search but has its own query cost.

Scientific relationships

Marked-item fraction is an amplitude-estimation target.

Historical source context

Brassard, Hoyer and Tapp submitted Quantum Counting on 27 May 1998; the paper appeared in the 1998 ICALP proceedings. Later amplitude-estimation formulations broaden the framework.

Counting five marked labels among thirty-two

Consider a uniform superposition of N=32 labels and a predicate accepting M=5. The initial success amplitude obeys sin squared theta=5/32. With the usual two-reflection Grover convention, the two relevant eigenvalues are exp(plus or minus 2i theta). A phase-estimation register therefore samples neighborhoods of phi=theta/pi and 1-phi. Both branches encode the same count because sin squared (pi phi) is unchanged by phi becoming 1-phi.

Use a four-qubit phase register, giving sixteen phase labels j. If j=2 or j=14 is observed, the reconstructed count is 32 sin squared (pi/8)=16-8sqrt(2), approximately 4.686292. Rounding this value gives five. If j=3 or j=13 is observed instead, the reconstructed value is 32 sin squared (3pi/16)=16-8sqrt(2-sqrt(2)), approximately 9.877065. A one-step phase-label difference can therefore have a substantial counting effect at this resolution.

The probability distribution is obtained from the finite geometric sum. For one eigenphase phi, p(j|phi)=|sum from k=0 to 15 of exp[2pi i k(phi-j/16)]/16| squared. The uniform search state has equal weight on the two eigenvectors in the nondegenerate two-dimensional plane, so the counting distribution is the half-sum of p(j|phi) and p(j|1-phi). This formula, rather than a declaration that the nearest label always occurs, determines the probability that rounding succeeds.

An explicit accuracy condition for integer recovery

Let the angular estimation error be delta, so the estimated count is 32 sin squared (theta+delta). The first derivative of N sin squared theta is N sin(2theta)=2sqrt(M(N-M)). Here it is 6sqrt(15), approximately 23.237900. The second derivative has magnitude at most 2N, so Taylor's theorem gives the rigorous local-to-global bound |estimated M-M| at most 6sqrt(15)|delta|+32 delta squared.

For |delta| at most 0.01 radians, that bound is approximately 0.235579, below one-half. Under this accuracy event, rounding necessarily returns the correct integer. The statement is conditional on an angular-error event whose probability must be supplied by the phase-estimation analysis. It is not a guarantee obtained merely by choosing a register size. A more conservative bound uses the derivative maximum N and demands |delta|<1/(2N), which works without knowing the particular marked fraction.

Near M=0, a relative count error is undefined, while a small additive error remains meaningful. At M=N, every candidate is marked and the useful Grover plane degenerates. Those endpoints can be checked directly within the promised model. An algorithm that distinguishes zero from a small nonzero count needs a detection guarantee, not a relative-error formula evaluated at zero.

Comparing query and sampling budgets

A four-qubit phase-estimation ladder uses controlled Grover powers with total exponent 1+2+4+8=15 if powers are implemented by repeated iterations. Each iteration includes a predicate reflection and a reflection about the initial preparation. If the predicate is computed into a flag, its inverse cleanup belongs to that reflection's gate cost. The small phase register therefore does not imply that the complete counting computation uses only four substantial operations.

A classical reference method samples uniform labels and averages the predicate. With S independent draws, the unbiased estimate 32 times the sample mean has variance M(N-M)/S=135/S. At S=1,000 the standard deviation is approximately 0.367423 labels. This calculation does not establish a winner against the sixteen-point quantum estimator; the procedures have different output distributions, coherent depths, and confidence guarantees. It does show exactly what a statistical comparison must hold fixed.

If all thirty-two labels can be enumerated cheaply, direct counting is an inexpensive exact classical baseline. Quantum counting becomes interesting as a query-complexity construction when the domain is large and membership access is the specified input. A count estimate also does not identify the five accepted labels. Listing them requires additional search and output work, so an application demanding the entire solution set has a different resource target.

Sources

  • Gilles Brassard; Peter Hoyer; Alain Tapp · · Research paper · Publication status unspecified · arXiv · DOI 10.1007/BFb0055105
    Verification scope

    Recorded source check ·

    Counting and amplitude-access model inspected.

    Formal scientific or official reference-semantics anchor. No SDK execution, hardware run, universal performance claim, or independent external peer review asserted. Original finite examples and definitions are independent explanations.

  • Gilles Brassard; Peter Hoyer; Michele Mosca; Alain Tapp · · Research paper · Publication status unspecified · arXiv
    Verification scope

    Selected source text checked ·

    Theoretical oracle model; independent examples do not constitute end-to-end hardware demonstrations.