I have two states $|\psi\rangle$ and $|\phi\rangle$. The swap test allows to estimate $|\langle \psi | \phi \rangle|^2$ by using the controlled SWAP gate and a couple of Hadamard gates. To obtain the estimate we repetitively measure the first qubit in the computational basis.

I don't understand why the swap test is necessary if we could just repetitively measure $|\psi\rangle$ in a basis $\{|\phi\rangle, |\phi^{\perp}\rangle\}$ and get an estimate of $|\langle \psi | \phi \rangle|^2$?

Is this test useful because it preserves both $|\psi\rangle$ and $|\phi\rangle$? Or measuring in the computation basis is easier than measurement in $\{|\phi\rangle, |\phi^{\perp}\rangle\}$?

Thank you.


1 Answer 1


Probably the most important difference between the swap test and the projective measurement technique is that performing the swap test does not require knowledge of its inputs.

When applying the swap test, once you are provided the states $|\psi\rangle, |\phi\rangle$, you need no additional information about the systems to estimate $|\langle \psi | \phi \rangle|^2$.

With the projective measurement technique, you need to implement a measurement $\{|\phi\rangle\langle \phi|, I - |\phi\rangle\langle \phi|\}$ in order to estimate $|\langle \psi | \phi \rangle|^2$, which involves having some knowledge about $|\psi\rangle$ or $|\phi\rangle$ or how the states are prepared. For example, this measurement is easy to perform is if you are provided $|\psi\rangle$ and also given the ability to implement a unitary $V^\dagger$ where $V$ satisfies $|\phi\rangle = V |0\rangle$. In this case, you define your measurements as \begin{align} |\phi\rangle\langle \phi| &= V |0\rangle \langle 0| V^\dagger \tag{1} \\ I - |\phi\rangle\langle \phi| &= V \left(I - |0\rangle \langle 0|\right) V^\dagger \tag{2} \\&= V\left(\sum_{x\in\{0,1\}^n\backslash0} |x\rangle \langle x|\right)V^\dagger\tag{3} \end{align}

This form of the measurements highlights that after applying $V^\dagger$ to $|\psi\rangle$, the projectors represent computational basis measurements where the probability of observing "0" is $p(0) = |\langle \psi | \phi \rangle |^2$. But again, this relied on the ability to implement $V^\dagger$, which is not guaranteed.

  • $\begingroup$ I wish this was in Wikipedia article. $\endgroup$
    – MonteNero
    Commented Aug 11, 2022 at 18:38
  • 1
    $\begingroup$ Another difference between the SWAP test and the projection is that the SWAP test allows for a quantum output. The states that come out, however, are not unchanged (as suggested by the question), they are projected on the symmetric subspace for outcome 0, or on the complement of that space for outcome 1. This could be useful for further symmetry tests, in e.g. a multipartite system. $\endgroup$ Commented Sep 1, 2022 at 17:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.