Skip to content

is_product

Checks if a quantum state is product state.

is_product

is_product(
    rho: ndarray,
    dim: int | list[int] | ndarray | None = None,
) -> tuple

Determine if a given vector is a product state 1.

If the input is deemed to be product, then the product decomposition is also returned.

Parameters:

  • rho (ndarray) –

    The vector or matrix to check.

  • dim (int | list[int] | ndarray | None, default: None ) –

    The dimension of the input.

Returns:

  • tuple

    True if rho is a product vector and False otherwise.

Examples:

Consider the following Bell state

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

The corresponding density matrix of \(u\) may be calculated by:

\[ \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} \in \text{D}(\mathcal{X}). \]

We can provide the input as either the vector \(u\) or the denisty matrix \(\rho\). In either case, this represents an entangled state (and hence a non-product state).

from toqito.state_props import is_product
from toqito.states import bell
rho = bell(0) @ bell(0).conj().T
u_vec = bell(0)
print(is_product(rho))
(array([False]), None)
print(is_product(u_vec))
(array([False]), None)

References

1 Wikipedia. Separable state. link.

Source code in toqito/state_props/is_product.py
def is_product(rho: np.ndarray, dim: int | list[int] | np.ndarray | None = None) -> tuple:
    r"""Determine if a given vector is a product state [@wikipediaseparable].

    If the input is deemed to be product, then the product decomposition is also
    returned.

    Args:
        rho: The vector or matrix to check.
        dim: The dimension of the input.

    Returns:
        `True` if `rho` is a product vector and `False` otherwise.

    Examples:
        Consider the following Bell state

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

        The corresponding density matrix of \(u\) may be calculated by:

        \[
            \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} \in \text{D}(\mathcal{X}).
        \]

        We can provide the input as either the vector \(u\) or the denisty matrix \(\rho\).
        In either case, this represents an entangled state (and hence a non-product state).

        ```python exec="1" source="above" result="text" session="is_product_example"
        from toqito.state_props import is_product
        from toqito.states import bell
        rho = bell(0) @ bell(0).conj().T
        u_vec = bell(0)
        print(is_product(rho))
        ```

        ```python exec="1" source="above" result="text" session="is_product_example"
        print(is_product(u_vec))
        ```

    """
    return _is_product(rho, dim)