Category: transform | Difficulty: advanced | Qubits: 4 | Gates: 16 | Depth: 10
Quantum Phase Estimation (QPE) estimates the eigenphase φ of a unitary U given an eigenstate |ψ⟩. It is used in Shor's factoring, HHL, and quantum chemistry simulations. The circuit superimposes counting qubits, applies controlled-U^(2^k) for each, then performs an inverse QFT to extract the binary representation of φ. This circuit uses U=T (phase π/4), eigenstate |1⟩, so φ=1/8. Expected output: |001⟩ (binary 0.001 = 1/8 in big-endian).
|001⟩ in counting register (φ = 1/8 = 0.001 in binary)
The OpenQASM 2.0 circuit is in circuit.qasm.
OPENQASM 2.0;
include "qelib1.inc";
// QPE: estimate eigenphase of T gate (phi = 1/8)
// q[0..2]: 3 counting qubits, q[3]: target eigenstate |1>
qreg q[4];
creg c[3];
// Prepare eigenstate |1> of T gate
x q[3];
// Superpose counting qubits
h q[0]; h q[1]; h q[2];
// Controlled-T^(2^k): T^1 = R_z(pi/4), T^2 = S = R_z(pi/2), T^4 = Z = R_z(pi)
// Controlled-T^4 from q[0] (MSB): cu1(pi)
cu1(3.141592653589793) q[0],q[3];
// Controlled-T^2 from q[1]: cu1(pi/2)
cu1(1.5707963267948966) q[1],q[3];
// Controlled-T^1 from q[2] (LSB): cu1(pi/4)
cu1(0.7853981633974483) q[2],q[3];
// Inverse QFT on counting register
swap q[0],q[2];
h q[0];
cu1(-1.5707963267948966) q[1],q[0];
h q[1];
cu1(-0.7853981633974483) q[2],q[0];
cu1(-1.5707963267948966) q[2],q[1];
h q[2];
measure q[0] -> c[0];
measure q[1] -> c[1];
measure q[2] -> c[2];
qpe phase-estimation eigenvalue subroutine shor
- Kitaev, A.Y. (1995). Quantum measurements and the Abelian Stabilizer Problem. arXiv:quant-ph/9511026
MIT — part of the OpenQC Algorithm Catalog.