|q⟩ Bad Qubits

intermediate · Programming · Quantum Phase Estimation

Success Probability

When the phase φ\varphi is exactly representable in nn bits — meaning 2nφ2^n \varphi is an integer — the inverse QFT collapses the counting register onto the single correct state and measurement succeeds with probability 1. Real-world phases are rarely so cooperative. This lesson analyses what happens when φ\varphi falls between two consecutive nn-bit grid points.

The general amplitude formula

Write the true phase as φ\varphi. After phase kickback and before the inverse QFT, the counting register holds

12n∑k=02n−1e2πikφ∣k⟩.\frac{1}{2^n} \sum_{k=0}^{2^n - 1} e^{2\pi i k \varphi} |k\rangle.

Let bb be any candidate integer in {0,1,…,2n−1}\{0, 1, \ldots, 2^n - 1\}. The inverse QFT maps this state to one whose amplitude on ∣b⟩|b\rangle is

αb=12n∑k=02n−1e2πik(φ−b/2n).\alpha_b = \frac{1}{2^n} \sum_{k=0}^{2^n - 1} e^{2\pi i k(\varphi - b/2^n)}.

Setting δ=φ−b/2n\delta = \varphi - b/2^n (the mismatch between φ\varphi and the grid point b/2nb/2^n), the geometric sum evaluates to

αb=12n⋅1−e2πi⋅2nδ1−e2πiδ(δ≠0).\alpha_b = \frac{1}{2^n} \cdot \frac{1 - e^{2\pi i \cdot 2^n \delta}}{1 - e^{2\pi i \delta}} \qquad (\delta \ne 0).

The measurement probability is ∣αb∣2|\alpha_b|^2. Using ∣1−eiθ∣=2∣sin⁡(θ/2)∣|1 - e^{i\theta}| = 2|\sin(\theta/2)|:

P(b)=∣sin⁡(π⋅2nδ)2nsin⁡(πδ)∣2.P(b) = \left|\frac{\sin(\pi \cdot 2^n \delta)}{2^n \sin(\pi \delta)}\right|^2.

The best estimate

The best estimate is the integer mm such that ∣m/2n−φ∣|m/2^n - \varphi| is smallest, i.e. ∣δ∣≤1/2n+1|\delta| \le 1/2^{n+1}. For that estimate the mismatch satisfies ∣δ∣≤1/(2⋅2n)|\delta| \le 1/(2 \cdot 2^n), and it can be shown that

P(m)≥4π2≈0.405.P(m) \ge \frac{4}{\pi^2} \approx 0.405.

This bound is tight: it is achieved in the worst case ∣δ∣=1/(2⋅2n)|\delta| = 1/(2 \cdot 2^n) and follows from the inequality sin⁡θ≤θ\sin\theta \le \theta (for θ≥0\theta \ge 0) combined with the bound sin⁡θ≥2θ/π\sin\theta \ge 2\theta/\pi for θ∈[0,π/2]\theta \in [0,\pi/2]. Concretely,

P(m)=∣sin⁡(π⋅2nδ)2nsin⁡(πδ)∣2≥∣sin⁡(π⋅2nδ)2n⋅π∣δ∣∣2.P(m) = \left|\frac{\sin(\pi \cdot 2^n \delta)}{2^n \sin(\pi \delta)}\right|^2 \ge \left|\frac{\sin(\pi \cdot 2^n \delta)}{2^n \cdot \pi |\delta|}\right|^2.

At ∣δ∣=1/(2⋅2n)|\delta| = 1/(2 \cdot 2^n) the numerator is ∣sin⁡(π/2)∣=1|\sin(\pi/2)| = 1 and the denominator is π/2\pi/2, giving (2/π)2=4/π2(2/\pi)^2 = 4/\pi^2.

Amplifying the success probability

Several strategies push the success probability above 4/π24/\pi^2:

  1. Use more counting qubits. Each additional qubit doubles the grid resolution, making a worst-case tie less likely and increasing the typical probability.
  2. Repeat and take the median. Running QPE O(log⁡(1/δ))O(\log(1/\delta)) times and taking the median estimate reduces the failure probability to δ\delta exponentially fast.
  3. Phase amplification. Quantum amplitude amplification can be used to boost the success probability of any QPE run from 4/π24/\pi^2 to near 1 with a modest circuit overhead.

Numerical check

For the TT gate, φ=1/8\varphi = 1/8. With n=3n = 3 counting qubits, 23φ=12^3 \varphi = 1 is exactly an integer, so P=1P = 1 and QPE is deterministic. To see the non-trivial bound you need a phase like φ=1/3\varphi = 1/3, where no power of 2 makes 2nφ2^n \varphi an integer. For n=3n = 3 and φ=1/3\varphi = 1/3, the best estimate is m=3m = 3 (since 3/8=0.3753/8 = 0.375 is closest to 1/3≈0.3331/3 \approx 0.333), giving ∣δ∣=1/24|\delta| = 1/24, and the exact probability is

P(3)=∣sin⁡(π/3)8sin⁡(π/24)∣2≈0.688,P(3) = \left|\frac{\sin(\pi/3)}{8 \sin(\pi/24)}\right|^2 \approx 0.688,

comfortably above 4/π2≈0.4054/\pi^2 \approx 0.405 as the bound guarantees.

Try it

QPE's worst-case success probability for the best estimate is 4/π24/\pi^2. Return that value as a number.

Run your code to see the quantum state.

Sign in on the full site to ask questions and join the discussion.