Questions tagged [swap-test]

For questions related to the "Swap test": a quantum algorithm whose purpose is to quantify the distance between two given quantum states.

Filter by
Sorted by
Tagged with
3 votes
2 answers
117 views

Estimating imaginary part of an inner product of two quantum states

Suppose I want to estimate $Im(\langle \psi_1\lvert \sigma_x\lvert \psi_2\rangle)$ by using quantum circuit. At first, I thought of using the Swap test, but since it gives $|\langle \psi_1|\psi_2\...
user avatar
2 votes
0 answers
124 views

What is the complexity of the Hadamard test and the SWAP test?

How to calculate the complexity of both the Hadamard test and SWAP test with $n$ qubits?
user avatar
  • 362
0 votes
1 answer
78 views

Parameterized swap test and perfect swap test

Suppose one has parameterized a swap test by using an ansatz $U(\theta) = \exp(-i\theta \text{ CSWAP})$, and one tries to find an angle $\theta$ such that one can distinguish given two quantum states ...
user avatar
2 votes
2 answers
112 views

Confusion in computing the $1+|\langle\phi|\psi\rangle|^2$ term in the quantum swap test algorithm

I am having trouble understanding a particular step of the Swap-test algorithm. As I am struggling with this for the past week, I thought I should ask here. So, I get the procedure until right after ...
user avatar
2 votes
1 answer
326 views

Amplitude encoding: distinction between negative and positive real values

I want to encode two vectors into qubits and compute a distance between them that corresponds/is proportional to the euclidian distance of the real vectors. The encoding I use is A) qiskit ...
user avatar
0 votes
0 answers
36 views

Quantum check sample implementation

I've been trying to figure out how to create a simple circuit in Qiskit to create a check (cheque ) generation and verification as described in this paper. I started with 3 qubits, first one with the ...
user avatar
  • 405
2 votes
1 answer
101 views

How do you test a pair of unknown qubits for orthogonality with certainty?

If you want to check if a pair of unknown qubits are the same, a standard test is the controlled SWAP test. This gives a result of 0 with certainty if the states are the same and 1 with a 50% chance ...
user avatar
3 votes
1 answer
283 views

How to calculate inner product of quantum states with other method than swap test? [duplicate]

In connection to this question, I am wondering how to calculate value $\langle \psi|\phi \rangle$ for arbitrary quantum states $|\psi\rangle$ and $|\phi\rangle$. A swap test is able to return only $|\...
user avatar
2 votes
1 answer
111 views

In the swap test, how is the final probability $P(0)$ calculated?

Does anyone know much about quantum dot product: Lets say: $$|\psi \rangle = \frac{|0\rangle_1|\overrightarrow{x_i}\rangle_2 + |1\rangle_1|\overrightarrow{x_j}\rangle_2}{\sqrt 2}$$ $$|\phi \rangle = \...
user avatar
  • 23
1 vote
1 answer
63 views

In a Swap Test why is the control qubit influenced and aren't the target qubits altered?

I am in a study group learning about quantum computing using O'Reilly - Programming Quantum Computing. I'm a developer, not a physicist. :) I feel like my question is rudimentary but I can't seem to ...
user avatar
1 vote
1 answer
67 views

Implementing a SWAP-Test for samples with large numbers of features

I am trying to calculate the distance between sets of vectors. To do this I can create a SwapTest circuit (described here on page 34) and encode a feature vector with a U3 gate, then apply H and CSWAP ...
user avatar
  • 323
4 votes
1 answer
665 views

How to implement the swap test with the help of qiskit?

It's creating a real confusion for me especially the parameterized circuit which I have to create. Can anybody please solve this for me? I want to create this circuit.
user avatar
  • 330
12 votes
2 answers
3k views

How and why does swap test works?

I am having some trouble understanding why a SWAP test would work. I meant I read that and understood the concepts as follows: If the two input states are equal, the output register always results in ...
user avatar
  • 271
8 votes
2 answers
546 views

Distance calculation between two vectors

In Quantum Machine Learning for data scientists, Page 34 gives an algorithm to calculate the distance between two classifical vectors. As mentioned in this question, it is not clear how the SwapTest ...
user avatar
  • 789
2 votes
3 answers
642 views

Swap Test for vector difference - how are different sized inputs combined?

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 ...
user avatar
  • 354
3 votes
2 answers
520 views

Can the SWAP test only compare registers with the same number of qubits?

I'm using the SWAP test circuit for implementing a qubit registers comparison From the documentation I could find I've understood it can be applied to input qubits |$\alpha\rangle$ and |$\beta\...
user avatar
  • 354