# partial_trace

Graph.partial_trace(density_matrix, subsystem_dimensions, traced_subsystems, *, name=None)

Calculate the partial trace of a density matrix.

### Parameters

• density_matrix (np.ndarray or Tensor) – The density matrix $\rho$(..., D, D).
• subsystem_dimensions (list [ int ]) – The dimension of each subsystem. The product of the subsystem dimensions is the dimension of the system D.
• traced_subsystems (int or list [ int ]) – The indices (starting from zero) of the subsystems to be traced out. Each index refers to a different subsystem.
• name (str or None , optional) – The name of the node.

### Returns

The reduced density matrix of shape (..., d, d). The reduced dimension d is equal to the system dimension D divided by the product of the traced out subsystem dimensions.

Tensor

## Notes

Given a density matrix $\rho$ of two subsystems $A$ and $B$, the partial trace over subsystem $B$

$({\mathrm{Tr}_{B}} \rho)_{ij} = \sum_k \rho_{ik,jk}.$

## Examples

>>> graph.partial_trace(np.diag([1, 0, 0, 0]), [2, 2], 1, name="partial")
<Tensor: name="partial", operation_name="partial_trace", shape=(2, 2)>
>>> result = bo.execute_graph(graph=graph, output_node_names="partial")
>>> result["output"]["partial"]["value"]
array([[[1, 0], [0, 0]])
>>> graph.partial_trace(np.eye(10)/10, [2, 5], 1, name="partial2")
<Tensor: name="partial2", operation_name="partial_trace", shape=(2, 2)>
>>> result = bo.execute_graph(graph=graph, output_node_names="partial2")
>>> result["output"]["partial2"]["value"]
array([[[0.5, 0], [0, 0.5]])

See more examples in the How to simulate large open system dynamics user guide.