# Implementation of filter operation

If I want to implement the measurement operation corresponding to filtering, i.e. $$M_1=\left(\begin{array}{cc}1 & 0 \\ 0 & \alpha \end{array}\right)\qquad M_2=\left(\begin{array}{cc}0 & 0 \\ 0 & \sqrt{1-\alpha^2} \end{array}\right),$$ how would I do that?

In this case, define a unitary $$U$$ such that $$U|0\rangle=\alpha|0\rangle+\sqrt{1-\alpha^2}|1\rangle.$$ Take the qubit that we want to measure, and introduce an ancilla in the state $$|0\rangle$$. Apply controlled-$$U$$ controlled from your qubit to be measured, and targeting the ancilla. Finally, perform a standard, $$Z$$, measurement on the ancilla qubit. Answers 0 and 1 correspond to implementing $$M_1$$ and $$M_2$$ respectively.
To see this explicitly, consider the possible inputs of $$|0\rangle$$ and $$1\rangle$$. Everything else will follow by linearity. $$|0\rangle|0\rangle\mapsto |0\rangle|0\rangle\qquad |1\rangle|0\rangle\mapsto |1\rangle(\alpha|0\rangle+\sqrt{1-\alpha^2}|1\rangle).$$ So, input $$|0\rangle$$ always returns $$|0\rangle$$ (good since $$M_1|0\rangle=|0\rangle$$ and $$M_2|0\rangle=0$$), while $$|1\rangle$$ returns either $$M_1|1\rangle$$ or $$M_2\rangle$$ depending on the measurement result.