QUANTUM / ALGORITHM LAB
Quantum Phase Estimation
Explore how a quantum phase becomes a measurable binary estimate.
| Outcome | Phase | Ideal | Mixed | Shots |
|---|
What the experiment means
The input is an eigenstate of U: applying U multiplies it by exp(2πiφ). Controlled powers of U imprint that phase on the counting register. The inverse quantum Fourier transform converts the relative phases into a distribution over integers y, giving the estimate y / 2ⁿ.
For φ = 1/8 and three counting qubits, the ideal output is 001 with probability 1. Between exactly representable phases, nearby outcomes share probability. This simulation assumes a perfect eigenstate and exact controlled operations.
Uniform mixing combines the ideal distribution with a uniform distribution. It is an illustrative noise model, not a device-specific hardware prediction.
Kitaev: Quantum measurements and the Abelian Stabilizer Problem
AUTHORED STUDY COMPANION / 3.3
Move an eigenphase onto an ancilla
Prerequisites. Tensor products, controlled gates, eigenvectors and the Hadamard gate.
If U|u⟩=e^(2πiφ)|u⟩, applying controlled-U to |+⟩|u⟩ gives (|0⟩+e^(2πiφ)|1⟩)|u⟩/√2. The target remains in its eigenstate while the control acquires a relative phase. That phase is global only within the target branch; it is relative between the two control branches and can therefore affect interference.
The companion explicitly constructs the two-qubit controlled matrix for U=diag(1,e^(2πiφ)), with the ancilla listed first and target |1⟩. A final Hadamard on the ancilla gives P(0)=cos²(πφ). Measuring the control directly in Z before that Hadamard would always give one half and miss the relative phase.
The eigenstate assumption matters. A superposed target can correlate the control with different eigenphases. QPE uses a larger control register and powers of U to resolve that information rather than inferring a unique phase from a single probability.
| Element | Model | Interpretation |
|---|---|---|
| Prepare | |+⟩⊗|1⟩ | Control branches are coherent |
| Controlled U | Phase on the control-1 branch | Relative phase encodes φ |
| Interfere | Hadamard then measure | P(0)=cos²(πφ) |
Predict, run, compare
At φ=1/8, the ancilla probability after H is cos²(π/8)≈0.853553. The target remains |1⟩ with probability one.
Download executable notebooks and source Inspect source ↗
Open kickback.ipynb in the package. Run cells in order, compare with the reference, then change the stated input. Restart the kernel to reset.
Computed reference result — local CPU fixture
{
"ancilla_zero_probability": 0.8535533905932735,
"expected": 0.8535533905932737,
"target_one_probability": 0.9999999999999998
}This is the recorded result of the included code under the package environment. It is not a live service or device measurement.
Extend the experiment
Calculate φ=0, 1/4 and 1/2 by hand. Explain why one ancilla probability cannot uniquely identify every phase on the unit circle.
Check your reasoning: Why can the kicked-back phase be observed?
- It is a relative phase between ancilla branches — Correct. Interference compares those coherent branches.
- Every global phase is measurable — A common global phase has no observable effect.
- The target transmits a classical message — The unitary acts on the joint system; this is not a messaging protocol.
This is an explained self-check, not a certification of mastery.
Claim-specific sources
- IBM Quantum Learning — Fundamentals of Quantum Algorithms
- Preskill — Quantum Computation lecture notes
Reviewed 2026-10-02: this worked example and its explicit assumptions. Source links and notebook results do not establish production or hardware validation.
AUTHORED STUDY COMPANION / 3.3
Verify a quantum Fourier transform as a unitary
Prerequisites. Complex exponentials, orthogonality and matrix conjugate transpose.
For N=2ⁿ, the chosen forward convention is F[y,x]=exp(2πixy/N)/√N. The inverse is F†, with the opposite sign. The transform maps each basis vector to a uniform-magnitude superposition with a particular phase pattern. Measuring a transformed basis state therefore yields uniform probabilities even though its phases distinguish it from other transformed states.
The notebook constructs the full matrix for up to eight qubits and checks F†F≈I. It transforms |1⟩, then applies the inverse and verifies recovery of |1⟩. This dense classical implementation scales quadratically in N; it is a reference calculation rather than an efficient quantum circuit implementation.
Circuit diagrams can use reversed wire order and different bit significance. A successful round trip alone will not detect a consistently reversed convention, so write down the basis order and test individual phase entries as well. QFT becomes useful inside interference algorithms; measuring its amplitudes does not return a full classical Fourier spectrum in one shot.
| Element | Model | Interpretation |
|---|---|---|
| Forward convention | exp(+2πixy/N)/√N | State the sign |
| Inverse | Conjugate transpose | Cancels the transform |
| Measurement | |amplitude|² | Does not expose all phases |
Predict, run, compare
With three qubits N=8, each probability after F|1⟩ is 1/8. Inverting must return the original state with residual below 10⁻¹².
Download executable notebooks and source Inspect source ↗
Open qft.ipynb in the package. Run cells in order, compare with the reference, then change the stated input. Restart the kernel to reset.
Computed reference result — local CPU fixture
{
"probabilities": [
0.12499999999999997,
0.12499999999999997,
0.12499999999999997,
0.12499999999999997,
0.12499999999999997,
0.12499999999999997,
0.12499999999999997,
0.12499999999999997
],
"unitary_residual": 2.670559279784228e-15,
"roundtrip_residual": 4.587548306807408e-16
}This is the recorded result of the included code under the package environment. It is not a live service or device measurement.
Extend the experiment
Compute one row inner product analytically as a geometric sum. Then compare F and F† on a nontrivial superposition, specifying basis order.
Check your reasoning: Why is F† the inverse?
- Because every entry is real — Most Fourier entries are complex.
- Because the normalized columns are orthonormal — Correct. Column orthonormality gives F†F=I.
- Because measurement reverses F — Measurement generally destroys the state information needed to invert.
This is an explained self-check, not a certification of mastery.
Claim-specific sources
- IBM Quantum Learning — Fundamentals of Quantum Algorithms
- Preskill — Quantum Computation lecture notes
Reviewed 2026-10-02: this worked example and its explicit assumptions. Source links and notebook results do not establish production or hardware validation.
AUTHORED STUDY COMPANION / 3.3
Measure phase error on a circle
Prerequisites. Phase kickback, the inverse QFT and probability-weighted error.
After ideal kickback, control amplitude k is exp(2πiφk)/√N. Applying the inverse DFT gives the QPE output amplitudes. The notebook calculates that matrix-vector product independently of the sine-quotient formula in the existing browser lab. Exact grid phases yield one ideal output bin; off-grid phases distribute probability across several bins.
Phase is periodic. Near φ=0.99, a reported phase of 0 is only 0.01 away around the circle, although ordinary subtraction gives −0.99. Circular error wraps the difference into [−1/2,1/2). The notebook reports both linear and circular RMSE, each weighted by the exact probability distribution. The browser retains its existing linear sample statistic and adds the circular sample statistic.
Exact probability-weighted RMSE and finite-shot sample RMSE are different quantities. Seed, shot count, bit order and any mixture parameter belong in the exported result. A uniform probability mixture is a teaching approximation, not calibrated device noise. The simulator does not implement controlled powers of a supplied Hamiltonian or demonstrate hardware advantage.
| Element | Model | Interpretation |
|---|---|---|
| Resolution | 1/2ⁿ | Grid spacing, not guaranteed error |
| Linear error | y/N−φ | Treats endpoints as far apart |
| Circular error | wrap(y/N−φ) | Respects periodic phase |
Predict, run, compare
For φ=1/8 and n=3, bin 001 has probability one. For φ=0.99, compare linear and circular RMSE; the circular result should be smaller.
Download executable notebooks and source Inspect source ↗
Open qpe.ipynb in the package. Run cells in order, compare with the reference, then change the stated input. Restart the kernel to reset.
Computed reference result — local CPU fixture
{
"probabilities": [
1.9526876500268063e-33,
0.9999999999999996,
2.5813597747667042e-33,
2.9143774022401695e-32,
2.340127311695949e-33,
6.538566841615407e-33,
5.3125723309817e-32,
6.625482972669266e-32
],
"dominant": 1,
"linear_rmse": 2.4875013541742143e-16,
"circular_rmse": 1.2436954683275526e-16,
"normalization": 0.9999999999999996
}This is the recorded result of the included code under the package environment. It is not a live service or device measurement.
Extend the experiment
Predict the distribution as n increases for a fixed off-grid phase. Compare exact RMSE with several finite-shot runs from the existing browser lab.
Check your reasoning: The distance from phase 0.99 to 0 around the circle is:
- 0.99 — That is the linear distance across a coordinate cut.
- 0.01 — Correct. The shortest periodic separation crosses the endpoint.
- Exactly zero — The phases are close but distinct.
This is an explained self-check, not a certification of mastery.
Claim-specific sources
- IBM Quantum Learning — Fundamentals of Quantum Algorithms
- Preskill — Quantum Computation lecture notes
Reviewed 2026-10-02: this worked example and its explicit assumptions. Source links and notebook results do not establish production or hardware validation.
Problem, implementation and evidence
Linear phase error can be misleading near the zero/one boundary.
The existing probability model now reports circular sample RMSE alongside its retained linear statistic; a notebook independently computes ideal probabilities by inverse DFT.
What the evidence establishes
Classical ideal-state simulation and toy uniform-mixture model; no controlled hardware unitary or calibrated device noise.
Reproduce or extend
Compare exact-grid, off-grid and wrap-boundary phases, then distinguish exact distributions from finite-shot samples.
Open the related experiment or review surface →