// Phase estimation of p(3π/4), whose eigenvalue on |1⟩ is e^{2πi·3/8}, with // three counting qubits: `ctrl @ pow(2**j) @` on a gate the program defines, // and the inverse of its own QFT with `inv @`. 3/8 is three bits exactly, so // every shot reads 3: k[0] and k[1] are 1, k[2] is 0. OPENQASM 3.1; include "stdgates.inc"; gate u_phase a { p(3 * pi / 4) a; } gate qft3 a, b, c { h a; cp(pi / 2) b, a; cp(pi / 4) c, a; h b; cp(pi / 2) c, b; h c; swap a, c; } qubit[3] k; qubit t; bit[3] r; x t; h k; for uint j in [0:2] { ctrl @ pow(2 ** j) @ u_phase k[j], t; } inv @ qft3 k[2], k[1], k[0]; r = measure k;