Two stations share a pair of qubits. Each station holds only its own qubit: what does it hold? The answer is a one-qubit density matrix, the reduced density matrix, obtained from the two-qubit \rho by the partial trace over the other qubit.
rho is a 4 \times 4 density matrix (a list of rows) of two qubits. Basis state |ab\rangle has index 2a + b: qubit 0 is the leftmost bit a, qubit 1 is the rightmost bit b (so |01\rangle is index 1 and |10\rangle is index 2). The reduced matrices are
To keep qubit 0 you add up the entries where qubit 1 has the same value in the row and the column, and the other way round.
Write reduce_pair(rho, keep) that returns the 2 \times 2 reduced density matrix of qubit keep (0 or 1) as a list of rows.
Examples
Input: rho = [[0.5, 0, 0, 0.5], [0, 0, 0, 0], [0, 0, 0, 0], [0.5, 0, 0, 0.5]], keep = 0
Output: [[0.5, 0], [0, 0.5]]
Explanation: rho is the Bell state (|00> + |11>)/sqrt(2). Each half alone is I/2.
Input: rho = [[0.5, 0.5, 0, 0], [0.5, 0.5, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]], keep = 0
Output: [[1, 0], [0, 0]]
Explanation: rho is |0> (qubit 0) times |+> (qubit 1): qubit 0 is |0>.
Input: rho = [[0.5, 0.5, 0, 0], [0.5, 0.5, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]], keep = 1
Output: [[0.5, 0.5], [0.5, 0.5]]
Explanation: and qubit 1 is |+><+|.
Entries may be ints, floats or complex numbers; each is compared with a tolerance of 1e-6.
Goals
- Compute the reduced density matrix of one qubit of a two-qubit density matrix
- Use the bit order (qubit 0 is the leftmost bit) to pick the right entries
- See that one half of a Bell pair, on its own, is the maximally mixed state