SWAP-Test State Overlap
Infer pure-state similarity from an ancilla while accounting for inconclusive outcomes.
Free theory articleInfer pure-state similarity from an ancilla while accounting for inconclusive outcomes.
Concept & interpretation
The SWAP test is a foundational quantum circuit used to estimate the overlap (inner product squared) between two unknown pure quantum states without fully characterizing them. It involves two input states, |ψa⟩ and |ψb⟩, and an ancilla qubit initialized to |0⟩. A controlled-SWAP (Fredkin) gate is applied, targeted on the two states and controlled by the ancilla (which is placed in a superposition).
Explore relative phases and orthogonality
Open the SWAP-Test State Overlap module to observe how relative angles impact the measurement outcome.
- Set First polar degrees to 90, Second polar degrees to 90, and Relative azimuth degrees to 90. The squared state overlap is 0.5 and the ancilla zero probability is 0.75.
- Change Relative azimuth degrees to 0. The vectors align identically, yielding an overlap of 1.0 and a definitive ancilla zero probability of 1.0. The test verifies they are the same state.
- Set First polar degrees to 0 and Second polar degrees to 180 (poles of the Bloch sphere). The states are orthogonal (|0⟩ and |1⟩), so the overlap is 0.0. The ancilla probability is 0.5, meaning the measurement yields random outcomes.
- Adjust Copies to observe how repeated measurements exponentially suppress the probability of an all-zero sequence when states are not identical.