swap test

The swap test measures how alike two quantum states are without learning anything about what either one is, so it's a comparison that keeps both secrets.

standard mathematics · standard mathematics, cited outward

In plain terms

Two devices each hand you a quantum state, and you want to know whether they agree. Measuring either state disturbs it and reveals only a little about it, and comparing the two lists of amplitudes directly isn't an operation nature offers.

The swap test threads one extra qubit, called an ancilla, through both states. Put the ancilla into a superposition of its two readings, and in the branch where it reads one swap the two states while in the other branch you leave them alone, then close the superposition so the two branches interfere, and read the ancilla. If the two states are identical, the swap changed nothing, and the ancilla reads zero every time, and if the states are orthogonal, meaning perfectly distinguishable, the ancilla is a fair coin. In between, the bias of the coin measures the overlap of the two states, the standard gauge of their resemblance, which runs from zero for perfectly distinguishable states to one for identical ones.

Repeat as often as you like and the overlap is estimated to any accuracy, while neither state is ever identified. It's the standard likeness-meter of quantum information.

In CSD

The swap test is the witness that opens the corpus's ancilla-interferometry family, the algorithms that read a quantity off the interference of a single helper qubit, beside the oracle family of Deutsch-Jozsa, Bernstein-Vazirani and Simon. The probability that the ancilla reads zero is proved to be exactly one half plus half the squared overlap of the two states, with the identical-state and orthogonal-state readings as corollaries.

The standing disclaimer applies, as the algorithms consume the programme's unitary- evolution pillar and don't support the foundations.

Mathematically

H on the ancilla, controlled swap, H again, on |0> tensor psi tensor phi, and the ancilla-zero marginal is (1/4) times the squared norm of psi tensor phi + phi tensor psi, so the cross term <psi tensor phi, phi tensor psi> = |<psi, phi>|^2 closes it, giving P(0) = (1 + |<psi, phi>|^2)/2 exactly (swap_test_prob).

P(0) = 1 iff the states coincide up to phase, P(0) = 1/2 iff they're orthogonal, and the estimator is quadratic in the overlap, which is why it reveals magnitude and not phase.

Related entries

On the site
TN4 covers the mixed states whose overlap this test estimates
New to this?
explainquantum is a beginners' course in quantum mechanics, which starts from scratch and needs no maths
Background
Overview

Source links are pinned to a commit, so they do not drift. The anchors above are checked mechanically against the Lean tree on every build. The mathematics is not, and cannot be: that is a human responsibility and it rests with the author.

Part of Constraint-Surface Dynamics · Formalised in csd-lean4.

Privacy policy