Top Qs
Timeline
Chat
Perspective

Swap test

Technique for comparing quantum states From Wikipedia, the free encyclopedia

Swap test
Remove ads

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]

Thumb
Circuit implementing the swap test between two states and

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]

Remove ads

Explanation of the circuit

Summarize
Perspective

Consider two states: and . The state of the system at the beginning of the protocol is . After the Hadamard gate, the state of the system is . The controlled SWAP gate transforms the state into . The second Hadamard gate results in

The measurement gate on the first qubit ensures that it's 0 with a probability of

when measured. If and are orthogonal , then the probability that 0 is measured is . If the states are equal , then the probability that 0 is measured is 1.[2]

In general, for trials of the swap test using copies of and copies of , the fraction of measurements that are zero is , so by taking , one can get arbitrary precision of this value.

Below is the pseudocode for estimating the value of using P copies of and :

Inputs P copies each of the n qubits quantum states  and 
Output An estimate of 

for j ranging from 1 to P:
    initialize an ancilla qubit A in state 
    apply a Hadamard gate to the ancilla qubit A
    for i ranging from 1 to n: 
        apply CSWAP to  and  (the ith qubit of the jth copy of  and ), with A as the control qubit
    apply a Hadamard gate to the ancilla qubit A
    measure A in the  basis and record the measurement Mj as either a 0 or 1
compute .
return  as our estimate of 
Remove ads

References

Loading related searches...

Wikiwand - on

Seamless Wikipedia browsing. On steroids.

Remove ads