Basis-Specific SWAP Test (Comparing Quantum States)

The standard SWAP Test is basis-agnostic. It measures the “overlap” of quantum states, which is to say you measure 0 with a probability of 1 when the states are identical and 0 with a probability of .5 when the states are maximally different (on completely opposite sides of the Bloch sphere such as |0> and |1>, |+> and |->, |i> and |-i>, and all other opposite points). Measurements between 0 and .5…