Solution (source code)

= Solution

Apply a <Hadamard gate> before a Z-basis <quantum measurement>[measurement]: $H|+\rangle=|0\rangle$ and $H|-\rangle=|1\rangle$. The result <probabilities> are
$$
\boxed{p_+=\frac{|\alpha+\beta|^2}{2},\qquad
p_-=\frac{|\alpha-\beta|^2}{2}.}
$$
For <quantum measurement>[measurement] statistics the network is $H$ followed by $M_Z$. If the measured <qubit> survives and should be left in the original X <eigenstate>, append a second $H$ after the nondestructive $M_Z$. The resulting instrument has <Kraus operators> $HP_0H=|+\rangle\langle+|$ and $HP_1H=|-\rangle\langle-|$, not Z-eigenstate outputs.

\Image[/past-exam-of-the-laser-science-and-quantum-information-processing-course-of-the-university-of-oxford/2019-quantum-networks.png]
{title=Original networks for X measurement, a controlled swap, two-query parity testing, and the simplified Deutsch circuit}
{description=Time runs left to right. Filled controls and circled targets denote computational-basis controlled-NOT operations. In the last network $a=f(0)$ and $b=f(0)\oplus f(1)$; powers zero omit a gate.}