Entanglement Entropy: Measuring Correlations in a Quantum Pair

Entanglement Entropy: Measuring Correlations in a Quantum Pair

For a pure pair, the entropy of one qubit's reduced state tells how entangled it is. A short NumPy example computes it by tracing out the partner.

A pair of qubits can be entangled even when neither qubit, examined alone, looks like a pure state. Entanglement entropy gives us a compact way to measure this for a pure joint state. The purity condition matters, because the same entropy can also come from ordinary uncertainty when the joint state is mixed.

Keep one qubit and trace out the other

Start with a pure two-qubit state |ψ>. Its density matrix is ρ_AB = |ψ><ψ|. To describe only qubit A, take the partial trace over qubit B: ρ_A = Tr_B(ρ_AB). This operation removes the partner from the description while preserving every measurement prediction that can be made on A alone.

The von Neumann entropy of A is S(ρ_A) = -Tr(ρ_A log₂ ρ_A). If the eigenvalues of ρ_A are λᵢ, the calculation becomes -Σ λᵢ log₂(λᵢ), with zero eigenvalues contributing zero. For a pure two-qubit state, this value is the entanglement entropy between A and B.

A Bell pair gives one bit

Consider |ψ> = (|00> + |11>)/√2. The pair as a whole is in a pure state, but after tracing out either qubit the remaining density matrix is I/2. Its eigenvalues are 1/2 and 1/2, so S(ρ_A) = 1 bit. One bit is the maximum entropy a single qubit can have.

By contrast, the product state |00> leaves qubit A in |0><0|. Its eigenvalues are 1 and 0, so its entropy is zero. In this pure-state comparison, the Bell pair has one bit of entanglement and the product pair has none.

Calculate it with NumPy

The code below expects a normalized two-qubit statevector in the basis order |00>, |01>, |10>, |11>. It forms the joint density matrix, traces out the second tensor factor, and computes the entropy from the reduced matrix eigenvalues.

import numpy as np

def entropy_of_first_qubit(state):
    rho_ab = np.outer(state, state.conj()).reshape(2, 2, 2, 2)
    rho_a = np.trace(rho_ab, axis1=1, axis2=3)
    eigenvalues = np.linalg.eigvalsh(rho_a)
    eigenvalues = eigenvalues[eigenvalues > 1e-12]
    value = -np.sum(eigenvalues * np.log2(eigenvalues))
    return max(0.0, float(value))

bell = np.array([1, 0, 0, 1], dtype=complex) / np.sqrt(2)
product = np.array([1, 0, 0, 0], dtype=complex)

print(entropy_of_first_qubit(bell))     # 1.0
print(entropy_of_first_qubit(product))  # 0.0

eigvalsh is appropriate because a density matrix is Hermitian. The small threshold drops tiny numerical values near zero, which otherwise cause problems in log2. The example is intentionally small so you can inspect the partial trace instead of treating entropy as a black-box score.

One final caution: for a mixed joint state, the entropy of A can reflect classical uncertainty as well as entanglement. So S(ρ_A) alone is not a general entanglement measure for mixed states. For a pure bipartite state, though, it gives a direct and useful answer to the question: how strongly is this qubit entangled with the rest?