Quantum Phase Estimation
An eigenvalue you cannot measure, written into a register of qubits as a phase — then read back out as a binary number by running the Fourier transform backwards.
Quantum Phase Estimation visualization
Top: one dial per counting qubit, turning by 2πφ·2ʲ as its controlled-U power runs. Bottom: what a measurement would give. Step through and notice the bottom panel does not move at all until the very last stage.
Stage 1 of 8: Prepare the eigenstate
The bottom qubit is put in |1⟩, the eigenstate of U = P(2πφ) with eigenvalue e^{2πiφ}. It stays in that state for the whole run — U never changes it, only the phase in front of it.
What you are manipulating
U here is the simplest operator with a phase to find: it multiplies |1⟩ by e2πiφ and leaves |0⟩ alone. The bottom qubit is prepared in that eigenstate and never changes again — U does nothing to it except put a number in front of it, and a number in front of a state is invisible to every measurement you can make on that state alone.
So the phase is moved somewhere it can be read. Each counting qubit controls a different power of U: qubit 0 applies it once, qubit 1 twice, qubit 2 four times. Drag the qubit count and step through the stages. Watch the dials fan out — and watch the probability panel below them stay perfectly flat until the inverse QFT runs.
Why the answer arrives in binary
Controlled-U2ʲ leaves qubit j holding the phase 2π·2jφ, wrapped into one turn. Wrapping is not a loss here, it is the mechanism: qubit 0 holds φ itself, which pins down the coarsest bit; qubit 4 holds 24φ, which for this φ has already gone 5 whole turns round and kept only what was left over — so a change in φ far too small to move qubit 0 moves that hand a long way. Coarse to fine, one qubit per binary place.
Together the register holds Σy e2πiφy|y⟩ — a phase ramp whose slope is 2tφ. That is precisely the state the quantum Fourier transform produces from |2tφ⟩, so running the transform backwards turns the ramp into that number. The QFT page shows the forward direction with every phase dial laid bare; this page is what feeds it.
What just happened
φ = 0.333333 is not a multiple of 2−5, so there is no outcome that is right. The best available answer, 0.01011 = 0.343750, comes up 68.4% of the time and the two outcomes straddling the true value take 85.5% between them. The error is 0.010417, below the 0.031250 the grid can resolve.
The floor under that number is a theorem, not a measurement: the nearest outcome is measured with probability at least 4/π² ≈ 40.5%, and the two nearest together at least 8/π² ≈ 81.1%, no matter what φ is or how many qubits you use. Drag φ across a grid point and watch a single spike split into two shoulders that still sum past that bound.
The most likely measurements
Exact probabilities from the closed form sin²(πε)/(4ᵗ·sin²(πε/2ᵗ)), which the test suite pins the simulator against. ε is how far 2ᵗφ sits from that outcome.
| Measured y | Binary | y / 2t | Error | Probability |
|---|---|---|---|---|
| 11 | 0.01011 | 0.343750 | 0.010417 | 68.4% |
| 10 | 0.01010 | 0.312500 | 0.020833 | 17.1% |
| 12 | 0.01100 | 0.375000 | 0.041667 | 4.3% |
| 9 | 0.01001 | 0.281250 | 0.052083 | 2.8% |
| 13 | 0.01101 | 0.406250 | 0.072917 | 1.4% |
| 8 | 0.01000 | 0.250000 | 0.083333 | 1.1% |
Precision and confidence are bought separately
Adding a counting qubit halves the spacing of the grid: t qubits resolve φ to 2−t, full stop. But being near the right answer most of the time and being near it reliably are different purchases, and the second one is surprisingly cheap.
t = n + ⌈log₂(2 + 1/2ε)⌉. At the 5 qubits set above, this run lands within 2−4 of φ 92.6% of the time.
The second term does not improve the answer at all — it only makes the good answer more likely, and it grows logarithmically in the confidence you demand. That asymmetry is why phase estimation is usable in practice: you pay linearly for the digits you need and almost nothing for certainty about them.
Where this sits in the arc
The quantum Fourier transform on its own computes nothing you can read — it turns a number into a phase ramp whose amplitudes are all the same size. Phase estimation is the missing half: it builds a ramp out of something you actually want to know, an eigenvalue, and then uses the inverse transform to convert it back into a number a measurement can return.
Shor’s algorithm is this page with one substitution. Take U to be multiplication by a modulo N. Its eigenvalues are e2πi·s/r, where r is the period you are hunting, so estimating the phase gives you s/r — and the continued-fraction step on Shor’s page is what pulls r out of that fraction. The counting register there is sized 2t ≥ N² for exactly the reason this page’s precision slider shows: without enough bits, two different periods produce estimates you cannot tell apart.
The same machine turns up wherever a physical quantity is an eigenvalue. Estimating molecular ground-state energies is phase estimation on the time-evolution operator e−iHt, which is why VQE exists at all: QPE needs far more coherent gates than today’s hardware can hold, so the variational method trades the guarantee for a circuit that fits.
What this simulation does not show
U is a single-qubit phase gate here, so controlled-U2ʲ is one gate no matter how large the exponent is. That is a genuine special case. For the U inside Shor’s algorithm, controlled-U2ʲ is modular exponentiation — a large arithmetic circuit that has to be compiled, and where nearly all the real cost of the algorithm lives. The structure of phase estimation is identical; the price of each stage is not.
Everything on this page is a real statevector on t + 1 qubits, transformed by an actual Hadamard-and-controlled-phase inverse QFT circuit, which is why t stops at 10. The probabilities in the table come from the closed-form distribution instead, and the test suite checks the two agree to nine decimal places — if they ever stop agreeing, one of them is wrong and the page should not be trusted until it is fixed.