state_ops.pure_to_mixed

Pure to mixed operation.

Module Contents

Functions

pure_to_mixed(phi)

Convert a state vector or density matrix to a density matrix.

state_ops.pure_to_mixed.pure_to_mixed(phi)

Convert a state vector or density matrix to a density matrix.

Examples

It is possible to convert a pure state vector to a mixed state vector using the toqito package. Consider the following Bell state

\[u = \frac{1}{\sqrt{2}} \left( |00 \rangle + |11 \rangle \right).\]

The corresponding mixed state from \(u\) is calculated as

\[\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}\end{split}\]

Using toqito, we can obtain this matrix as follows.

>>> from toqito.states import bell
>>> from toqito.state_ops import pure_to_mixed
>>> phi = bell(0)
>>> pure_to_mixed(phi)
array([[0.5, 0. , 0. , 0.5],
       [0. , 0. , 0. , 0. ],
       [0. , 0. , 0. , 0. ],
       [0.5, 0. , 0. , 0.5]])

We can also give matrix inputs to the function in toqito.

>>> from toqito.states import bell
>>> from toqito.state_ops import pure_to_mixed
>>> phi = bell(0) * bell(0).conj().T
>>> pure_to_mixed(phi)
array([[0.5, 0. , 0. , 0.5],
       [0. , 0. , 0. , 0. ],
       [0. , 0. , 0. , 0. ],
       [0.5, 0. , 0. , 0.5]])
Raises:

ValueError – If matrix is not square.

Parameters:

phi (numpy.ndarray) – A density matrix or a pure state vector.

Returns:

density matrix representation of phi, regardless of whether phi is itself already a density matrix or if if is a pure state vector.

Return type:

numpy.ndarray