Algorithm guide · transform
Quantum Phase Estimation
Estimate the eigenphase φ of a unitary U to t bits of precision.
Circuit size: t = 1..6 counting qubits + 1 eigenstate qubit
Eigenvectors · Phase in turns versus radians · Inverse QFT
Review quantum fundamentals →Notation used in this lesson
- |ψ⟩ and ⟨ψ|
- A state vector (ket) and its conjugate transpose (bra). ⟨a|b⟩ is their inner product.
- α, β and i
- α and β are complex amplitudes; i²=−1. A probability is the squared magnitude |α|².
- XOR, · and ⊗
- XOR adds bits modulo two. In s·x, multiply corresponding bits and XOR them. ⊗ combines registers or operations on different wires.
- U†, Σ and Tr
- U† is the adjoint (inverse for a unitary). Σ sums terms. Tr is the matrix trace, the sum of diagonal entries.
- Probability, shots and angles
- Ideal probabilities describe the model; measured shot frequencies fluctuate. Angles inside trigonometric expressions are in radians unless explicitly labeled turns.
1. The problem
For an eigenstate |u⟩ satisfying U|u⟩=exp(2πiφ)|u⟩, estimate φ in [0,1). The eigenvalue is a complex phase; it is not generally an ordinary real energy.
2. How it works
Controlled powers of U let counting wires accumulate different multiples of the same phase. The inverse QFT recombines those phase clocks into a binary estimate.
Prepare an eigenstate
Choose a compatible U and one of its labeled eigenvectors.
Prepare counting wires
Apply H to each of t counting bits.
Controlled powers
Counting bit j controls U^(2ʲ).
Inverse QFT and read
Measure counting integer y and estimate φ≈y/2ᵗ.
3. The mathematics, one idea at a time
The target stays in its eigenstate while its eigenvalue becomes a relative phase on the control.
When φ is exactly a grid point, all terms reinforce for one y and cancel for the others. Otherwise the outcomes spread over the circular phase grid.
Work this through by hand
4. Smallest ruler: resolve phase 1/2
One counting qubit plus one target: the supported minimum t=1.
Choose Phase P(θ), Exact grid, k=1 and the eigenvector labeled |1⟩. With t=1 this sets φ=1/2 and θ=π. The internal option key “minus” labels this |1⟩ choice; use the displayed vector.
| Stage | Calculation or state | What it means |
|---|---|---|
| Eigenvalue | P(π)|1⟩=−|1⟩ | −1=exp(2πi·1/2). |
| Phase kickback | Counting |+⟩ becomes |−⟩ | The target remains |1⟩. |
| Inverse one-bit QFT | H|−⟩=|1⟩ | Measured y=1 gives φ=y/2=1/2. |
Expected outcomes for this example
These are ideal predictions for the stated configuration, not a result already measured by your browser. Rows describing alternative modes or combined events are labeled explicitly.
| Outcome or event | Ideal probability | Interpretation |
|---|---|---|
| 1 | 100% ideal | Counting integer one; decoded phase one-half. |
5. Load the worked example in Composer
The worked example can use smaller or simpler inputs than the gallery defaults. The button below loads the exact circuit used in this lesson.
- Counting qubits (t)
- 1
- Unitary operator (U)
- Phase P(θ)
- Phase input mode
- Exact grid
- Exact phase index (k)
- 1
- Phase φ (0 ≤ φ < 1)
- 0.5
- Eigen vector
- |1⟩
- Save any current circuit you want to keep, then open the worked example. Loading it does not execute a paid hardware job.
- Trace the preparation, main operations and measurements against the worked table. Check the gate editor for controls, targets and angles.
- Start with an ideal noiseless simulator compatible with the circuit. Mid-circuit measurement, reset and feed-forward require support from the chosen backend.
- Inspect the live preview. For a recorded experiment, open Execute, set the available backend options and shots, and Run. Sign in when prompted to retain it in My Jobs.
- Read the output as described below before changing one setting and repeating. The guide describes the original example; edits can change the answer.
6. Read the output correctly
Read the counting register, not the eigenstate target.
Exact grid controls the phase through k/2ᵗ. Continuous mode uses φ directly. With a non-eigenstate input, different eigenphases can appear with weights set by its eigenstate components.
A bit label is a register value; its bar height is a probability or count. For S shots and observed count k, the sampled frequency is k/S. A typical sampling scale for probability p is √[p(1−p)/S]; this is not a strict error bound. Finite samples do not have to match the ideal percentages exactly.
7. Common mistakes & limits
- φ=1/2 turn means θ=π radians, not 0.5 radians.
- More shots cannot make a one-bit grid resolve every possible phase exactly.
8. Check your understanding
For t=2 and y=11₂, what phase estimate is reported?
Reveal the reasoning
y=3, so φ≈3/4. The corresponding eigenvalue is exp(3πi/2)=−i.
9. Further study
The lesson’s register mappings, supported inputs and loadable example follow Quantket’s implemented circuit. A reference may use different wire names, bit order or resource conventions.
Gallery reference: defaults, definitions & implementation notes
Inputs & default settings
These are the gallery defaults. The worked example above may override them. Configure the card to change the inputs before loading its editable circuit.
- Counting qubits (t)
- Default: 3 · Whole number from 1 to 6.
Precision of the estimate: the register resolves φ to 1/2^t. The eigenstate lives on one extra qubit, so the circuit uses t + 1 in total.
- Unitary operator (U)
- Default: phase · Choices for the current settings: Pauli-X ([[0, 1], [1, 0]] — one controlled-X on q0.); Pauli-Y ([[0, −i], [i, 0]] — one controlled-Y on q0.); Pauli-Z (diag(1, −1) — one controlled-Z on q0.); Pauli-(X+Y) ((X+Y)/√2 = T·X·T† — TDG, CX, T on q0.); Phase P(θ) (diag(1, e^(iθ)) — a controlled-P on every counting qubit.).
The unitary whose eigenphase is being estimated. QPE needs controlled-U^(2^j) for each counting qubit j — cheap here because every Pauli squares to the identity, and exact for the phase gate because its powers are just doubled angles.
- Phase input mode
- Default: exact · Choices for the current settings: Exact grid (Choose k so φ = k/2^t lands on one counting bin.); Continuous (Dial any φ and observe leakage between circular bins.). Shown only for the relevant configuration.
Exact grid predicts one bitstring. Continuous mode deliberately exposes non-representable phases and spectral leakage.
- Exact phase index (k)
- Default: 2 · Whole number k from 0 to 7; the phase is k/2^3. Shown only for the relevant configuration.
φ = k/2^t. Increasing t scales k to preserve φ; decreasing t snaps to the nearest point on the circular phase grid.
- Phase φ (0 ≤ φ < 1)
- Default: 0.25 · A fraction of a full turn, 0 ≤ φ < 1 (so φ = 0.5 means π radians). Shown only for the relevant configuration.
A φ that is not a multiple of 1/2^t cannot land on a single bin — the register spreads over the two nearest, which is what QPE looks like in practice.
- Eigen vector
- Default: minus · Choices for the current settings: |0⟩ (P(θ)|0⟩ = |0⟩ → φ = 0); |1⟩ (P(θ)|1⟩ = e^(iθ)|1⟩ → φ = θ/2π).
QPE only returns a phase if the eigenstate wire is prepared in an eigenvector of U. Each operator has two, and the circuit prepares the one you pick from |0⟩.
Implementation notes
This example uses the gallery's default configuration. Check Run details for the settings used in your execution.
P(θ) has eigenphase θ/2π on |1⟩ and 0 on |0⟩. The counting register resolves it exactly when θ/2π is a multiple of 1/2^t — otherwise the outcome spreads over neighbouring bins.
Default example: predictions & circuit facts
These values describe the unedited default setup. They are predictions and circuit properties, not measured results from your saved execution.
- Resolution
- 1/8
- Eigenphase φ
- 1/4
- Reads
- 010
Read your saved result
Check the submitted circuit, measured register and execution settings in Run details. Exact results give computed probabilities; sampled results show frequencies from the recorded shots. Edited circuits and noise can change the expected outcome. The algorithm label records the circuit's origin; it does not certify an edited circuit or a measured result.