qml.vn_entropy

vn_entropy(wires, log_base=None)[source]

Von Neumann entropy of the system prior to measurement.

\[S( \rho ) = -\text{Tr}( \rho \log ( \rho ))\]
Parameters
  • wires (Sequence[int] or int) – The wires of the subsystem

  • log_base (float) – Base for the logarithm.

Returns

Measurement process instance

Return type

VnEntropyMP

Example:

dev = qml.device("default.qubit", wires=2)

@qml.qnode(dev)
def circuit_entropy(x):
    qml.IsingXX(x, wires=[0, 1])
    return qml.vn_entropy(wires=[0])

Executing this QNode:

>>> circuit_entropy(np.pi/2)
0.6931472

It is also possible to get the gradient of the previous QNode:

>>> param = np.array(np.pi/4, requires_grad=True)
>>> qml.grad(circuit_entropy)(param)
tensor(0.62322524, requires_grad=True)

Note

Calculating the derivative of vn_entropy() is currently supported when using the classical backpropagation differentiation method (diff_method="backprop") with a compatible device and finite differences (diff_method="finite-diff").

Note

qml.vn_entropy can also be used to compute the entropy of entanglement between two subsystems by computing the Von Neumann entropy of either of the subsystems.

Contents

Using PennyLane

Release news

Development

API

Internals