2

1

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.$$

1First, two *

qubits* always have the same size; by definition the dimension of a qubit is 2. If you have two quantum registers, of two dimensions and of three dimensions, then it doesn't really make sense to apply the Swap Test to these two registers. You could apply the Swap Test to the dimension-two register and a dimension-two subspace of the dimension-three register, or a dimension-3 extension of the first register and the second register. But to see whether that would be a good idea, you have to tell us what you're trying to accomplish with the Swap Test. – Peter Shor – 2019-03-16T14:28:10.253Hi, Gianni. Welcome to Quantum Computing SE! Please do not post mathematical expressions as screenshots, but use MathJax instead. Review Why are images of text, code and mathematical expressions discouraged?. I've [edit]ed it on your behalf this time.

– Sanchayan Dutta – 2019-03-16T14:39:41.907@Peter, I'm trying to apply Lloyd's method for deriving the difference between two vectors (a) and (b) using the Swap test, and also reported in the paper I've mentioned. There two qubit registers psi and phi are introduced and the vector difference is said can be calculated as inner product of those two registers (see formula (132) above. – Gianni – 2019-03-16T15:59:17.760

The point is that psi and phi have different size (psi is n+1, where n is the size of the two vectors, and phi is size 1), and then it's not clear how you can perform an inner product between them. Those two register are supposed to be the 2 inputs of the swap test (ancilla apart), but their size has to match. You mention the use of a sub-space for the bigger register (psi in my case), or of an extended subspace for the smaller register (phi), but I don't see how to reflect that both mathematically and into circuit element. Could you be more explicit? – Gianni – 2019-03-16T15:59:40.380

Finally, the first equation (133) I report relating a scalar (inner product) with a qubit register. How can that be correct? – Gianni – 2019-03-16T16:02:05.397

@GianniCasonato To also notify a previous commenter, mention their user name with a

– Sanchayan Dutta – 2019-03-17T07:59:57.550`@`

symbol:`@peter`

or`@PeterShor`

will both work. Review the formatting help page. I've edited your first comment. Andpleasego through the MathJax tutorial. Terms like "phi" and "psi" are not very readable when written in words. Please use MathJax to write them as $\phi$ (`$\phi$`

) and $\psi$ (`$\psi$`

) instead. Thanks!