We can recognize that the Pauli $X$ gate will change the state $|0\rangle$ to $|1\rangle$ and vice versa, and $\alpha|0\rangle + \beta|1\rangle$ to $\alpha|1\rangle + \beta|0\rangle$.

As a reminder, the Pauli $X$ gate is defined by the following matrix:

$$
X =
\begin{bmatrix} 0 &  1 \\\ 1 &  0 \end{bmatrix}
$$

We can see how it affects, for example, the basis state $|0\rangle$:

$$
X|0\rangle =
\begin{bmatrix} 0 &  1 \\\ 1 &  0 \end{bmatrix}
\begin{bmatrix} 1 \\\ 0 \end{bmatrix} =
\begin{bmatrix} 0 \cdot 1 + 1 \cdot 0 \\\ 1 \cdot 1 + 0 \cdot 0 \end{bmatrix}=
\begin{bmatrix} 0 \\\1 \end{bmatrix}=
|1\rangle
$$

Similarly, we can consider the effect of the $X$ gate on the superposition state $|\psi\rangle = 0.6|0\rangle + 0.8|1\rangle$:

$$
X|\psi\rangle =
\begin{bmatrix} 0 &  1 \\\1 &  0\end{bmatrix}
\begin{bmatrix}0.6 \\\0.8 \end{bmatrix}=
\begin{bmatrix} 0 \cdot 0.6 + 1 \cdot 0.8 \\\1 \cdot 0.6 + 0 \cdot 0.8\end{bmatrix}=
\begin{bmatrix}0.8 \\\0.6\end{bmatrix}=
0.8|0\rangle + 0.6|1\rangle
$$

@[solution]({
"id": "single_qubit_gates__state_flip_solution",
"codePath": "./Solution.qs"
})
