symop.ccr.algebra.density.purity

Purity of symbolic density polynomials.

The purity of a density operator is defined as

\[\mathrm{Purity}(\rho) = \mathrm{Tr}(\rho^2) = \langle \rho, \rho \rangle,\]

i.e. the Hilbert–Schmidt inner product of the density with itself.

For normalized states:

  • Pure states satisfy \(\mathrm{Tr}(\rho^2) = 1\)

  • Mixed states satisfy \(\mathrm{Tr}(\rho^2) < 1\)

This module computes purity symbolically using the density inner product.

Functions

density_purity(terms)

Compute the purity \(\mathrm{Tr}(\rho^2)\).

density_purity(terms: tuple[DensityTerm, ...]) float

Compute the purity \(\mathrm{Tr}(\rho^2)\).

Parameters:

terms (tuple[DensityTerm, ...]) – Density polynomial terms representing \(\rho\).

Returns:

The real part of \(\mathrm{Tr}(\rho^2)\).

Return type:

float

Notes

  • Computed as density_inner(terms, terms).

  • The result is returned as a real float.

  • No Hermiticity assumption is enforced here.