state_fidelity¶
- state_fidelity(state1, state2, validate=True)[source]¶
Return the state fidelity between two quantum states.
The state fidelity \(F\) for density matrix input states \(\rho_1, \rho_2\) is given by
\[F(\rho_1, \rho_2) = Tr[\sqrt{\sqrt{\rho_1}\rho_2\sqrt{\rho_1}}]^2.\]If one of the states is a pure state this simplies to \(F(\rho_1, \rho_2) = \langle\psi_1|\rho_2|\psi_1\rangle\), where \(\rho_1 = |\psi_1\rangle\!\langle\psi_1|\).
- Parameters
state1 (Statevector or DensityMatrix) – the first quantum state.
state2 (Statevector or DensityMatrix) – the second quantum state.
validate (bool) – check if the inputs are valid quantum states [Default: True]
- Returns
The state fidelity \(F(\rho_1, \rho_2)\).
- Return type
float
- Raises
QiskitError – if
validate=True
and the inputs are invalid quantum states.