|q⟩ Bad Qubits

intermediate · Programming · Quantum Phase Estimation

The Phase Estimation Problem

Every unitary operator UU has eigenvalues that sit on the complex unit circle. That is not an accident — it is a direct consequence of unitarity. If UU is unitary and ψ|\psi\rangle is one of its eigenvectors, the eigenvalue equation reads

Uψ=e2πiφψ,φ[0,1).U|\psi\rangle = e^{2\pi i \varphi}|\psi\rangle, \qquad \varphi \in [0,1).

The real number φ\varphi is called the phase (or eigenphase) of UU for that eigenvector. Estimating φ\varphi from a quantum circuit — to as many bits of precision as needed — is the Quantum Phase Estimation (QPE) problem.

Why the phase matters

The phase φ\varphi encodes information that is otherwise extremely hard to extract classically. Several landmark quantum algorithms reduce to phase estimation:

In each case the key computational step is: given black-box access to controlled-UU, and given an eigenstate ψ|\psi\rangle, estimate φ\varphi to nn bits.

Setting up the problem precisely

Before writing any circuit it helps to fix what we are given and what we want:

Given:

  1. A unitary UU acting on mm qubits, accessible as a gate (or a family of controlled-U2kU^{2^k} gates).
  2. An eigenstate ψ|\psi\rangle of UU, or a state that has significant overlap with at least one eigenstate.
  3. A desired precision of nn bits.

Goal: Produce a classical nn-bit string φ~\tilde{\varphi} such that φ~/2nφ2n|\tilde{\varphi}/2^n - \varphi| \le 2^{-n} with probability at least 1ϵ1 - \epsilon for some small ϵ\epsilon.

The remarkable fact is that a quantum circuit can accomplish this using only nn ancilla ("counting") qubits and O(n)O(n) calls to controlled powers of UU. A classical algorithm that queries a unitary black box cannot extract phases at all — it can only learn action on specific states.

The circuit idea at a glance

The QPE circuit has three conceptual stages.

Stage 1 — Superpose the counting register. Apply HnH^{\otimes n} to nn ancilla qubits initialised to 0|0\rangle. This creates the uniform superposition

12n/2k=02n1k.\frac{1}{2^{n/2}} \sum_{k=0}^{2^n - 1} |k\rangle.

Stage 2 — Kick back the phase. Use each ancilla qubit jj to control U2jU^{2^j}. Because ψ|\psi\rangle is an eigenstate, the controlled unitary does not entangle the two registers in amplitude — instead it imprints a phase factor e2πiφ2je^{2\pi i \varphi \cdot 2^j} onto the 1|1\rangle component of ancilla qubit jj. After all nn controlled powers, the counting register holds

12n/2k=02n1e2πiφkk.\frac{1}{2^{n/2}} \sum_{k=0}^{2^n - 1} e^{2\pi i \varphi k} |k\rangle.

This is precisely the Quantum Fourier Transform of the computational basis state 2nφ|2^n \varphi\rangle (when φ\varphi is exactly representable in nn bits).

Stage 3 — Invert the QFT. Apply the inverse QFT to the counting register. The interference pattern collapses onto the state 2nφ|2^n \varphi\rangle, so a computational-basis measurement gives the nn-bit binary expansion of φ\varphi deterministically (or near-deterministically when φ\varphi is not exactly representable).

The coming lessons build each stage in code. The present lesson's job is to make the goal clear: read the eigenphase φ\varphi of a unitary out of the interference pattern left by phase kickback, undone by the inverse QFT.

A worked example with numbers

Suppose U=SU = S (the phase gate, S1=i1=e2πi1/41S|1\rangle = i|1\rangle = e^{2\pi i \cdot 1/4}|1\rangle) and we want the phase of its eigenstate 1|1\rangle. The true eigenphase is φ=1/4\varphi = 1/4.

With n=2n = 2 ancilla qubits the counting register after stage 2 holds

12(00+e2πi1/401+e2πi2/410+e2πi3/411).\frac{1}{2}\bigl(|00\rangle + e^{2\pi i \cdot 1/4}|01\rangle + e^{2\pi i \cdot 2/4}|10\rangle + e^{2\pi i \cdot 3/4}|11\rangle\bigr).

The inverse QFT of this four-element superposition is exactly 01|01\rangle (binary for 11, which encodes φ=1/4=1/22\varphi = 1/4 = 1/2^2). Measurement gives 01 with certainty, and we read off φ=0.012=1/4\varphi = 0.01_2 = 1/4. The precision is exactly two bits, as promised.

If we had used only n=1n = 1 ancilla qubit, the φ=1/4\varphi = 1/4 state would fall halfway between the two representable values (00 and 1/21/2), yielding each with probability 1/21/2 — a useful reminder that precision is controlled entirely by how many ancilla qubits you allocate.

Summary

The Quantum Phase Estimation problem asks: given UU and an eigenstate ψ|\psi\rangle, estimate the eigenphase φ\varphi such that Uψ=e2πiφψU|\psi\rangle = e^{2\pi i\varphi}|\psi\rangle. The answer is a circuit that combines Hadamard superposition, phase kickback through controlled-UU powers, and the inverse QFT. Each additional bit of precision requires one more ancilla qubit and one more application of UU. In the next lessons you will implement each component, culminating in a complete QPE circuit.

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