Swap test
Technique for comparing quantum states / From Wikipedia, the free encyclopedia
The swap test is a procedure in quantum computation that is used to check how much two quantum states differ, appearing first in the work of Barenco et al.[1] and later rediscovered by Harry Buhrman, Richard Cleve, John Watrous, and Ronald de Wolf.[2] It appears commonly in quantum machine learning, and is a circuit used for proofs-of-concept in implementations of quantum computers.[3][4]
Formally, the swap test takes two input states and and outputs a Bernoulli random variable that is 1 with probability (where the expressions here use bra–ket notation). This allows one to, for example, estimate the squared inner product between the two states, , to additive error by taking the average over runs of the swap test.[5] This requires copies of the input states. The squared inner product roughly measures "overlap" between the two states, and can be used in linear-algebraic applications, including clustering quantum states.[6]