Quantum Counting and Amplitude Estimation

Quantum counting and amplitude estimation are the meeting point of the two great engines of quantum algorithms. Grover's search rotates a state toward the marked items of an unstructured set, but on its own it only finds a solution — it never says how many there are. The decisive observation is that the Grover iteration GG, inside the two-dimensional plane that carries all of the search dynamics, is nothing more than a rotation by a fixed angle 2θ2\theta, set entirely by the density of solutions through sin⁡2θ=M/N\sin^2\theta = M/N. Its eigenvalues are e±2iθe^{\pm 2i\theta}, and extracting that eigenphase is exactly what quantum phase estimation does — so counting becomes "measure how fast Grover spins," and you learn MM without ever isolating a marked item. Three consequences organize this article. First, the whole procedure is quantum phase estimation applied to GG: a register of tt ancillas controls the powers G2jG^{2^j}, an inverse quantum Fourier transform reads out 2θ/2π2\theta/2\pi, and M=Nsin⁡2θ^M = N\sin^2\hat\theta inverts the geometry. Second, the cost is Heisenberg-limited — angular precision Δθ∼π/T\Delta\theta \sim \pi/T after TT Grover calls, a quadratic improvement over the 1/S1/\sqrt{S} shot noise of SS classical samples. Third, Brassard, Høyer, Mosca and Tapp stripped away the search framing: replace the uniform superposition by an arbitrary state preparation A\mathcal{A} and the oracle by a marking predicate, and the same operator QQ estimates a general amplitude a=sin⁡2θa=\sin^2\theta — the abstraction that accelerates Monte Carlo integration, mean estimation and partition functions.

Key takeaways
  • Quantum counting estimates the number MM of marked items in a set of size NN by running quantum phase estimation on the Grover iteration GG.
  • GG acts as a planar rotation by 2θ2\theta with sin⁡2θ=M/N\sin^2\theta=M/N; its eigenvalues e±2iθe^{\pm 2i\theta} carry the count, so reading the eigenphase gives θ\theta and hence M=Nsin⁡2θM=N\sin^2\theta.
  • Resolving θ\theta to tt bits costs T=2t−1T=2^t-1 Grover iterations and gives count error ∼2M(N−M) π/2t\sim 2\sqrt{M(N-M)}\,\pi/2^t — a quadratic speedup over classical sampling.
  • Amplitude estimation generalizes counting: for any preparation A\mathcal{A} with good amplitude a=sin⁡2θa=\sin^2\theta, phase estimation on Q=AS0A†SχQ=\mathcal{A}S_0\mathcal{A}^\dagger S_\chi returns aa to precision ϵ\epsilon in O(1/ϵ)O(1/\epsilon) queries versus O(1/ϵ2)O(1/\epsilon^2) classically — the quadratic Monte Carlo speedup.
  • Counting also solves the search decision problem (M=0M=0 vs M≥1M\ge 1) in O(N)O(\sqrt{N}) queries.
  • Key idea: the Grover iteration GG is a planar rotation by 2θ2\theta with sin⁡2θ=M/N\sin^2\theta=M/N, so its eigenvalues e±2iθe^{\pm 2i\theta} carry the count; running quantum phase estimation on GG reads θ\theta to mm bits using O(2m)O(2^m) queries, yielding MM (or a general amplitude a=sin⁡2θa=\sin^2\theta) with quadratically better precision-per-query than classical sampling.

Where this lives today

Amplitude estimation is now the standard subroutine wherever a quantum computer must estimate a number rather than find one. In quantitative finance it drives algorithms for option pricing and risk measures: a derivative's payoff is encoded as a good-subspace amplitude and estimation returns its expected value with a quadratic reduction in samples — the line of work opened by Woerner and Egger at IBM. Because the textbook construction needs a full controlled-G2jG^{2^j} ladder and an inverse QFT — deep circuits noisy hardware cannot yet run — the active frontier is QFT-free estimation: maximum-likelihood and iterative amplitude estimation run many shallow Grover circuits of depth kk and fit the marked-outcome probability to sin⁡2((2k+1)θ)\sin^2((2k+1)\theta), keeping the O(1/ϵ)O(1/\epsilon) scaling while removing the ancilla register. These variants have been demonstrated on superconducting and trapped-ion processors, and resource estimates for chemistry and finance treat amplitude estimation as the dominant cost.

The physical picture

For search, the NN-dimensional computational space collapses into a single two-dimensional plane. Let ∣α⟩|\alpha\rangle be the equal superposition of all unmarked states and ∣β⟩|\beta\rangle that of all marked states. The uniform superposition ∣ψ⟩=H⊗n∣0⟩|\psi\rangle=H^{\otimes n}|0\rangle lives in this plane, tilted an angle θ\theta off the unmarked axis with sin⁡θ=M/N\sin\theta=\sqrt{M/N}. Grover's operator is the product of two reflections — the oracle about ∣α⟩|\alpha\rangle, the diffusion operator about ∣ψ⟩|\psi\rangle — and two reflections whose mirror lines are separated by θ\theta compose to a rotation by 2θ2\theta. So the whole search is one number: the angle θ\theta.

Figure
In the plane spanned by the unmarked axis α and the marked axis β, the uniform state ψ sits at angle θ with sin²θ = M/N. Grover's operator G rotates by 2θ; for N = 4, M = 1 a single step (θ = 30°, 2θ = 60°) lands exactly on β. Because G is a rotation its eigenvalues lie on the unit circle at e^±2iθ.
One Grover step = a rotation by 2θ in the marked/unmarked plane α unmarked β marked ψ Gψ θ = 30° 2θ = 60° sin²θ = M/N = 1/4 e^(+2iθ) e^(−2iθ) 2θ eigenphases on the unit circle

A rotation is the one operator whose eigenphase you can read directly: its eigenvalues e±2iθe^{\pm 2i\theta} lie on the unit circle, and phase estimation is precisely the instrument that measures an eigenphase. So "count the solutions" becomes "measure the rotation rate of Grover." The quadratic advantage is the coherence-versus-sampling story of Heisenberg-limited metrology: a classical estimator draws SS independent samples and beats down variance as 1/S1/\sqrt{S}, but coherently accumulating phase over TT applications of GG sharpens the angle as 1/T1/T — and no quantum algorithm can do better than this Heisenberg limit.

Figure
Additive error ε against the number of oracle calls, on log–log axes. Coherent phase accumulation gives the quantum estimate ε ∝ 1/T (Heisenberg scaling, slope −1); classical sampling gives ε ∝ 1/√S (shot noise, slope −½). Reaching a target ε costs T ∝ 1/ε quantum queries but S ∝ 1/ε² classical samples, and at 10⁴ calls the gap is already about 31×.
The punchline: quantum precision falls as 1/T, classical only as 1/√S quantum ε ∝ 1/T classical ε ∝ 1/√S quantum advantage 10¹ 10⁰ 10⁻¹ 10⁻² 10¹ 10² 10³ 10⁴ number of oracle calls T (or samples S) additive error ε

Amplitude estimation removes the search framing entirely. Any algorithm A\mathcal{A} preparing a "good" component with amplitude aa defines an angle θ\theta by a=sin⁡2θa=\sin^2\theta, and the operator QQ rotates by 2θ2\theta in the good/bad plane exactly as GG did. Estimating aa is then estimating an expectation value — a probability, a mean, an integral — which is why the same argument that counts database entries delivers the quadratic Monte Carlo speedup.

The core equations

The single number that governs everything is the angle θ\theta: defined by the fraction of marked items, equal to half the Grover rotation angle, and returned as the eigenphase by phase estimation. Every other quantity is computed from it.

sin⁡2θ=MN,0≤θ≤π2(1)\sin^2\theta = \frac{M}{N}, \qquad 0\le\theta\le\frac{\pi}{2} \qquad (1)

where: θ\theta — half the Grover rotation angle, the eigenphase to be estimated; MM — number of marked solutions; NN — size of the search space (database dimension). Reading: the marked fraction M/NM/N, not MM itself, sets the geometry. In the invariant plane the start state is a simple tilt of angle θ\theta off the unmarked axis — the only state the algorithm ever tracks.

∣ψ⟩=cos⁡θ ∣α⟩+sin⁡θ ∣β⟩(2)|\psi\rangle = \cos\theta\,|\alpha\rangle + \sin\theta\,|\beta\rangle \qquad (2)

where: ∣α⟩|\alpha\rangle — normalized equal superposition of all unmarked states; ∣β⟩|\beta\rangle — normalized equal superposition of all marked states; ∣ψ⟩=H⊗n∣0⟩|\psi\rangle=H^{\otimes n}|0\rangle — uniform superposition over all N=2nN=2^n states. Reading: cos⁡2θ\cos^2\theta and sin⁡2θ\sin^2\theta are the fractions of unmarked and marked weight. The Grover iteration is the workhorse unitary — the oracle followed by the diffusion reflection.

G=(2∣ψ⟩⟨ψ∣−I) O(3)G = (2|\psi\rangle\langle\psi| - I)\,O \qquad (3)

where: OO — oracle reflecting marked states, O∣x⟩=(−1)f(x)∣x⟩O|x\rangle=(-1)^{f(x)}|x\rangle; 2∣ψ⟩⟨ψ∣−I2|\psi\rangle\langle\psi|-I — reflection about the mean (diffusion operator); GG — the Grover operator, a rotation by 2θ2\theta in the {∣α⟩,∣β⟩}\{|\alpha\rangle,|\beta\rangle\} plane. Reading: two reflections make a rotation — the whole reason phase estimation applies. As a matrix in the plane, GG is a textbook rotation and its eigenvalues follow at once.

G=(cos⁡2θ−sin⁡2θsin⁡2θcos⁡2θ),G∣ψ±⟩=e±2iθ∣ψ±⟩(4)G = \begin{pmatrix} \cos 2\theta & -\sin 2\theta \\ \sin 2\theta & \cos 2\theta \end{pmatrix}, \qquad G|\psi_\pm\rangle = e^{\pm 2i\theta}|\psi_\pm\rangle \qquad (4)

where: ∣ψ±⟩=12(∣α⟩∓i∣β⟩)|\psi_\pm\rangle=\tfrac{1}{\sqrt2}(|\alpha\rangle\mp i|\beta\rangle) — the complex eigenvectors of GG; e±2iθe^{\pm 2i\theta} — the eigenvalues, whose phase encodes the count. Reading: the conjugate pair sits symmetrically on the unit circle, so either branch gives the same sin⁡2θ\sin^2\theta. Phase estimation with tt control qubits returns an integer yy; scaling recovers the angle, and inverting the geometry recovers the count.

θ^=π y2t,M^=Nsin⁡2θ^(5)\hat\theta = \frac{\pi\, y}{2^{t}}, \qquad \hat M = N\sin^2\hat\theta \qquad (5)

where: yy — integer measured on the tt-qubit control register after the inverse QFT; tt — number of control (ancilla) qubits, which sets the precision; θ^\hat\theta — the estimate of θ\theta. Reading: the register outputs 2θ/2π2\theta/2\pi scaled to 2t2^t, so yy tracks the angle, and MM appears only after the nonlinear map Nsin⁡2N\sin^2. Propagating the one-bit angular resolution through that nonlinear map gives the count error.

∣θ^−θ∣≤π2t  ⇒  ∣M^−M∣≤(2MN+π2N2t+1)π2t(6)|\hat\theta-\theta|\le \frac{\pi}{2^{t}} \;\Rightarrow\; |\hat M-M| \le \left(\sqrt{2M N} + \frac{\pi^2 N}{2^{t+1}}\right)\frac{\pi}{2^{t}} \qquad (6)

where: M^=Nsin⁡2θ^\hat M=N\sin^2\hat\theta — estimated count; ∣M^−M∣|\hat M-M| — additive error. Reading: the error scales as MN\sqrt{MN}, so few solutions are cheap to bound and a half-filled set is hardest. Amplitude estimation replaces the oracle-and-diffusion pair by two general reflections built from an arbitrary preparation A\mathcal{A}.

Q=A S0 A† Sχ,a=sin⁡2θ(7)Q = \mathcal{A}\, S_0\, \mathcal{A}^{\dagger}\, S_\chi, \qquad a = \sin^2\theta \qquad (7)

where: A\mathcal{A} — state preparation, A∣0⟩=1−a ∣ψbad⟩+a ∣ψgood⟩\mathcal{A}|0\rangle=\sqrt{1-a}\,|\psi_{\text{bad}}\rangle+\sqrt{a}\,|\psi_{\text{good}}\rangle; Sχ=I−2ΠgoodS_\chi=I-2\Pi_{\text{good}} — phase flip on good states; S0S_0 — phase flip on ∣0⟩|0\rangle; aa — the good-subspace probability. Reading: QQ is again a rotation by 2θ2\theta, so amplitude estimation is counting with M/NM/N promoted to a general aa. The payoff is the query-count comparison — the entire reason the field exists.

Tquantum=Θ ⁣(1ϵ)vs.Tclassical=Θ ⁣(1ϵ2)(8)T_{\text{quantum}} = \Theta\!\left(\frac{1}{\epsilon}\right) \quad\text{vs.}\quad T_{\text{classical}} = \Theta\!\left(\frac{1}{\epsilon^2}\right) \qquad (8)

where: ϵ\epsilon — target additive precision on aa (or on M/NM/N). Reading: to halve the error, a quantum estimator doubles its circuit depth while a classical estimator quadruples its samples — the gap widens without bound as ϵ→0\epsilon\to 0.

Derivation AThe Grover operator as a planar rotation with eigenphase 2θ

The goal is to show that the Grover iteration GG leaves invariant the two-dimensional plane spanned by the marked and unmarked superpositions, that inside that plane it is a rigid rotation by 2θ2\theta, and that its eigenvalues are therefore e±2iθe^{\pm 2i\theta} with sin⁡2θ=M/N\sin^2\theta=M/N. This is the single fact that makes counting possible: it converts an opaque search unitary into a rotation whose one free parameter, the eigenphase, is exactly what phase estimation extracts.

Step 1. Define ∣β⟩|\beta\rangle as the normalized equal superposition of the MM marked states and ∣α⟩|\alpha\rangle as that of the N−MN-M unmarked states. Then ∣ψ⟩=H⊗n∣0⟩=(N−M)/N ∣α⟩+M/N ∣β⟩=cos⁡θ ∣α⟩+sin⁡θ ∣β⟩|\psi\rangle=H^{\otimes n}|0\rangle=\sqrt{(N-M)/N}\,|\alpha\rangle+\sqrt{M/N}\,|\beta\rangle=\cos\theta\,|\alpha\rangle+\sin\theta\,|\beta\rangle. Why: this is the only place MM enters — it fixes the tilt angle θ\theta, and thereafter the algorithm refers only to θ\theta.

Step 2. Identify the reflections. The oracle O=I−2∣β⟩⟨β∣O=I-2|\beta\rangle\langle\beta| reflects about the ∣α⟩|\alpha\rangle axis; the diffusion operator 2∣ψ⟩⟨ψ∣−I2|\psi\rangle\langle\psi|-I reflects about the ∣ψ⟩|\psi\rangle axis at angle θ\theta. Both map the plane to itself, so it is invariant under GG. Why: a two-dimensional invariant subspace lets an NN-dimensional problem be analyzed with 2×22\times 2 matrices.

Step 3. Compose them. A reflection at angle 00 followed by one at angle θ\theta is a rotation by 2θ2\theta, giving the matrix in equation (4); GG sends the tilt θ↦3θ↦5θ↦⋯\theta\mapsto 3\theta\mapsto 5\theta\mapsto\cdots, so after kk steps the state is at angle (2k+1)θ(2k+1)\theta. Why: the marked-state probability after kk steps is sin⁡2((2k+1)θ)\sin^2((2k+1)\theta), the fitting form the near-term variants exploit.

Step 4. Diagonalize. The characteristic polynomial det⁡(G−λI)=λ2−2λcos⁡2θ+1=0\det(G-\lambda I)=\lambda^2-2\lambda\cos2\theta+1=0 has roots λ=e±2iθ\lambda=e^{\pm 2i\theta} with eigenvectors ∣ψ±⟩=12(∣α⟩∓i∣β⟩)|\psi_\pm\rangle=\tfrac{1}{\sqrt2}(|\alpha\rangle\mp i|\beta\rangle), and the start state decomposes as ∣ψ⟩=−i2(eiθ∣ψ+⟩−e−iθ∣ψ−⟩)|\psi\rangle=\tfrac{-i}{\sqrt2}\big(e^{i\theta}|\psi_+\rangle-e^{-i\theta}|\psi_-\rangle\big) with equal weight on both branches. Why: equal weight means phase estimation on ∣ψ⟩|\psi\rangle returns the eigenphase 2θ2\theta with the standard success probability — no special eigenstate preparation is needed.

Go deeper · Derivation B · 1 minFrom angular resolution to the count-error bound and query cost
Derivation BFrom angular resolution to the count-error bound and query cost

The goal is to turn "phase estimation resolves θ\theta to one part in 2t2^t" into two concrete numbers: how many Grover queries the algorithm spends, and how large the resulting uncertainty in the count MM is. The subtlety is that phase estimation is linear in the angle but the count depends on sin⁡2θ\sin^2\theta, so the angular error must be pushed through a nonlinear Jacobian that amplifies it most severely for a half-filled database.

Step 1. Count the queries. Phase estimation applies controlled-G2jG^{2^j} for j=0,…,t−1j=0,\dots,t-1, each block costing 2j2^j oracle calls, so the total is T=∑j=0t−12j=2t−1T=\sum_{j=0}^{t-1}2^j=2^t-1; the QPE guarantee gives Pr⁡[ ∣θ^−θ∣≤π/2t ]≥8/π2≈0.81\Pr[\,|\hat\theta-\theta|\le\pi/2^t\,]\ge 8/\pi^2\approx 0.81. Why: the budget is dominated by the highest power G2t−1G^{2^{t-1}}, tying precision and cost as Δθ∼π/T\Delta\theta\sim\pi/T — the Heisenberg-limited scaling.

Step 2. Differentiate the count. From M=Nsin⁡2θM=N\sin^2\theta the sensitivity is dM/dθ=Nsin⁡2θ=2M(N−M)\mathrm{d}M/\mathrm{d}\theta=N\sin2\theta=2\sqrt{M(N-M)}, so ΔM≈2M(N−M) Δθ\Delta M\approx 2\sqrt{M(N-M)}\,\Delta\theta. Why: this Jacobian decides how expensive counting is — it vanishes as M→0M\to 0 (easy to certify emptiness) and peaks at M=N/2M=N/2.

Step 3. Make the bound exact. Using sin⁡2θ^−sin⁡2θ=sin⁡(θ^+θ)sin⁡(θ^−θ)\sin^2\hat\theta-\sin^2\theta=\sin(\hat\theta+\theta)\sin(\hat\theta-\theta) with ∣sin⁡(θ^−θ)∣≤∣θ^−θ∣|\sin(\hat\theta-\theta)|\le|\hat\theta-\theta| and ∣sin⁡(θ^+θ)∣≤sin⁡2θ+∣θ^−θ∣|\sin(\hat\theta+\theta)|\le\sin2\theta+|\hat\theta-\theta|, then ∣θ^−θ∣≤π/2t|\hat\theta-\theta|\le\pi/2^t and sin⁡2θ≤2M/N\sin2\theta\le 2\sqrt{M/N} yield equation (6). Why: this is the rigorous Nielsen and Chuang bound; the leading term matches the Jacobian estimate, the second is the O(Δθ2)O(\Delta\theta^2) correction.

Step 4. Compare with classical sampling. Drawing SS items gives a binomial estimator with standard error M(N−M)/S\sqrt{M(N-M)/S}; matching the quantum error ∼2M(N−M)/T\sim 2\sqrt{M(N-M)}/T requires S∼T2S\sim T^2 samples. Why: the quadratic speedup made quantitative — TT coherent queries reach what costs T2T^2 incoherent samples.

Go deeper · Derivation C · 1 minAmplitude estimation from amplitude amplification
Derivation CAmplitude estimation from amplitude amplification

The goal is to lift quantum counting off the uniform-superposition-plus-oracle scaffold and show it works for any state preparation A\mathcal{A} and any marking predicate. The claim is that Q=AS0A†SχQ=\mathcal{A}S_0\mathcal{A}^\dagger S_\chi is once again a rotation by 2θ2\theta, with a=sin⁡2θa=\sin^2\theta the probability of a good outcome, so the identical phase-estimation machinery now returns a general amplitude — a probability, an expectation value, or an integral — with the same Heisenberg-limited precision.

Step 1. Prepare and split. Write A∣0⟩=cos⁡θ ∣Ψbad⟩+sin⁡θ ∣Ψgood⟩\mathcal{A}|0\rangle=\cos\theta\,|\Psi_{\text{bad}}\rangle+\sin\theta\,|\Psi_{\text{good}}\rangle, where ∣Ψgood⟩|\Psi_{\text{good}}\rangle is the normalized projection onto the good subspace and sin⁡2θ=a\sin^2\theta=a is the probability a direct measurement of A∣0⟩\mathcal{A}|0\rangle returns a good outcome. Why: this reproduces the counting geometry with M/NM/N replaced by an arbitrary amplitude aa — no new mathematics, only new labels.

Step 2. Build the reflections. Sχ=I−2ΠgoodS_\chi=I-2\Pi_{\text{good}} reflects about ∣Ψbad⟩|\Psi_{\text{bad}}\rangle, and AS0A†=2 A∣0⟩⟨0∣A†−I\mathcal{A}S_0\mathcal{A}^\dagger=2\,\mathcal{A}|0\rangle\langle 0|\mathcal{A}^\dagger-I reflects about A∣0⟩\mathcal{A}|0\rangle; their axes are separated by θ\theta, so QQ rotates by 2θ2\theta with eigenvalues e±2iθe^{\pm 2i\theta}. Why: S0S_0 generalizes Grover's diffusion — conjugating a reflection about ∣0⟩|0\rangle by A\mathcal{A} reflects about the prepared state, so the search-specific oracle is no longer needed.

Step 3. Read out and bound. Phase estimation on QQ returns yy, giving θ^=πy/2t\hat\theta=\pi y/2^t and a^=sin⁡2θ^\hat a=\sin^2\hat\theta. The Brassard–Høyer–Mosca–Tapp guarantee is that, with probability at least 8/π28/\pi^2, ∣a^−a∣≤2πa(1−a)/T+π2/T2|\hat a-a|\le 2\pi\sqrt{a(1-a)}/T+\pi^2/T^2 for T=2tT=2^t applications of QQ. Why: the leading term is O(a(1−a)/T)O(\sqrt{a(1-a)}/T), so reaching precision ϵ\epsilon costs T=O(1/ϵ)T=O(1/\epsilon) queries — quadratically fewer than O(1/ϵ2)O(1/\epsilon^2) classical samples, and Ω(1/ϵ)\Omega(1/\epsilon) is optimal.

Limiting cases

Behaviour of the counting estimate across regimes of marked fraction and precision tt:

CaseResultMeaning
No solutionsM=0⇒θ=0, M^≈0M=0 \Rightarrow \theta=0,\ \hat M\approx 0Counting doubles as the search decision problem: an angle consistent with θ=0\theta=0 certifies emptiness (with high probability) in O(N)O(\sqrt N) queries.
Few solutionsM≪N⇒θ≈M/N, ΔM≈2MN ΔθM\ll N \Rightarrow \theta\approx\sqrt{M/N},\ \Delta M\approx 2\sqrt{MN}\,\Delta\thetaResolving MM to constant relative accuracy needs Δθ≲1/MN\Delta\theta\lesssim 1/\sqrt{MN}, i.e. T∼N/MT\sim\sqrt{N/M} queries.
Half-filledM=N/2⇒θ=π/4, dM/dθ=NM=N/2 \Rightarrow \theta=\pi/4,\ \mathrm{d}M/\mathrm{d}\theta=NMaximal sensitivity: the Jacobian Nsin⁡2θN\sin2\theta peaks here, so the count is hardest to pin down at balance.
Precision scalingΔθ∼π/2t, T=2t−1\Delta\theta\sim\pi/2^t,\ T=2^t-1Heisenberg-limited: precision improves linearly in TT, versus Δθ∼1/T\Delta\theta\sim 1/\sqrt T classically.

Worked examples

1 · Counting solutions in a database (fully worked)

A verifier marks solutions in a set of N=210=1024N=2^{10}=1024 items; the true count is M=20M=20, unknown to us. Run quantum counting with t=8t=8 control qubits and find the eigenphase, register value, estimate M^\hat M, error bound, and query cost.

Step 1. Compute the geometry. sin⁡2θ=20/1024=0.019531\sin^2\theta=20/1024=0.019531, so sin⁡θ=0.13975\sin\theta=0.13975 and θ=arcsin⁡(0.13975)=0.14021 rad\theta=\arcsin(0.13975)=\mathbf{0.14021\ \text{rad}}; the Grover rotation is 2θ=0.280432\theta=0.28043 and the eigenphase as a fraction of a turn is φ=2θ/2π=0.044631\varphi=2\theta/2\pi=\mathbf{0.044631}.

Step 2. Predict the register outcome. With t=8t=8 the register holds 256256 values, so the ideal readout is y⋆=φ⋅256=11.43y^\star=\varphi\cdot 256=11.43, rounding to y=11\mathbf{y=11}. Then θ^=πy/2t=π⋅11/256=0.13499 rad\hat\theta=\pi y/2^t=\pi\cdot 11/256=\mathbf{0.13499\ \text{rad}}, one bit below the true angle (∣θ^−θ∣=0.0052<π/256=0.0123|\hat\theta-\theta|=0.0052<\pi/256=0.0123).

Step 3. Recover the count. M^=Nsin⁡2θ^=1024×(0.13458)2=18.55\hat M=N\sin^2\hat\theta=1024\times(0.13458)^2=\mathbf{18.55}, rounding to 1919 solutions against a true 2020 — an error of ∣M^−M∣=1.45|\hat M-M|=\mathbf{1.45}.

Step 4. Check the bound and count queries. Equation (6) gives ∣M^−M∣≤(2⋅20⋅1024+π2⋅1024/512) π/256=(202.4+19.7)×0.01227=2.73|\hat M-M|\le(\sqrt{2\cdot 20\cdot 1024}+\pi^2\cdot 1024/512)\,\pi/256=(202.4+19.7)\times 0.01227=\mathbf{2.73}, and indeed 1.45≤2.731.45\le 2.73. The oracle cost is T=2t−1=255T=2^t-1=\mathbf{255} Grover iterations, while a classical sampler reaching the same ±2.7\pm 2.7 uncertainty needs S≈M(N−M)/ϵ2≈2700S\approx M(N-M)/\epsilon^2\approx\mathbf{2700} samples — and the ratio grows as 1/ϵ1/\epsilon at finer precision. M^=18.55\hat M=18.55 (true 20), error 1.45 within bound 2.73, at 255 queries versus ~2700 classical samples.

2 · Amplitude estimation for a Monte Carlo mean

A preparation A\mathcal{A} encodes the expectation of a bounded random variable as a good-subspace probability a=E[f]=0.3a=\mathbb{E}[f]=0.3. Estimate aa with t=8t=8 control qubits (T=256T=256 applications of QQ), and compare with classical Monte Carlo.

Step 1. Apply the guarantee. With a(1−a)=0.21=0.4583\sqrt{a(1-a)}=\sqrt{0.21}=0.4583, Derivation 3 gives ∣a^−a∣≤2π⋅0.4583/256+π2/2562=0.01125+0.00015=0.0114|\hat a-a|\le 2\pi\cdot 0.4583/256+\pi^2/256^2=0.01125+0.00015=\mathbf{0.0114} — the 256256 coherent applications pin the mean to about ±1.1×10−2\pm 1.1\times 10^{-2}.

Step 2. Compare classically. Monte Carlo with SS samples has standard error a(1−a)/S\sqrt{a(1-a)/S}, so matching ϵ=0.0114\epsilon=0.0114 requires S=a(1−a)/ϵ2≈1600S=a(1-a)/\epsilon^2\approx\mathbf{1600} samples — about 6×6\times the 256256 quantum queries.

Step 3. Push the precision. Demand ϵ=10−3\epsilon=10^{-3} instead: the quantum cost is T≈2πa(1−a)/ϵ≈2900T\approx 2\pi\sqrt{a(1-a)}/\epsilon\approx\mathbf{2900}, while the classical cost is S≈a(1−a)/ϵ2≈2.1×105S\approx a(1-a)/\epsilon^2\approx\mathbf{2.1\times 10^5} samples. The advantage has grown from 6×6\times to about 70×70\times — the signature of O(1/ϵ)O(1/\epsilon) versus O(1/ϵ2)O(1/\epsilon^2). 256 queries give ϵ≈0.011\epsilon\approx 0.011 (vs 1600 samples); tightening to 10−310^{-3} costs ~2900 queries vs ~210000 samples.

3 · Exact search as a special angle

Take N=4N=4, M=1M=1 (the case drawn in the first figure). Here sin⁡2θ=1/4\sin^2\theta=1/4, so θ=30∘\theta=30^\circ. After one Grover iteration the state sits at (2⋅1+1)θ=3θ=90∘(2\cdot 1+1)\theta=3\theta=90^\circ, exactly on the marked axis ∣β⟩|\beta\rangle — a single query finds the item with certainty. Counting reads the same angle back through the eigenphase 2θ=60∘2\theta=60^\circ: M^=4sin⁡230∘=4⋅14=1\hat M=4\sin^2 30^\circ=4\cdot\tfrac14=\mathbf{1}. The count lives entirely in the rotation angle.

Physics of the portrait

Quantum counting and amplitude estimation are the work of a small group of theorists who saw that Grover's search and Shor's phase estimation were two faces of one geometric idea — and then generalized it into a tool that now anchors quantum speedups far beyond search.

Origins · 1 minGilles Brassard and how this was discovered
GB
Gilles Brassard
b. 1955, Montréal · quantum algorithms and quantum information

Gilles Brassard is a Canadian computer scientist at the Université de Montréal and one of the founders of quantum information science, best known for co-inventing quantum key distribution — the BB84 protocol with Charles Bennett in 1984. Within quantum algorithms, Brassard and his collaborators recognized that Grover's 1996 search was a rotation in a two-dimensional plane, and that the rotation could be measured rather than merely iterated. With Peter Høyer and Alain Tapp he framed quantum counting as phase estimation of the Grover operator (1998), and with Høyer, Michele Mosca and Tapp he unified the ideas into quantum amplitude amplification and estimation (2000). That abstraction — replace the oracle and uniform superposition by an arbitrary preparation A\mathcal{A} and a predicate χ\chi — carried the quadratic advantage out of database search and into Monte Carlo integration, mean estimation and partition-function approximation. He has since received the Wolf Prize in Physics (2018) and the Breakthrough Prize in Fundamental Physics (2023).

History
1996
— Grover's quantum search rotates a state toward marked items in O(√N) queries
1998
— Brassard, Høyer and Tapp cast counting as phase estimation of the Grover operator
2000
— Brassard, Høyer, Mosca and Tapp unify amplitude amplification and estimation
2015
— Montanaro speeds up Monte Carlo estimation using amplitude estimation
2020
— QFT-free maximum-likelihood and iterative amplitude estimation target NISQ hardware

Going further

Texts. Nielsen and Chuang, Quantum Computation and Quantum Information, §6.3 (quantum counting) · Brassard, Høyer, Mosca, Tapp, "Quantum Amplitude Amplification and Estimation," Contemporary Mathematics 305 (2002) · Preskill, Lecture Notes on Quantum Computation, Ch. 6 · Kitaev, Shen, Vyalyi, Classical and Quantum Computation, §13 · Wilde, Quantum Information Theory, chapter on phase estimation · Mermin, Quantum Computer Science, Ch. 4 · Montanaro, "Quantum speedup of Monte Carlo methods," Proc. R. Soc. A (2015).

Provenance. A verifier should recompute: (1) the Grover matrix G=(cos⁡2θ−sin⁡2θsin⁡2θcos⁡2θ)G=\big(\begin{smallmatrix}\cos2\theta&-\sin2\theta\\\sin2\theta&\cos2\theta\end{smallmatrix}\big), its characteristic equation λ2−2λcos⁡2θ+1=0\lambda^2-2\lambda\cos2\theta+1=0, and eigenvalues e±2iθe^{\pm2i\theta} with sin⁡2θ=M/N\sin^2\theta=M/N (N&C §6.1–6.3); (2) the geometric sum ∑j=0t−12j=2t−1\sum_{j=0}^{t-1}2^j=2^t-1 and resolution Δθ∼π/2t\Delta\theta\sim\pi/2^t (standard QPE analysis); (3) the count-error bound ∣M^−M∣≤(2MN+π2N/2t+1)π/2t|\hat M-M|\le(\sqrt{2MN}+\pi^2N/2^{t+1})\pi/2^t via sin⁡2a−sin⁡2b=sin⁡(a+b)sin⁡(a−b)\sin^2 a-\sin^2 b=\sin(a+b)\sin(a-b) (N&C §6.3); (4) the amplitude-estimation operator Q=AS0A†SχQ=\mathcal{A}S_0\mathcal{A}^\dagger S_\chi and bound ∣a^−a∣≤2πa(1−a)/T+π2/T2|\hat a-a|\le 2\pi\sqrt{a(1-a)}/T+\pi^2/T^2 with success ≥8/π2\ge 8/\pi^2 (BHMT 2002, Thm 12). Worked-example arithmetic (N=1024,M=20,t=8⇒M^=18.55N=1024,M=20,t=8\Rightarrow\hat M=18.55, bound 2.732.73, T=255T=255; a=0.3,T=256⇒ϵ≈0.011a=0.3,T=256\Rightarrow\epsilon\approx 0.011) was checked numerically. The constant 8/π2≈0.818/\pi^2\approx 0.81 and the Θ(1/ϵ)\Theta(1/\epsilon)-vs-Θ(1/ϵ2)\Theta(1/\epsilon^2) scaling are standard; no fabricated numbers appear.

Builds on: Quantum Phase Estimation · Grover's Search Algorithm · Amplitude Amplification · Quantum Fourier Transform Leads to: Shor's Factoring Algorithm · Order Finding and Period Finding

Ask the tutor: Ask me to walk through the N=1024, M=20N=1024,\,M=20 counting run bit by bit, or to show how amplitude estimation turns a Monte Carlo mean into a rotation angle.

Why does the algorithm output an angle instead of the count directly?

Because phase estimation is fundamentally an eigenphase meter, and the eigenphase of the Grover operator is 2θ2\theta, not MM. The count enters only through sin⁡2θ=M/N\sin^2\theta=M/N, which the hardware cannot unwind — it hands you θ^\hat\theta and you compute M^=Nsin⁡2θ^\hat M=N\sin^2\hat\theta in classical post-processing. This matters because the conversion is nonlinear: the Jacobian dM/dθ=2M(N−M)\mathrm{d}M/\mathrm{d}\theta=2\sqrt{M(N-M)} amplifies the angular error, most severely for a half-filled set. The angular precision the register achieves is not the count precision you keep — you always propagate through the sine.

What exactly is the source of the quadratic speedup?

Coherent phase accumulation. A classical estimator draws independent samples, and independent noise averages down only as 1/S1/\sqrt{S} — shot noise. Quantum counting instead applies the rotation GG a total of TT times coherently, so the accumulated phase is 2Tθ2T\theta and the angular resolution sharpens as 1/T1/T. Reaching a target error ϵ\epsilon therefore costs T∼1/ϵT\sim 1/\epsilon quantum queries but S∼1/ϵ2S\sim 1/\epsilon^2 classical samples, so S∼T2S\sim T^2. It is the same physics as Heisenberg-limited metrology: coherently reusing a probe beats the standard quantum limit by a square root.

How does amplitude estimation generalize quantum counting?

Replace the two ingredients specific to search: the uniform superposition H⊗n∣0⟩H^{\otimes n}|0\rangle becomes an arbitrary preparation A\mathcal{A}, and the oracle becomes a predicate χ\chi marking a "good" subspace. The operator Q=AS0A†SχQ=\mathcal{A}S_0\mathcal{A}^\dagger S_\chi is then still a rotation by 2θ2\theta, but now a=sin⁡2θa=\sin^2\theta is a general amplitude — the probability that measuring A∣0⟩\mathcal{A}|0\rangle yields a good outcome. Since that probability can encode an expectation value E[f]\mathbb{E}[f], estimating aa estimates a mean or an integral, which is why the same construction accelerates Monte Carlo far outside database search.

Both eigenvalues e^{±2iθ} are present — doesn't that create ambiguity?

The measured phase comes back as θ\theta or as 2π−θ2\pi-\theta (equivalently −θ-\theta modulo 2π2\pi), because the start state has equal weight on both eigenvectors ∣ψ±⟩|\psi_\pm\rangle. But both branches give the same sin⁡2θ\sin^2\theta, so the recovered count or amplitude is unambiguous — you restrict θ\theta to [0,π/2][0,\pi/2] and read off sin⁡2θ\sin^2\theta. The two-branch structure is not harmless everywhere, though: you must include both eigenvalues when proving the 8/π28/\pi^2 success-probability bound, and when the true θ\theta is near 00 or π/2\pi/2 the two branches sit close together and the analysis needs care to avoid double-counting the resolution.

Is quantum counting the same as solving the search decision problem?

It is strictly more, and contains the decision problem as its coarsest output. The decision problem asks only whether any solution exists (M≥1M\ge 1) or not. Quantum counting answers that with a measured angle: an estimate consistent with θ=0\theta=0 certifies emptiness with high probability in O(N)O(\sqrt N) queries, the same budget as one Grover search. But counting keeps going and returns an estimate of MM (to constant relative error in O(N/M)O(\sqrt{N/M}) queries) that the bare decision problem does not need. Knowing MM then lets Grover search choose its optimal iteration count ⌊π/(4θ)⌋\lfloor\pi/(4\theta)\rfloor and avoid overshooting the marked subspace.

Why can't the register just be made huge to get any precision cheaply?

Because precision and cost are the same resource. Adding a control qubit doubles 2t2^t and halves Δθ\Delta\theta, but the largest controlled power G2t−1G^{2^{t-1}} also doubles, so the query count T=2t−1T=2^t-1 doubles with it. There is no free precision: every extra bit of angle costs a factor of two more Grover iterations, exactly the Δθ∼π/T\Delta\theta\sim\pi/T Heisenberg scaling. This is why the near-term variants matter — they keep the O(1/ϵ)O(1/\epsilon) scaling but spread the queries across many shallow circuits instead of one deep controlled-power ladder, trading depth for repetitions on hardware that cannot sustain long coherent evolutions.

Before this

Where this leads