43 lines
1.7 KiB
Plaintext
43 lines
1.7 KiB
Plaintext
---
|
||
title: state_fidelity (v0.26)
|
||
description: API reference for qiskit.quantum_info.state_fidelity in qiskit v0.26
|
||
in_page_toc_min_heading_level: 1
|
||
python_api_type: function
|
||
python_api_name: qiskit.quantum_info.state_fidelity
|
||
---
|
||
|
||
<span id="qiskit-quantum-info-state-fidelity" />
|
||
|
||
# qiskit.quantum\_info.state\_fidelity
|
||
|
||
<Function id="qiskit.quantum_info.state_fidelity" isDedicatedPage={true} github="https://github.com/qiskit/qiskit/tree/stable/0.17/qiskit/quantum_info/states/measures.py" signature="state_fidelity(state1, state2, validate=True)">
|
||
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 simplifies 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*](qiskit.quantum_info.Statevector "qiskit.quantum_info.Statevector") *or*[*DensityMatrix*](qiskit.quantum_info.DensityMatrix "qiskit.quantum_info.DensityMatrix")) – the first quantum state.
|
||
* **state2** ([*Statevector*](qiskit.quantum_info.Statevector "qiskit.quantum_info.Statevector") *or*[*DensityMatrix*](qiskit.quantum_info.DensityMatrix "qiskit.quantum_info.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.
|
||
</Function>
|
||
|