symop.ccr.algebra.density.normalize_trace

Trace normalization for symbolic density polynomials.

This module provides a helper that rescales a density polynomial so that its trace equals one.

Given a density polynomial \(\rho\), we compute \(\mathrm{Tr}(\rho)\) symbolically and return

\[\rho' = \frac{1}{\mathrm{Tr}(\rho)}\,\rho,\]

whenever \(|\mathrm{Tr}(\rho)|\) is not too small.

Functions

density_normalize_trace(terms, *[, eps])

Scale a density polynomial so that its trace equals 1.

density_normalize_trace(terms: tuple[DensityTerm, ...], *, eps: float = 1e-14) tuple[DensityTerm, ...]

Scale a density polynomial so that its trace equals 1.

This function computes \(\mathrm{Tr}(\rho)\) via density_trace() and returns \(\rho' = \rho / \mathrm{Tr}(\rho)\). If \(|\mathrm{Tr}(\rho)| < \text{eps}\), a ValueError is raised.

Mathematically,

\[\rho' \;=\; \frac{1}{\mathrm{Tr}(\rho)} \, \rho, \qquad \mathrm{Tr}(\rho') \;=\; 1.\]
Parameters:
  • terms (tuple[DensityTerm, ...]) – Input density polynomial \(\rho\).

  • eps (float) – Minimum absolute threshold for \(|\mathrm{Tr}(\rho)|\). If the trace magnitude is smaller than eps, normalization is refused.

Returns:

The scaled density polynomial with unit trace.

Return type:

tuple[DensityTerm, …]

Raises:

ValueError – If \(|\mathrm{Tr}(\rho)| < \text{eps}\).

Notes

  • Scaling is performed by density_scale() with factor \(1/\mathrm{Tr}(\rho)\).

  • Works with complex traces; no assumption of Hermiticity is required.