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
44 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 ...
Count Ably's user avatar
2 votes
0 answers
28 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 $$ ||\...
francler's user avatar
  • 181
2 votes
0 answers
73 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 $\...
francler's user avatar
  • 181
2 votes
2 answers
310 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 ...
francler's user avatar
  • 181
2 votes
1 answer
62 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
93 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
124 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
271 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
96 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,210
1 vote
0 answers
150 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
33 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
5 votes
0 answers
165 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
56 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
302 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
194 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
321 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
120 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
  • 399
0 votes
2 answers
680 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
162 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
374 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
  • 701
3 votes
1 answer
55 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
  • 507
4 votes
0 answers
71 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
  • 805
0 votes
0 answers
43 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
48 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
243 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
385 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
543 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
156 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
144 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
642 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
5 votes
2 answers
245 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
624 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
158 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
186 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
128 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
14 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 ...
Hamza's user avatar
  • 291
9 votes
2 answers
801 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
  • 859
2 votes
3 answers
827 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
608 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