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.
41 questions
15
votes
2
answers
5k
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 ...
9
votes
2
answers
854
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 ...
8
votes
0
answers
212
views
Optimal estimation of quantum state overlap - Circuit implementation?
I've been reading this paper, but don't understand what their optimal method really is, and how it can be realized as a quantum circuit.
The paper mentions the "Schur transform" which has a ...
5
votes
1
answer
306
views
Swap test vs measurement in a specific basis
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 ...
5
votes
2
answers
302
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 ...
5
votes
1
answer
543
views
Fidelity (overlap) test over reduced density matrices on quantum circuit
The inner product between two quantum states
$\rho(x_1) = U(x_1)|0\rangle\langle 0| U^\dagger(x_1)$ and
$\rho(x_2) = U(x_2)|0\rangle\langle 0| U^\dagger(x_2)$ can be calculated analytically with $Tr[\...
5
votes
0
answers
261
views
Explanation of the generalized SWAP test: the permutation test?
I am reading this paper on the state separability problem, and came across the term “Permutation Test.” This is on page 7 section 2.3.
Apparently, the more famous SWAP test is a special case of ...
4
votes
1
answer
316
views
What is the "additive error" of Swap Test?
I'm learning the Swap Test, a quantum circuit to calculate the inner product of two quantum states $|\langle \phi|\psi\rangle|^2 $:
For the error analysis of this quantum circuit, according to Swap ...
4
votes
1
answer
1k
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.
4
votes
2
answers
471
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\...
4
votes
0
answers
76
views
Comparing two sets of qudits
Suppose we are given two sequences of qudits, in some states unknown to us: $(|\psi_1\rangle, ... |\psi_n\rangle)$ and $(|\phi_1\rangle, ... |\phi_n\rangle)$. The qudits are not entangled to each ...
3
votes
2
answers
621
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\...
3
votes
1
answer
109
views
Can we test whether $|\psi\rangle$ is orthogonal to $|\phi\rangle$ without creating a coherent superposition therebetween?
Let a first register store $|\psi\rangle$ and a second register store $|\phi\rangle$, and let us be promised that either $\vert\langle\psi|\phi\rangle\vert^2=0$ or $\vert\langle\psi|\phi\rangle\vert^2=...
3
votes
1
answer
571
views
Integral over Haar measure of squared density matrix of Haar random state is proportional to the identity plus swap operator
I am having some trouble understanding why $\int d\psi (| \psi \rangle \langle \psi | )^{\otimes ^2}\propto \ I+$ SWAP , where $|\psi \rangle =U|\psi _0\rangle$ are Haar random states and $d\psi $ is ...
3
votes
1
answer
61
views
SWAPing Schmidt vectors
Can anything be said about the inner product of a bipartite entangled state with itself but with the Schmidt vectors swapped? That is, if the Schmidt decomposition of a state is given by
$$\vert \psi \...
3
votes
2
answers
149
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 ...
3
votes
1
answer
757
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 $|\...
3
votes
3
answers
79
views
How can I move a C.NOT over a circuit
I am doing some Quantum Computing Exercises and I am curious on how you go from left to right in this picture...
I see not only how the c-not moves but also a new bond between X gates in second and ...
2
votes
3
answers
863
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 ...
2
votes
1
answer
606
views
Can IBM Quantum hardware handle any CSWAP at all?
I am designing quantum algorithms where the quantum circuit uses CSWAP gates a lot. The result is very noisy on the quantum hardwares. So I designed really simple circuits to test whether it is indeed ...
2
votes
2
answers
348
views
Alternatives to the swap test using a smaller number of qubits
I need to compute the inner product between two generic quantum states. To this aim, one can use the swap test as explained in https://en.wikipedia.org/wiki/Swap_test .
In my case, both of the quantum ...
2
votes
1
answer
83
views
How to implement the state $|\psi\rangle = \frac{1}{\sqrt{2}}\left[|0\rangle \otimes |X_i\rangle + |1\rangle \otimes |X_j\rangle\right]$
I am trying to implement the quantum k-means algorithm proposed in https://arxiv.org/pdf/1909.04226.pdf.
In the equation (8) of the manuscript we need to implement a state $|\psi\rangle = \frac{1}{\...
2
votes
1
answer
175
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 = \...
2
votes
2
answers
225
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 ...
2
votes
1
answer
77
views
How to compute the measurement probability in the Hadamard test?
In the Hadamard test (e.g., page 40 of these lecture notes) we have:
But if you look at standard textbook reference, like Nielsen and Chuang, there's an example for how to compute the measurement ...
2
votes
1
answer
708
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 ...
2
votes
0
answers
46
views
Efficient way to compute the $L^1$ norm of quantum state
We all know that the $L^2$ norm
$$
||\psi||_2 = \sqrt{\sum_i |c_i|^2}
$$
of a quantum state $|\psi\rangle = \sum_i c_i |i\rangle$ is always equal to $1$. It is possible to compute the $L^1$ norm
$$
||\...
2
votes
0
answers
84
views
Given three quantum states, how to compute the triple product of amplitudes $\sum_i u_i v_i w_i$?
Assume I have three quantum states $|u\rangle$, $|v\rangle$ and $|w\rangle$ which can be obtained with three quantum circuits $U$, $V$ and $W$.
We know that we can easily estimate the inner product $\...
2
votes
0
answers
650
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?
1
vote
1
answer
144
views
SWAP test: clarification of measurement output
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.
I understand every step, except for the last one:
$P(0) = \frac{...
1
vote
1
answer
394
views
pennylane:fidelity calculation after swap test between entagled states. Swap test issue
What I am trying to do is first take an image and encode it into quantum states, for this I have taken an image from the MNIST dataset and then reshaped it to (4,4) and now I wrote the following ...
1
vote
1
answer
145
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 ...
1
vote
0
answers
278
views
Is it possible to design a swap test for three qubits? If it is possible how is it different from 2 and 4 qubits? share the design of the swap test?
Explain the swap test for 2 qubits to find the distance between qubits. Extend the swap test for 3 and 4 qubits. Will the design differ from each other and share the design for both the swap tests?
1
vote
0
answers
40
views
What are the estimate-estimate and estimate-project algorithms for quantum overlap?
In this paper on improvements to the traditional SWAP test to measure quantum state overlap (or fidelity), they mention two methods called estimate-estimate and estimate-project.
I googled about these ...
0
votes
2
answers
211
views
What's the matrix representation of the CSWAP?
I don't know how to represent the matrix format of the CSWAP gate in the circuit:
Despite reviewing some material about CSWAP from Qiskit CSWAP, I am still unable to understand the concept. I am ...
0
votes
1
answer
67
views
How are mixed states given to a quantum algorithm?
I've been reading this paper about quantum fidelity estimation, but really have no idea what's going on when it comes to density matrix notation. In the abstract, they have the following quote:
...
0
votes
1
answer
148
views
How to apply error-correction to the swap test circuit?
Swap test is a simple quantum circuit to measure the inner product of two quantum states [Wiki: swap test], it only contains three quantum gates. However, due to the error in the real quantum computer ...
0
votes
1
answer
138
views
perform a SWAP measurement using local operations and classical feedback
I am interested in performing a SWAP measurement, namely, measure 2 qubits and project their state onto either the triplet state manifold $\{|00\rangle, |11\rangle, |01\rangle + |10\rangle\}$ or the ...
0
votes
2
answers
938
views
How to compare 2 classical number using a quantum circuit
I'm given 2 numbers(could be positive/negative). I want to program a quantum circuit to compare them and return the greater one.
How can I do that?
Also, if the first step is encoding the numbers ...
0
votes
1
answer
171
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 ...
0
votes
0
answers
44
views
How to obtain the product of the amplitudes of arbitrary basis vectors in a superposition state without measuring?
Suppose there is a superposition state $|{{\Phi }^{+}}\rangle =\sum\limits_{i=0}^{15}{{{\alpha }_{i}}|i\rangle }$, I want to get ${{\alpha }_{i}}\times {{a}_{j}},i\ne j,i,j\in [0,15]$ without ...