Near-grid quantum phase estimation (source code)

= Near-grid quantum phase estimation
{title2=$P(n)=\sin^2(N\epsilon/2)/[N^2\sin^2(\epsilon/2)]$}

For register size $N=2^t$ and <eigenphase> $\phi=2\pi n/N+\epsilon$, the amplitude of decoded label $m$ is $N^{-1}\sum_{k=0}^{N-1}e^{ik(\phi-2\pi m/N)}$. The <finite geometric series> gives $P(n)=\sin^2(N\epsilon/2)/[N^2\sin^2(\epsilon/2)]$. If $N|\epsilon|\ll1$, this is $1-(N^2-1)\epsilon^2/12+O(N^4\epsilon^4)$. Thus the nearest exactly representable phase is returned with <probability> near one, not with certainty unless the offset vanishes.

// Target: quantum-error-correction.bigb