Skip to content

dq.entropy_vn

entropy_vn(x: ArrayLike) -> Array

Returns the Von Neumann entropy of a ket or density matrix.

It is defined by \(S(\rho) = -\tr{\rho \ln \rho}\).

Parameters

  • x (array_like of shape (..., n, 1) or (..., n, n))

    Ket or density matrix.

Returns

(array of shape (...)) Real-valued Von Neumann entropy.

Examples

>>> rho = dq.unit(dq.fock_dm(2, 0) + dq.fock_dm(2, 1))
>>> dq.entropy_vn(rho)
Array(0.693, dtype=float32)
>>> psis = [dq.fock(16, i) for i in range(5)]
>>> dq.entropy_vn(psis).shape
(5,)