A density matrix is used in quantum theory to describe the statistical state of a quantum system. It is the quantum-mechanical analogue to a phase-space density (probability distribution of position and momentum) in classical statistical mechanics. The need for a description via the density matrix arises whenever the exact quantum-mechanical state of the system (i.e. its wavefunction) is not known. Then only the probability of the system being in a certain state can be given, which is accomplished by the density matrix. In such a case, the system is said to be in a mixed state, while otherwise it is in a pure state.

Typical situations in which a density matrix is needed include: a quantum system in thermal equilibrium (at finite temperatures), nonequilibrium time-evolution that starts out of a mixed equilibrium state, and entanglement between two subsystems, where each individual system must be described by a density matrix even though the complete system may be in a pure state.

The density matrix (commonly designated by ρ) is an operator acting on the Hilbert space of the system in question. For the special case of a pure state, it is given by the projection operator of this state. For a mixed state, where the system is in the quantum-mechanical state |ψj⟩ with probability pj, the density matrix is the sum of the projectors, weighted with the appropriate probabilities (see bra-ket notation):

ρ = ∑j pjj⟩⟨ψj|

The density matrix is used to calculate the expectation value of any operator A of the system, averaged over the different states |ψj⟩. This is done by taking the trace of the product of ρ and A:

tr[ρ A]=∑j pj ⟨ψj|A|ψj

The probabilities pj are nonnegative and normalized (i.e. their sum gives one). For the density matrix, this means that ρ is a positive semidefinite hermitian operator (its eigenvalues are nonnegative) and the trace of ρ (the sum of its eigenvalues) is equal to one.