Site Tools


qutip-partial-trace

Partial Trace

Partial trace computes the reduced density matrix of a subsystem by tracing out others. For a composite system $AB$, the reduced state is $\rho_A = \text{Tr}_B(\rho_{AB})$.

Partial trace is essential for analyzing entanglement and correlations in multi-qubit systems. It removes information about one subsystem, leaving only the observable statistics of the other.

from qutip import *
 
# Two-qubit system: Bell state (|00⟩ + |11⟩)/√2
psi = (tensor(basis(2, 0), basis(2, 0)) + 
       tensor(basis(2, 1), basis(2, 1))).unit()
rho = psi * psi.dag()
 
# Full density matrix: 4×4
print(rho.dims)  # [[2, 2], [2, 2]]
 
# Trace out qubit 1, get qubit 0's reduced state
rho_0 = ptrace(rho, 0)
print(rho_0.dims)  # [[2], [2]]
 
# Trace out qubit 0, get qubit 1's reduced state
rho_1 = ptrace(rho, 1)
 
# Both are maximally mixed (no information about individual qubit)
print(rho_0)  # I/2

Multi-Qubit Systems

For $n$-qubit systems, use ptrace(rho, [i, j, ...]) to trace out all except qubits $i, j, \ldots$

# Three-qubit system
rho = ... # 8×8 density matrix
rho_01 = ptrace(rho, [0, 1])  # Reduce to qubits 0 and 1

Partial trace loses information—you cannot recover the full state from reduced states alone. But reduced states encode all locally observable statistics.

qutip-partial-trace.md · Last modified: by 127.0.0.1