# qml.math.vn_entropy¶

vn_entropy(state, indices, base=None, check_state=False, c_dtype='complex128')[source]

Compute the Von Neumann entropy from a state vector or density matrix on a given subsystem. It supports all interfaces (Numpy, Autograd, Torch, Tensorflow and Jax).

$S( \rho ) = -\text{Tr}( \rho \log ( \rho ))$
Parameters
• state (tensor_like) – (2**N) state vector or (2**N, 2**N) density matrix.

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

• base (float) – Base for the logarithm. If None, the natural logarithm is used.

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

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

Returns

Von Neumann entropy of the considered subsystem.

Return type

float

Example

The entropy of a subsystem for any state vectors can be obtained. Here is an example for the maximally entangled state, where the subsystem entropy is maximal (default base for log is exponential).

>>> x = [1, 0, 0, 1] / np.sqrt(2)
>>> vn_entropy(x, indices=[0])
0.6931472


The logarithm base can be switched to 2 for example.

>>> vn_entropy(x, indices=[0], base=2)
1.0


The entropy can be obtained by providing a quantum state as a density matrix, for example:

>>> y = [[1/2, 0, 0, 1/2], [0, 0, 0, 0], [0, 0, 0, 0], [1/2, 0, 0, 1/2]]
>>> vn_entropy(y, indices=[0])
0.6931472