Estimates φ in U|ψ⟩ = e^{2πiφ}|ψ⟩. Counting q0 is the LSB of the binary readout.
Prepare |ψ⟩ (here |1⟩, an eigenstate of T, S, or Z), Hadamard the counting register, apply controlled-U^{2^j} from counting wire j, then inverse QFT. The counting integer m satisfies m/2^t ≈ φ.
Default unitary is T: T|1⟩ = e^{iπ/4}|1⟩ = e^{2πi/8}|1⟩ so φ = 1/8. With t = 3 this is exactly 0.001₂. Controlled-U^{2^j} is CP [j, eigen] with angle 2·2^j·φ (π-multiples): 0.25, 0.5, 1.
How it works
-
1
Eigenstate
X 3 prepares |1⟩ on the eigen wire.
-
2
Counting superposition
H (0,1,2).
-
3
Kickback
CP from each counting qubit onto q3.
-
4
IQFT
Inverse QFT on q0-q2. Expect counting value 1, binary |001⟩ with q0 on the right.
X 3 H (0,1,2) CP [0,3] 0.25 CP [1,3] 0.5 CP [2,3] 1 SWAP [0,2] H 0 CP [0,1] -0.5 H 1 CP [0,2] -0.25 CP [1,2] -0.5 H 2
Function form: QPE(0.125)
State. Counting |001⟩ (decimal 1), eigenstate |1⟩ on q3. φ = 1/8 = 1/8.
P(counting = 1) = 1. Binary 001 with q0 = LSB. 1/2³ = 0.125.
| Basis | Amplitude | Probability |
|---|---|---|
|1001⟩ (q3 q2 q1 q0) |
1 |
Notes
- S gate: φ = 1/4. Z gate: φ = 1/2. Custom φ is a fraction in [0, 1).
- If φ is not a t-bit dyadic, the mass spreads over nearby integers (success ≥ 4/π² on the closest bin).
Change parameters
The write-up above is for the default circuit. Use this control to generate other variants and load them in the simulator.