qml.math.reduced_dm

reduced_dm(state, indices, check_state=False, c_dtype='complex128')[source]

Compute the reduced density matrix from a state vector or a density matrix. It supports all interfaces (Numpy, Autograd, Torch, Tensorflow and Jax).

Parameters
  • state (tensor_like) – (2**N) state vector or (2**N, 2**N) density matrix.

  • indices (Sequence(int)) – List of indices in the considered subsystem.

  • check_state (bool) – If True, the function will check the state validity (shape and norm).

  • c_dtype (str) – Complex floating point precision type.

Returns

Reduced density matrix of size (2**len(indices), 2**len(indices))

Return type

tensor_like

Example

>>> x = [1, 0, 1, 0] / np.sqrt(2)
>>> reduced_dm(x, indices=[0])
[[0.5+0.j 0.5+0.j]
 [0.5+0.j 0.5+0.j]]
>>> reduced_dm(x, indices=[1])
[[1.+0.j 0.+0.j]
 [0.+0.j 0.+0.j]]
>>> y = tf.Variable([1, 0, 0, 0], dtype=tf.complex128)
>>> reduced_dm(y, indices=[1])
tf.Tensor(
[[1.+0.j 0.+0.j]
 [0.+0.j 0.+0.j]], shape=(2, 2), dtype=complex128)
>>> z = [[0.5, 0, 0.0, 0.5], [0, 0, 0, 0], [0, 0, 0, 0], [0.5, 0, 0, 0.5]]
>>> reduced_dm(z, indices=[0])
[[0.5+0.j 0.0+0.j]
 [0.0+0.j 0.5+0.j]]
>>> reduced_dm(z, indices=[1])
[[1.+0.j 0.+0.j]
 [0.+0.j 0.+0.j]]
>>> y_mat_tf = tf.Variable([[1, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]], dtype=tf.complex128)
>>> reduced_dm(y_mat_tf, indices=[1])
tf.Tensor(
[[1.+0.j 0.+0.j]
 [0.+0.j 0.+0.j]], shape=(2, 2), dtype=complex128)