The virial expansion expresses the equation of state as PV/NkT = 1 + B₂(T)ρ + B₃(T)ρ² + ... where B_n(T) are temperature-dependent virial coefficients. This systematic density expansion accounts for interactions and reduces to the ideal gas law when density vanishes.
From your work with the partition function and the canonical ensemble, you know how to derive the ideal gas equation of state: Z = (V/λ³)^N/N!, leading to PV = NkT. This works because ideal-gas molecules don't interact — each molecule moves independently, and the partition function factorizes cleanly. The virial expansion is the systematic next step: a controlled perturbative expansion for a dilute gas where interactions are present but weak relative to thermal energy.
The key mathematical tool is the Mayer f-function: f_{ij} = e^{−βu(r_{ij})} − 1, where u(r) is the pair interaction potential. For non-interacting molecules, u = 0 everywhere, so f_{ij} = 0 and the ideal gas result is recovered. For interacting molecules, the cluster expansion groups contributions to the partition function by the number of correlated molecules. At low density, the dominant correction comes from pairs: the probability of three molecules being simultaneously close together is much smaller than the probability of a single pair. The second virial coefficient B₂(T) = −½ ∫ f(r) 4πr² dr is the integral of the Mayer f-function over all pair separations — a single number capturing the net effect of pairwise interactions.
The physical content of B₂(T) is transparent. For an attractive potential (the van der Waals well at intermediate range), f(r) < 0 at those distances, giving B₂ < 0. A negative B₂ means Z = PV/NkT < 1: the gas exerts less pressure than the ideal prediction because molecules attract each other and spend extra time near the walls, but more importantly because the attractive clustering reduces the effective number of independently-acting particles. For hard-sphere repulsion at short range, f(r) = −1 inside the hard core, giving a positive contribution: B₂ > 0 and Z > 1 — the gas is harder to compress than ideal because molecules exclude volume. The Boyle temperature where B₂ = 0 is where attractive and repulsive effects exactly cancel, producing approximately ideal behavior.
Higher virial coefficients B₃, B₄, ... account for three-body, four-body correlations and become significant at higher densities. The full power of the expansion appears in the connection to the van der Waals equation: expanding (P + aN²/V²)(V − Nb) = NkT in powers of density and comparing with the virial series reveals that the van der Waals constants a and b correspond directly to contributions from the Mayer f-function. The phenomenological parameters Verhulst introduced empirically to fit gas behavior are thus derived from the microscopic pair potential, completing the statistical-mechanical justification of a model that was purely empirical for decades.