Solution (source code)

= Solution

In the stated ordered propagation basis, a downward input is transmitted downward and reflected upward, giving the first column $(1,1)^T/\sqrt2$. An upward input is reflected downward with the opposite reflection phase and transmitted upward, giving the second column $(-1,1)^T/\sqrt2$. Therefore
$$
\boxed{B=\frac{1}{\sqrt2}\begin{pmatrix}1&-1\\1&1\end{pmatrix}.}
$$
Equal <mirror> reflection phases exchange the two directions. Choosing a phase of $\pi$ per reflection gives
$$
\boxed{M=-\begin{pmatrix}0&1\\1&0\end{pmatrix}.}
$$
Each path encounters one <mirror>, so $M$ describes both arms together, not two successive reflections of each <photon>. Changing its common phase leaves all detection <probabilities> unchanged. Direct multiplication gives $B^\dagger B=M^\dagger M=I$, so both are <unitary matrices>. They preserve the norm of a <quantum state> and hence total <probability> for these lossless optical elements.

Ideal detectors are represented by measurement matrices, but detection itself is not unitary evolution within the two traveling modes. With $e_1=(1,0)^T$ and $e_2=(0,1)^T$, the <projective measurement> operators are
$$
\boxed{P_2=e_1e_1^\dagger=\begin{pmatrix}1&0\\0&0\end{pmatrix},\qquad
P_1=e_2e_2^\dagger=\begin{pmatrix}0&0\\0&1\end{pmatrix}.}
$$
They give <Born rule> <probabilities> $\langle\psi|P_j|\psi\rangle$ and sum to $I$. An absorbing detector maps the incident <photon> to an excited detector and vacuum field; a complete physical description includes those additional degrees of freedom.