# What happens to a qubit in superposition that goes through a Pauli-X gate?

Suppose, you have the following quantum circuit: We start with a qubit and put it through a Hadamard gate which will put the qubit into superposition.

Now, we apply the Pauli-X gate to the qubit in superposition (which flips the bit) and then we measure the result.

Regardless of whether the circuit makes sense or not, my question is: To flip a bit, the bit must be known. Does this mean, applying the Pauli-X gate automatically leads to a collapse of the superposition?

• I'd have a look at the concept of unitary time evolution, which such operations fall under' – user129412 May 6 '18 at 10:10
• No. That is how a classical X gate would work. The challenge in building quantum gates is that they work on superpositions of 0 and 1 as well. If you put in a superposition of 0 and 1, you get out the same superposition of 1 and 0. – knzhou May 6 '18 at 10:53

is completely incorrect. The Pauli X gate, like all unitary evolution, applies linearly: if $$X|0⟩ = |1⟩ \quad \text{and} \quad X|1⟩ = |0⟩,$$ then $X$ acting on a superposition $\alpha |0⟩+ \beta |1⟩$ will produce a superposition of the outcomes, i.e. \begin{align} X \left( \alpha |0⟩+ \beta |1⟩ \right) & = \alpha X|0⟩+ \beta X|1⟩ \\ & = \alpha |1⟩+ \beta |0⟩, \end{align} or in matrix form $$\begin{pmatrix}0&1\\1&0\end{pmatrix} \begin{pmatrix}\alpha\\ \beta\end{pmatrix} = \begin{pmatrix}\beta \\ \alpha\end{pmatrix}.$$ There's no collapse of the wavefunction until (and unless) you explicitly perform a projective measurement.
Rather than thinking of it as a "flip" think of it as a rotation. The Pauli-X gate rotates the Bloch sphere around the X-axis by $\pi$ radians. It maps $\vert0\rangle$ to $\vert1\rangle$, $\vert1\rangle$ to $\vert0\rangle$ and (the superposition) $\alpha\vert0\rangle+\beta\vert1\rangle$ to $\alpha\vert1\rangle+\beta\vert0\rangle$. Two Hadamard or Pauli gates in a row are equivalent to having none, they undo themselves.