Solution (source code)

= Solution

A <basic measurement> is specified by an <orthonormal basis> $\{|b_j\rangle\}_{j=0}^{d-1}$, with outcome $j$ associated with the rank-one <orthogonal projection> $P_j=|b_j\rangle\langle b_j|$. For a normalized <pure state> $|\psi\rangle$, the <Born rule> gives
$$
\boxed{p(j)=\langle\psi|P_j|\psi\rangle=|\langle b_j|\psi\rangle|^2.}
$$
The <probabilities> sum to one because $\sum_jP_j=I$. Conditional on an outcome with $p(j)>0$, the <post-measurement state> is
$$
\boxed{\frac{P_j|\psi\rangle}{\sqrt{p(j)}}=\frac{\langle b_j|\psi\rangle}{|\langle b_j|\psi\rangle|}|b_j\rangle,}
$$
which represents $|b_j\rangle$ up to a <global phase>. An outcome of zero <probability> has no conditional state to normalize. For a <density matrix> $\rho$, the corresponding expressions are $p(j)=\operatorname{Tr}(P_j\rho)$ and $P_j\rho P_j/p(j)$. If the outcome is ignored, the <nonselective projective measurement> instead produces $\sum_jP_j\rho P_j$, generally a <mixed state>.<The Theory of Quantum Information by John Watrous/Basic notions of quantum information>[§2.3, Definition 2.34 and the outcome-probability rule; specialize to rank-one orthogonal projections]{ref}