Quantum Phase Estimation (QPE) estimates the eigenvalue phase of a unitary operator.
Given a unitary
QPE outputs
Step 1 — Prepare the eigenstate on
Step 2 — Create superposition on
Step 3 — Controlled powers of
Step 4 — Inverse QFT on the precision register:
The QFT transforms
With
Implements
Decomposition:
Inverse QFT circuit for the precision register:
- Cascade of
$CU_1(-\pi/2^{j-i})$ gates in reverse order - Followed by Hadamard on each qubit
- Prepare the eigenstate on system qubits (defaults to
$|0\rangle^{\otimes m}$ ) - Apply
$H^{\otimes n}$ on precision qubits for uniform superposition - For each precision qubit
$k$ : apply$U^{2^k}$ controlled by that qubit - Apply QFTdagger on precision qubits
- Measure the precision register
# Estimate the phase of the T gate (phase = π/8 ≈ 0.3927)
python examples/algorithms/qpe.py --n-precision 4 --unitary t
# Estimate Z-gate phase (eigenvalue = -1, so phase = 0.5)
python examples/algorithms/qpe.py --n-precision 4 --unitary z
# More precision qubits
python examples/algorithms/qpe.py --n-precision 6 --unitary t --shots 8192Expected output:
Quantum Phase Estimation
Precision qubits: 4
Phase precision: 1/16 = 0.0625
Unitary: t
Measurement results:
|0110⟩ prob= 94.2% phase=0.3750 ← most likely
|0101⟩ prob= 2.1% phase=0.3125
|0111⟩ prob= 1.8% phase=0.4375
Estimated phase: 0.3750
True phase: 0.3927
Absolute error: 0.0177
✓ QPE complete.
- Eigenstate input: QPE requires a known eigenstate. For non-diagonal unitaries, the output is a superposition of phases corresponding to the eigenstate decomposition.
-
Controlled unitaries: For diagonal
$U$ , controlled-$U$ is implemented as$CU_1$ gates encoding the phase angles. The cascade decomposition handles multi-qubit phase encoding. -
Binary phase encoding: QPE treats the precision register as a binary fraction
$\varphi = \sum_k b_k / 2^k$ . The estimated integer$m$ from measurement gives$\tilde{\varphi} = m / 2^n$ .
- HHL Algorithm: Use QPE as the core of the quantum linear systems solver
- Iterative QPE (IQPE): Reduce qubit count by measuring and re-using one qubit per iteration
- Quantum counting: Combine Grover search with QPE to count marked states
- Nielsen, M. A., & Chuang, I. L. (2010). Quantum Computation and Quantum Information. Cambridge University Press. Chapter 5.
- Cleve, R., Ekert, A., Macchiavello, C., & Mosca, M. (1998). "Quantum algorithms revisited." Proc. R. Soc. A. https://arxiv.org/abs/quant-ph/9708016