# How to check a qubit's state?

Is it possible to write an algorithm that returns a single bit that represents if a qubit is in superposition or not, without compromising the qubit's wavefunction? Example:

is_in_superposition($$\vert 0 \rangle$$) = 0

is_in_superposition($$\dfrac{1}{\sqrt{2}} \vert 0 \rangle + \dfrac{1}{\sqrt{2}} \vert 1 \rangle$$) = 1

Even though this gate wouldn't be unitary, it wouldn't even be linear. Let us write this down.

Let us call this gate $$\mathbf{S}$$. $$\mathbf{S}$$ has the following properties:

$$\mathbf{S}\,|x\rangle=\begin{cases}|0\rangle&\text{if } |x\rangle=|0\rangle\text{ or }|1\rangle\\|1\rangle&\text{otherwise}\end{cases}$$

Then we would have:

$$\mathbf{S}\,(\alpha\,|0\rangle+\beta\,|1\rangle)=|1\rangle$$

by assumption. But we also have:

$$\mathbf{S}\,(\alpha\,|0\rangle+\beta\,|1\rangle)=\alpha\,\mathbf{S}\,|0\rangle+\beta\,\mathbf{S}\,|1\rangle = \alpha\,|0\rangle+\beta\,|0\rangle$$

which is contradictory. Hence, such a gate doesn't exist. Actually, with the same argument, you cannot implement such a gate with additional qubits either: since the gate makes a distinction between superposed and non-superposed states, it cannot be linear and as such, cannot be a gate.

Maybe an algorithm that would do such a task, if you want a classical result rather than a quantum state, could be implemented as such:

1. Create the state you're interested in.
2. Measure it.
3. Repeat.

If at least once you get different results (and if we don't consider noise that may affect the state), then you know that this quantum state is in a superposition. Of course, this is a very bad algorithm:

1. Creating the state can be computationally hard.
2. Noise can induce inaccuracies in the measurement.
3. You're never sure that a state really is not in a superposed state.

Still, you would have noticed that a measurement is performed. Hence, the wavefunction is affected. Since you want to get a classical result, the only way you have for this is to perform a measurement.

Our only solution here is to add qubits to get this piece of information. Even there, it is not possible to do such a thing. We cannot get our answer as a quantum state using the same argument stated above. We cannot even use controlled gates to see whether $$\alpha$$ or $$\beta$$ is nil, since the measurement will then affect $$|x\rangle$$. You can refer/learn more about that by searching "Weak measurement"

Unless I'm mistaken, it is thus impossible to perform such an operation.

• Thanks for the explanation! After your answer, I realized that the only way of knowing $\alpha$ and $\beta$ is to keep track of them as you perform operations, because, if they are unknown, trying to know $\alpha$ or $\beta$ is indeed a form of measurement, even if we only want to know whether they are $0$ or $1$. Commented May 10, 2020 at 22:00