Solution (source code)

= Solution

For two <density operators>, the <trace distance> and the unsquared <quantum fidelity> are
$$
\boxed{D(\rho,\sigma)=\frac12\|\rho-\sigma\|_1,\qquad F(\rho,\sigma)=\operatorname{Tr}\sqrt{\sqrt\rho\,\sigma\sqrt\rho}=\|\sqrt\rho\sqrt\sigma\|_1.}
$$
The unsquared convention matters: if $P=|\psi\rangle\langle\psi|$ is a <pure state>, then $\sqrt\rho P\sqrt\rho$ is a rank-one <positive operator> with its sole nonzero <eigenvalue> equal to $\langle\psi|\rho|\psi\rangle$. Hence
$$
\boxed{F(\rho,P)^2=\langle\psi|\rho|\psi\rangle.}
$$