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?
 A: This

to flip a bit, the bit must be known

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.
A: Three videos by Micheal Nielsen explain this at length, quite simply: 


*

*Our first quantum gate: the quantum NOT gate 

*The Hadamard Gate 

*Measuring a Qubit 
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.
