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 if the states are orthogonal. The resulting probability distribution can also be used to approximate fidelity, etc.

Is there a/what is the equivalent test to determine orthogonality with certainty, i.e. giving a result of 0 with certainty if the states are orthogonal and 1 with some probability if the states are identical?

Alternatively, is there a more balanced test, which gives the same (lower than 50%) error in detecting either orthogonality or similarity?

Obviously, one opton is to carry out state tomography on each qubit to get their mathematical descriptions and calculate the orthogonality/fidelity accordingly, but this may not be the best solution in terms of copies required for a given accuracy.


2 Answers 2


It is not possible for a measurement to deterministically give one outcome or the other depending on whether two states are equal or orthogonal. Such a measurement would be some two-outcome POVM $\mu$ such that $$\langle\mu(\text{yes}),\rho\otimes\rho\rangle=1, \qquad \langle\mu(\text{no}),\rho\otimes\sigma\rangle=1,$$ for all states $\rho$ and $\sigma$ with $\langle\sigma,\rho\rangle=0$.

This would imply, in particular, that $$\langle \mu(\text{yes}),\mathbb P_0\otimes \mathbb P_0\rangle =\langle \mu(\text{yes}),\mathbb P_1\otimes \mathbb P_1\rangle =1,\\ \langle \mu(\text{yes}),\mathbb P_0\otimes \mathbb P_1\rangle =\langle \mu(\text{yes}),\mathbb P_1\otimes \mathbb P_0\rangle =0, \\ 1 = \langle \mu(\text{yes}),\mathbb P_+\otimes \mathbb P_+\rangle = \frac12 + \frac14 \langle\mu(\text{yes}),I\otimes X+X\otimes I\rangle, \\ 1 = \langle \mu(\text{yes}),\mathbb P_-\otimes \mathbb P_-\rangle = \frac12 - \frac14 \langle\mu(\text{yes}),I\otimes X+X\otimes I\rangle,$$ where I'm using the shorthand notation $\mathbb P_\psi\equiv|\psi\rangle\!\langle\psi|$, and $X\equiv|0\rangle\!\langle1|+|1\rangle\!\langle0|$.

The last two conditions are clearly inconsistent, as summing them we'd get $2=1$, thus no such measurement can exist.

A measurement that always gives the outcome "yes" when the input has the form $\rho\otimes \rho$ is possible, for example, the trivial "measurement" that always returns "yes". But this clearly will not correctly classify orthogonal input states.

There's probably a better way to show this though.

  • 1
    $\begingroup$ Thanks, I get that the measurement can't be deterministic in both cases. In fact, I think the existence of such a measurement would violate the no-cloning principle. The SWAP test is deterministic on identical states and probabilistic on orthogonal ones. I want the opposite: a test that's deterministic on orthogonal states and probabilistic on identical states. You're right, I can make a trivial measurement! So perhaps a better way of phrasing the question is: what measurement is deterministic for orthogonal states and has 50:50 probability for identical states (opposite of the SWAP). $\endgroup$ Commented Jul 22, 2021 at 23:09
  • 1
    $\begingroup$ @Jason How could you use it to build a cloner? $\endgroup$ Commented Jul 23, 2021 at 22:48

Though gIS' answer concerns deterministic measurements, its conclusion doesn't change when considering probabilistic measurements.

Though it's not a formal proof, we can use picos to look for such a measurement. That is, we want it to look for $M_0$ and $M_1$ such that:

  • Both are positive semi-definite;
  • $M_0+M_1=I$
  • For all $|\psi\rangle$ and $|\varphi\rangle$ such that $\langle\psi|\varphi\rangle=0$, $\mathrm{tr}\left(M_0|\psi,\varphi\rangle\!\langle\psi,\varphi|\right)=1$. This corresponds to the fact that the measurement identifies orthogonal states perfectly.
  • The probability of getting the $0$ outcome on non-orthogonal states is as low as possible.

The last condition is not very formal, and the penultimate one is quite hard to test, so we'll solve a simpler problem: find $M_0$ and $M_1$ such that:

  • Both are positive semi-definite;
  • $M_0+M_1=I$
  • We obtain the outcome $0$ with certainty on input $|0,1\rangle\!\langle0,1|$, $|1,0\rangle\!\langle1,0|$, $|+,-\rangle\!\langle+,-|$, $|-,+\rangle\!\langle-,+|$, $|i,-i\rangle\!\langle i,-i|$ and $|-i,i\rangle\!\langle -i,i|$.
  • We want to minimize the average probability of getting the outcome $0$ on input $|0,0\rangle\!\langle0,0|$, $|1,1\rangle\!\langle1,1|$, $|+,+\rangle\!\langle+,+|$, $|-,-\rangle\!\langle-,-|$, $|i,i\rangle\!\langle i,i|$ and $|-i,-i\rangle\!\langle -i,-i|$.

Clearly, if a non-trivial measurement exists for the problem we care about, it will also be a non-trivial solution for the second one. Conversely, if there is no non-trivial measurement that solves the second problem, then no non-trivial measurement solves the first.

We thus input this to picos:

import numpy as np
import picos as pc

sdp = pc.Problem(verbosity = 0)
M0 = pc.HermitianVariable("M0", (4, 4))
M1 = pc.HermitianVariable("M1", (4, 4))

sdp.add_constraint(M0 >> 0)
sdp.add_constraint(M1 >> 0)
sdp.add_constraint(M0 + M1  == np.eye(4))

zero_state = np.array([[1], [0]])
one_state = np.array([[0], [1]])
plus_state = np.array([[1], [1]]) / np.sqrt(2)
minus_state = np.array([[1], [-1]]) / np.sqrt(2)
i_state = np.array([[1], [1j]]) / np.sqrt(2)
minus_i_state = np.array([[1], [-1j]]) / np.sqrt(2)

certainty_states = [
    np.kron(zero_state, one_state),
    np.kron(one_state, zero_state),
    np.kron(plus_state, minus_state),
    np.kron(minus_state, plus_state),
    np.kron(i_state, minus_i_state),
    np.kron(minus_i_state, i_state),

extremal_states = [
    np.kron(zero_state, zero_state),
    np.kron(one_state, one_state),
    np.kron(plus_state, plus_state),
    np.kron(minus_state, minus_state),
    np.kron(i_state, i_state),
    np.kron(minus_i_state, minus_i_state),

certainty_states = [s @ s.conj().T for s in certainty_states]
extremal_states = [s @ s.conj().T for s in extremal_states]

for state in certainty_states:
    sdp.add_constraint(pc.trace(M0 * state) == 1)

obj = pc.trace(M0 * sum(extremal_states))
sdp.set_objective("min", obj)

print(sdp.value / 6)

This code yields:

[[ 1.00000000e+00+0.00000000e+00j  1.97355128e-16-3.66797943e-16j
  -3.26236171e-16+2.02131752e-16j  7.63261303e-16+4.46637958e-21j]
 [ 1.97355128e-16+3.66797943e-16j  1.00000000e+00+0.00000000e+00j
   1.29011297e-11-3.66985535e-21j -3.23831307e-16-3.85180042e-16j]
 [-3.26236171e-16-2.02131752e-16j  1.29011297e-11+3.66985535e-21j
   1.00000000e+00+0.00000000e+00j  1.98606930e-16+1.52525270e-16j]
 [ 7.63261303e-16-4.46637958e-21j -3.23831307e-16+3.85180042e-16j
   1.98606930e-16-1.52525270e-16j  1.00000000e+00+0.00000000e+00j]]

Thus, up to inaccuracies, the optimal measurement is the trivial one that always return $0$.

As a sanity check, we can invert the role of extremal_states and certainty_states in the code above in order to check that we get the POVM associated to the SWAP test (or something at least as good). Doing so yields:

[[1.00000000e+00+0.00000000e+00j 1.00930041e-16-3.04715104e-16j
  2.41912746e-16-1.61029373e-16j 3.27055113e-16+6.68833130e-21j]
 [1.00930041e-16+3.04715104e-16j 4.99999980e-01+0.00000000e+00j
  4.99999997e-01+3.36471447e-18j 3.22435776e-16-2.47496372e-17j]
 [2.41912746e-16+1.61029373e-16j 4.99999997e-01-3.36471447e-18j
  4.99999980e-01+0.00000000e+00j 1.41739720e-16-7.93076212e-17j]
 [3.27055113e-16-6.68833130e-21j 3.22435776e-16+2.47496372e-17j
  1.41739720e-16+7.93076212e-17j 1.00000000e+00+0.00000000e+00j]]

which is what we expected.

All in all, there is no measurement other than the trivial one that behaves deterministically on orthogonal states.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.