Skip to main contentIBM Quantum Documentation
This page is from an old version of Qiskit SDK and does not exist in the latest version. We recommend you migrate to the latest version. See the release notes for more information.

qiskit.quantum_info.state_fidelity

state_fidelity(state1, state2, validate=True)

GitHub

Return the state fidelity between two quantum states.

The state fidelity FF for density matrix input states ρ1,ρ2\rho_1, \rho_2 is given by

F(ρ1,ρ2)=Tr[ρ1ρ2ρ1]2.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 simplifies to F(ρ1,ρ2)=ψ1ρ2ψ1F(\rho_1, \rho_2) = \langle\psi_1|\rho_2|\psi_1\rangle, where ρ1=ψ1 ⁣ψ1\rho_1 = |\psi_1\rangle\!\langle\psi_1|.

Parameters

Returns

The state fidelity F(ρ1,ρ2)F(\rho_1, \rho_2).

Return type

float

Raises

QiskitError – if validate=True and the inputs are invalid quantum states.

Was this page helpful?
Report a bug or request content on GitHub.