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\) of the system to be reduced. Can be a single square matrix or a batch of matrices with dimension
(..., 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 dimensiond
is equal to the system dimensionD
divided by the product of the traced out subsystem dimensions.- Return type:
Notes
Given a density matrix \(\rho\) of two subsystems \(A\) and \(B\), the partial trace over subsystem \(B\) is defined as
\[({\mathrm{Tr}_{B}} \rho)_{ij} = \sum_k \rho_{ik,jk}.\]For more information about the partial trace, see partial trace on Wikipedia.
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 = qctrl.functions.calculate_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="partial") <Tensor: name="partial", operation_name="partial_trace", shape=(2, 2)> >>> result = qctrl.functions.calculate_graph(graph=graph, output_node_names=["partial"]) >>> result.output["partial"]["value"] array([[[0.5, 0], [0, 0.5]])
See more examples in the How to simulate large open system dynamics user guide.