2

I'm working on a similar problem of that raised by Aman in Inner product of quantum states

Concerning the use of Swap Test for calculating the difference of two vectors. An example of the original Lloyd formula is given in Quantum machine learning for data scientists.

And I got stuck at the same point, i.e. what mathematically means the inner product between the two qubits $\psi$ and $\phi$, which have different size. The explanation in the paper (eq. 133) which says

$$\langle \phi|\psi\rangle = \frac{1}{\sqrt{2Z}}(|a||a\rangle - |b||b\rangle)$$

looks incorrect because it equals an inner product (scalar value) with a qubit! Or am I missing something?

The suggestion of composing $\phi$ with tensor products of the identity matrices for matching $\psi$ and $\phi$ sizes looks a math trick because such composition is not an allowed quantum operation (identity matrix I should be supposed to be a qubit, and it's not of course). I share Aman's doubts on the demonstration of (132) i.e. $$|a-b|^2=2Z|\langle\phi|\psi\rangle|^2.$$

glS
  • 27,670
  • 7
  • 39
  • 126
Gianni
  • 364
  • 1
  • 7

3 Answers3

7

You are not swapping the first register (one qubit) with the entire second register ($k$ qubits), but just with the first qubit of the second register.

What you need to know is what is meant by $\langle x | y \rangle$ when $x$ is one qubit and $y$ is $k$ qubits. The resulting state is the $k-1$ qubit state you get when you project one qubit (generally the first one, if it isn't specified) onto the vector $|x\rangle$.

So for example, suppose $$|x\rangle = \alpha |0\rangle + \beta |1\rangle.$$

and suppose $$|y\rangle = \frac{1}{\sqrt{2}}\left( |00\rangle + |11\rangle\right).$$

When we take the inner product of $|x\rangle$ and $|y\rangle$, we get \begin{eqnarray*} \langle x | y \rangle &=& \frac{1}{\sqrt{2}} \left(\alpha^* \langle 0 | + \beta^* \langle1 | \right) \big( |0\rangle \otimes |0\rangle + |1\rangle \otimes |1\rangle\big) \\ &=& \frac{1}{\sqrt{2}} \left( \alpha^* \langle 0| 0\rangle \otimes |0\rangle + \alpha^* \langle 0| 1\rangle \otimes |1\rangle + \beta^* \langle 1| 0\rangle \otimes | 0\rangle+\beta^* \langle 1| 1\rangle \otimes |1\rangle \right) \\ &=& \frac{1}{\sqrt{2}} \left( \alpha^* |0\rangle +\beta^* | 1\rangle \right) \end{eqnarray*}

Peter Shor
  • 359
  • 1
  • 7
3

The paper you refer is incomplete and not very right on this part. First a minus sign should be present in : $$ |\phi\rangle = \frac{1}{\sqrt{Z}} (|a||0\rangle - |b||1\rangle) $$

Secondly, if you look at the original reference of this procedure on a special case of algorithm but it can be generalized, what you swap is actually the ancilla qubit of $ |\psi\rangle $ with the qubit in state $ |\phi\rangle$.

I was mislead by this paper before but found out the trick recently. We should point out also that there is a step of estimation of $Z$ before using this algorithm.

cnada
  • 4,852
  • 1
  • 9
  • 22
-2

Starting from the last index, just swap two qubits as long as you have them and then measure the ancilla qubit. This Works fine for me!!

Aman
  • 473
  • 3
  • 13