Density Matrices
A density matrix is a positive operator of trace one that describes any quantum state, pure or mixed, including classical uncertainty.
Beyond the state vector
A state vector describes a perfectly known, isolated system. When there is classical uncertainty about which state was prepared, or when a subsystem is entangled with an inaccessible environment, the vector is not enough. The density matrix rho handles both cases uniformly.
Definition
For a pure state |psi>, the density matrix is the outer product rho = |psi> Any matrix with these three properties is a valid quantum state. The diagonal entries are outcome probabilities in that basis; the off-diagonal entries, called coherences, encode superposition and vanish as a state decoheres. A state is pure exactly when Tr(rho^2) = 1, equivalently when rho has a single nonzero eigenvalue equal to one. If Tr(rho^2) < 1 the state is mixed. The quantity Tr(rho^2), called purity, ranges from 1 (pure) down to 1/d for the maximally mixed state of dimension d. Under a unitary U the density matrix evolves as rho -> U rho U-dagger. The Born rule becomes prob(i) = Tr(P_i rho). Expectation of an observable A is Tr(A rho). These formulas reduce to the state-vector versions for pure states but also cover noise, making the density matrix the standard language for real hardware where noise channels act.Defining properties
Pure versus mixed
Dynamics and measurement
import numpy as np
plus = np.array([1,1])/np.sqrt(2)
rho = np.outer(plus, plus.conj())
print(np.trace(rho@rho).real) # 1.0 -> pure