qiskit-documentation/docs/api/qiskit/0.31/qiskit.quantum_info.purity.mdx

40 lines
1.1 KiB
Plaintext
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
title: purity (v0.31)
description: API reference for qiskit.quantum_info.purity in qiskit v0.31
in_page_toc_min_heading_level: 1
python_api_type: function
python_api_name: qiskit.quantum_info.purity
---
<span id="qiskit-quantum-info-purity" />
# qiskit.quantum\_info.purity
<Function id="qiskit.quantum_info.purity" isDedicatedPage={true} github="https://github.com/qiskit/qiskit/tree/stable/0.18/qiskit/quantum_info/states/measures.py" signature="purity(state, validate=True)">
Calculate the purity of a quantum state.
The purity of a density matrix $\rho$ is
$$
\text{Purity}(\rho) = Tr[\rho^2]
$$
**Parameters**
* **state** ([*Statevector*](qiskit.quantum_info.Statevector "qiskit.quantum_info.Statevector") *or*[*DensityMatrix*](qiskit.quantum_info.DensityMatrix "qiskit.quantum_info.DensityMatrix")) a quantum state.
* **validate** (*bool*) check if input state is valid \[Default: True]
**Returns**
the purity $Tr[\rho^2]$.
**Return type**
float
**Raises**
**QiskitError** if the input isnt a valid quantum state.
</Function>