Starting from the -qubit computational basis state , apply one Hadamard gate to every qubit. Since ,
Thus parallel Hadamard gates prepare the uniform quantum superposition.
The Hadamard gate conjugates the Pauli X gate into the Pauli Z gate:
When the control qubit is , all three circuits act as the identity on the target. When it is , the right-hand circuit acts on the target as . It therefore agrees with the Controlled-Z gate on every computational basis state, proving
Conjugating both sides by and using immediately gives the reverse identity
The three controlled-NOT gates have directions , , and . On computational basis bits they act as
By linearity, the whole quantum circuit is the SWAP gate. Therefore
so and .
After the first Hadamard gate, the joint state is
The controlled SWAP gate then gives
After the second Hadamard gate, it is
The Born rule says that each probability is the squared norm of the corresponding ancilla component. Since the states are normalized,
Consequently
This circuit is the swap test. If the two pure states are identical up to a physically irrelevant global phase, then and outcome one never occurs. If they are distinct, then and each run produces outcome one with positive probability .
Run the circuit independently on fresh copies. Observing even one outcome one proves that the states differ. If no one occurs in runs, that event has probability
when the states differ, which tends to zero as . Repetition therefore distinguishes equality from inequality with arbitrarily high probability.

Articles by others on the same topic (0)

There are currently no matching articles.