toqito.state_metrics.hilbert_schmidt ==================================== .. py:module:: toqito.state_metrics.hilbert_schmidt .. autoapi-nested-parse:: Hilbert-Schmidt metric is a distance metric used to generate an entanglement measure. Module Contents --------------- .. py:function:: hilbert_schmidt(rho, sigma) Compute the Hilbert-Schmidt distance between two states [@WikiHilbSchOp]. The Hilbert-Schmidt distance between density operators \(\rho\) and \(\sigma\) is defined as \[ D_{\text{HS}}(\rho, \sigma) = \text{Tr}((\rho - \sigma)^2) = \left\lVert \rho - \sigma \right\rVert_2^2. \] .. rubric:: Examples One may consider taking the Hilbert-Schmidt distance between two Bell states. In `|toqito⟩`, one may accomplish this as ```python exec="1" source="above" import numpy as np from toqito.states import bell from toqito.state_metrics import hilbert_schmidt rho = bell(0) @ bell(0).conj().T sigma = bell(3) @ bell(3).conj().T print(np.around(hilbert_schmidt(rho, sigma), decimals=2)) ``` :raises ValueError: If matrices are not density operators. :param rho: An input matrix. :param sigma: An input matrix. :returns: The Hilbert-Schmidt distance between `rho` and `sigma`.