# Can we test whether $|\psi\rangle$ is orthogonal to $|\phi\rangle$ without creating a coherent superposition therebetween?

Let a first register store $$|\psi\rangle$$ and a second register store $$|\phi\rangle$$, and let us be promised that either $$\vert\langle\psi|\phi\rangle\vert^2=0$$ or $$\vert\langle\psi|\phi\rangle\vert^2=1$$; the standard approach to determine which is which is via the SWAP test.

After the SWAP test is performed, the state of the control qubit and the first and second registers is:

$$\frac{1}{2}|0\rangle(|\phi\rangle|\psi\rangle + |\psi\rangle|\phi\rangle) + \frac{1}{2}|1\rangle(|\phi\rangle|\psi\rangle - |\psi\rangle|\phi\rangle).$$

If $$\vert\langle\psi|\phi\rangle\vert^2=1$$ then the control qubit always measures $$|0\rangle$$ and the state is uncorrupted while if $$\vert\langle\psi|\phi\rangle\vert^2=0$$ then we end up creating a coherent superposition of the first and second registers being SWAP'ed (with either a positive or negative relative phase depending on the control qubit).

But is there another SWAP-like test that will leave the first and second registers uncorrupted if the first register is orthogonal to the second register (at the cost of, for example, corrupting the first and second registers conditioned on them being equal to each other)? For example could we iterate the SWAP test a polynomial number of times and have a high probability of keeping the first and second registers as $$|\psi\rangle\otimes|\phi\rangle$$ while also learning that $$\vert\langle\psi|\phi\rangle\vert^2=0$$?

I don't think so as I think this violates the no-cloning theorem but I can't put my finger on it yet.

No, you can't do it (except for trivial things). Think about what you're asking for: a map that performs $$|0\rangle|\psi\rangle|\psi^\perp\rangle\longrightarrow |1\rangle|\psi\rangle|\psi^\perp\rangle$$ (the first qubit being the one that's going to flag that the two states were orthogonal). Now try to see what happens if $$|\psi\rangle$$ is any of the eigenvectors of $$X$$ or $$Y$$. If you take linear combinations of them, you'll be able to prove things like $$|000\rangle\longrightarrow|100\rangle$$ etc. Indeed, the only operation that fulfils this does not act on the two input states and just flips the bit to be measured.