state_metrics.fidelity¶
Fidelity is a metric that qualifies how close two quantum states are.
Functions¶
Module Contents¶
- state_metrics.fidelity.fidelity(rho, sigma)¶
Compute the fidelity of two density matrices [1].
Calculate the fidelity between the two density matrices
rho
andsigma
, defined by:\[||\sqrt(\rho) \sqrt(\sigma)||_1,\]where \(|| \cdot ||_1\) denotes the trace norm. The return is a value between \(0\) and \(1\), with \(0\) corresponding to matrices
rho
andsigma
with orthogonal support, and \(1\) corresponding to the caserho = sigma
.Examples
Consider the following Bell state
\[u = \frac{1}{\sqrt{2}} \left( |00 \rangle + |11 \rangle \right) \in \mathcal{X}.\]The corresponding density matrix of \(u\) may be calculated by:
\[\begin{split}\rho = u u^* = \frac{1}{2} \begin{pmatrix} 1 & 0 & 0 & 1 \\ 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 \\ 1 & 0 & 0 & 1 \end{pmatrix} \in \text{D}(\mathcal{X}).\end{split}\]In the event where we calculate the fidelity between states that are identical, we should obtain the value of \(1\). This can be observed in
toqito
as follows.>>> from toqito.state_metrics import fidelity >>> import numpy as np >>> rho = 1 / 2 * np.array( ... [[1, 0, 0, 1], ... [0, 0, 0, 0], ... [0, 0, 0, 0], ... [1, 0, 0, 1]] ... ) >>> sigma = rho >>> fidelity(rho, sigma) np.float64(1.0000000000000002)
References
[1] (1,2)Wikipedia. Fidelity of quantum states. URL: https://en.wikipedia.org/wiki/Fidelity_of_quantum_states.
- Raises:
ValueError – If matrices are not density operators.
- Parameters:
rho (numpy.ndarray) – Density operator.
sigma (numpy.ndarray) – Density operator.
- Returns:
The fidelity between
rho
andsigma
.- Return type:
float