1
$\begingroup$

I've been reading the wikipedia page on the SWAP test, and am particularly confused on the last step of the explanation of the circuit.

Swap test explanation

I understand every step, except for the last one:

$P(0) = \frac{1}{4} \left ( \left < \phi \right | \left < \psi \right | + \left < \psi \right | \left < \phi \right | \right ) \left ( \left | \phi \right > \left | \psi \right > + \left | \psi \right > \left | \phi \right > \right )$.

How exactly are we going from a quantum state to an inner product of two quantum states? Can someone provide a more mathematically full explanation of this step?

Thanks.

$\endgroup$

1 Answer 1

4
$\begingroup$

Please look at picture of the circuit.

enter image description here

The state in the second last step, is the state after the second $H$ gate. Now, we only have to measure, and we are interested in the probability of the two possible outcomes $0$ and $1$.

This is done via the formalism of the partial measurement. Let $(n+1)$-qubits be in state $$ |0\rangle|\Psi_0\rangle_n + |1\rangle|\Psi_1\rangle_n, $$ where $\langle \Psi_0 |\Psi_0\rangle + \langle \Psi_1|\Psi_1\rangle = 1$.

If we measure the first qubit, then the probability of outcome $0$ is given by $$ P(0) = \langle\Psi_0|\Psi_0\rangle $$ and, similarly for outcome $1$.

This is exactly what is happening here, with $$ |\Psi_0\rangle = \frac{1}{2}(|\psi\rangle|\phi\rangle + |\phi\rangle|\psi\rangle). $$

With this, the computation is simple.

\begin{align*} P(0) &= \langle\Psi_0|\Psi_0\rangle, \\ &= \frac{1}{2}(\langle\psi|\langle\phi| + \langle\phi|\langle\psi|) \frac{1}{2}(|\psi\rangle|\phi\rangle + |\phi\rangle|\psi\rangle). \end{align*} Here, the product of the first and the third term is 1, the product of the second and fourth term is also 1, and the two cross terms have product $\langle \psi|\phi\rangle \langle \psi|\phi\rangle = |\langle \psi|\phi\rangle|^2$.

Putting this all together, we get $$ P(0) = \frac{1}{4}(1 + 1 + 2 |\langle \psi|\phi\rangle|^2), \\ = \frac{1}{2} + \frac{1}{2} |\langle \psi|\phi\rangle|^2. $$

$\endgroup$
4
  • $\begingroup$ Oh, I've never heard of the partial measurement formalism. Thanks. $\endgroup$
    – wavosa
    Commented Mar 8, 2023 at 1:50
  • $\begingroup$ I have added additional details. $\endgroup$ Commented Mar 8, 2023 at 2:55
  • 1
    $\begingroup$ "...where $|\Psi_0\rangle_n, |\Psi_0\rangle_n$ are normalized." First, I think you have a typo where one of the $0$ symbols should be a $1$ symbol. Second, these kets are not individually normalized. If that were literally the case you would have both $P(0) = 1$ and $P(1) = 1$. I think what you mean to say is that $\langle\Psi_0|\Psi_0\rangle+\langle\Psi_1|\Psi_1\rangle=1$ $\endgroup$
    – hft
    Commented Mar 8, 2023 at 5:26
  • 1
    $\begingroup$ @hft Thank you for the correction. Fixed. $\endgroup$ Commented Mar 8, 2023 at 6:41

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.