Solution (source code)

= Solution

A <density matrix> is a complex $d\times d$ <Hermitian matrix> that is <positive semidefinite> and has unit <trace>:
$$
\boxed{\rho=\rho^\dagger,\qquad v^\dagger\rho v\geq0\ \text{for every }v\in\mathbb C^d,\qquad\operatorname{Tr}\rho=1.}
$$
Equivalently, its <eigenvalues> are nonnegative and sum to one, with an <orthonormal basis> of <eigenvectors>.<The Theory of Quantum Information by John Watrous/Mathematical preliminaries>[§1.1.2, printed pp. 17–18, equations (1.94)–(1.97)]{ref}