What the Two Halves Share

von Neumann entropy · mutual information · partial trace · eigenvalues · numpy

Two labs each hold part of an n-qubit register whose joint state is the 2^n \times 2^n density matrix rho (a list of rows). Part A is qubits 0, \dots, m-1 and part B is qubits m, \dots, n-1. Basis state |b_0 \dots b_{n-1}\rangle has index int("b0b1...", 2): qubit 0 is the leftmost bit (in 3 qubits, |011\rangle is index 3), so every index is i = a \cdot d_B + b, where a is the number formed by the bits of A, b that of B, and d_A = 2^m, d_B = 2^{n-m}. The reduced density matrices of the parts are

(\rho_A)_{a a'} = \sum_{b} \rho_{a d_B + b,\; a' d_B + b}, \qquad (\rho_B)_{b b'} = \sum_{a} \rho_{a d_B + b,\; a d_B + b'}.

The von Neumann entropy of a density matrix with eigenvalues \lambda_1, \lambda_2, \dots is

S(\rho) = -\sum_{\lambda_k > 10^{-12}} \lambda_k \log_2 \lambda_k,

counted in bits: eigenvalues of at most 10^{-12} (zeros, and rounding dust that may even be slightly negative) are left out, which is the rule 0 \log 0 = 0. A pure state has S = 0; the maximally mixed state of k qubits has S = k. The mutual information of the cut,

I(A{:}B) = S(\rho_A) + S(\rho_B) - S(\rho),

says how much the two parts know about each other. It is 0 for a product \rho_A \otimes \rho_B; on two qubits it reaches 2 bits for a maximally entangled pure state, while correlations that a shared coin flip could create give at most 1 bit.

This problem is the one where numpy is the tool: np.linalg.eigvalsh(M) returns the (real) eigenvalues of a Hermitian matrix M.

Write shared_information(rho, m) that returns the tuple (S_A, S_B, S_AB, I) of four real numbers: S(\rho_A), S(\rho_B), S(\rho) and I(A{:}B).

Examples

Input:  rho = [[0.5, 0, 0, 0.5], [0, 0, 0, 0], [0, 0, 0, 0], [0.5, 0, 0, 0.5]], m = 1
Output: (1.0, 1.0, 0.0, 2.0)
Explanation: the Bell state (|00> + |11>)/sqrt(2): pure, yet each half is I/2.

Input:  rho = [[0.5, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0.5]], m = 1
Output: (1.0, 1.0, 1.0, 1.0)
Explanation: a fair coin decides between |00> and |11>: one bit of shared randomness.

Input:  rho = [[0.25, 0, 0, 0.25, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0],
               [0, 0, 0, 0, 0, 0, 0, 0], [0.25, 0, 0, 0.25, 0, 0, 0, 0],
               [0, 0, 0, 0, 0.25, 0, 0, 0.25], [0, 0, 0, 0, 0, 0, 0, 0],
               [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0.25, 0, 0, 0.25]], m = 1
Output: (1.0, 0.0, 1.0, 0.0)
Explanation: qubit 0 is a fair coin on its own, and qubits 1 and 2 hold the Bell
state (|00> + |11>)/sqrt(2): part B is pure, and nothing crosses the cut.

Constraints

  • 2 to 6 qubits; 1 <= m <= n - 1; rho is a density matrix (Hermitian, trace 1, no negative eigenvalues).
  • Each number is compared with a tolerance of 1e-6 (an entropy of -4e-16 counts as 0.0).

Goals

  • Compute the von Neumann entropy of a density matrix from its eigenvalues
  • Take partial traces of a mixed state over a cut of the register
  • Combine the entropies into the mutual information of the two parts
Starting Python…