Purity of a density operator (source code)

= Purity of a density operator

The purity of a density operator is $\operatorname{Tr}(\rho^2)$. It equals one exactly for a pure state; in finite dimension $d$ it lies between $1/d$ and $1$.