Solution (source code)

= Solution

Following the <pure state> through the first two gates gives $(|1\rangle+e^{i\alpha}|2\rangle)/\sqrt2$. After the last <Hadamard gate> it is
$$
|\Psi_f\rangle=e^{i\alpha/2}\left[\cos(\alpha/2)|1\rangle-i\sin(\alpha/2)|2\rangle\right].
$$
Using the <qubit polarization> convention defined above,
$$
\boxed{\vec P_f=(0,-\sin\alpha,\cos\alpha),\qquad p_2=\sin^2(\alpha/2).}
$$
The output remains pure and has unit <Bloch vector> length. The population oscillation is the <Ramsey interferometry> fringe: the first gate supplies <quantum coherence>, and the last turns the acquired <relative quantum phase> into a measurable population difference.