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
2 votes
1 answer
47 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}{\...
pablote's user avatar
  • 23
3 votes
1 answer
83 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=...
Mark Spinelli's user avatar
0 votes
1 answer
107 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 ...
Saul_better's user avatar
4 votes
1 answer
237 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 ...
Saul_better's user avatar
0 votes
1 answer
83 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 ...
Lior's user avatar
  • 1,190
1 vote
0 answers
101 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?
vector's user avatar
  • 11
1 vote
0 answers
32 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 ...
Loic Stoic's user avatar
4 votes
0 answers
115 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 ...
TwentyCents's user avatar
0 votes
1 answer
54 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: ...
Loic Stoic's user avatar
1 vote
1 answer
212 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 ...
Pratyush's user avatar
8 votes
0 answers
190 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 ...
Loic Stoic's user avatar
3 votes
1 answer
206 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 ...
Andrew Dynneson's user avatar
1 vote
1 answer
99 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{...
wavosa's user avatar
  • 379
0 votes
2 answers
480 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 ...
quark epsi's user avatar
0 votes
2 answers
128 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 ...
Saul_better's user avatar
5 votes
1 answer
289 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[\...
incud's user avatar
  • 681
3 votes
1 answer
54 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 \...
SescoMath's user avatar
  • 485
4 votes
0 answers
67 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 ...
shashvat's user avatar
  • 705
0 votes
0 answers
42 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 ...
Ren-Xin Zhao's user avatar
1 vote
0 answers
46 views

Is there a way to find the inner product between some ground states in a superposition?

Suppose there is a superposition state $|{{\Phi }^{+}}\rangle =\sum\limits_{i=0}^{15}{U({{\theta }_{i}})|i\rangle }$, I want to get $\langle i|U{{({{\theta }_{i}})}^{\dagger }}U({{\theta }_{m}})|m\...
Ren-Xin Zhao's user avatar
5 votes
1 answer
221 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 ...
Moonlighter's user avatar
4 votes
2 answers
326 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\...
userflux9674's user avatar
2 votes
0 answers
475 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?
Ren-Xin Zhao's user avatar
0 votes
1 answer
144 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 ...
user19468's user avatar
3 votes
2 answers
136 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 ...
Konstandinos's user avatar
2 votes
1 answer
590 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 ...
kingusiu's user avatar
  • 121
4 votes
1 answer
208 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 ...
Jason Pereira's user avatar
3 votes
1 answer
552 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 $|\...
Martin Vesely's user avatar
2 votes
1 answer
147 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 = \...
See's user avatar
  • 23
2 votes
2 answers
159 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 ...
Matt Penner's user avatar
1 vote
1 answer
122 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 ...
Andrew's user avatar
  • 323
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.
sohamb172's user avatar
  • 345
13 votes
2 answers
4k 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 ...
Hamza's user avatar
  • 281
9 votes
2 answers
763 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 ...
czwang's user avatar
  • 849
2 votes
3 answers
792 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 ...
Gianni's user avatar
  • 364
3 votes
2 answers
593 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\...
Gianni's user avatar
  • 364