Physics
Universitystatistical-mechanics

The Boltzmann Distribution and Partition Function

What happens to 'every microstate is equally likely' once a system can trade energy with the outside world — and the single function, built from nothing but a sum of exponentials, that ends up encoding all of its thermodynamics.

Before this, you should know:

The previous topic built its entire argument on one clean assumption: every microstate of an isolated system is equally probable. But almost nothing you'd actually want to study is isolated. A cup of coffee sits in a room full of air; a single atom sits inside a crystal lattice; a gas molecule sits among 102310^{23} others. Each of these is a small system embedded in a much larger one, constantly trading energy back and forth with its surroundings through collisions and radiation. The moment a system can trade energy, "every microstate equally likely" stops being the right statement — a microstate with enormous energy costs the rest of the universe something to supply, and it is not obviously as easy to arrange as a low-energy one.

So the question sharpens: if a small system is in thermal contact with a much larger reservoir, what is the probability of finding the system in one particular microstate of energy EE? This is not an idle generalization — the answer is arguably the single most useful formula in all of statistical physics, and it falls out of exactly the same counting argument as before, just applied one level up.

Setting up system and reservoir

Let the small system SS (the one we care about) sit in thermal contact with a much larger reservoir RR. Together they're isolated from everything else, so their combined energy Etotal=ES+ERE_{\text{total}} = E_S + E_R is fixed. Crucially, RR is enormous compared to SS — think of a single atom sitting in a block of metal containing 102310^{23} other atoms.

Ask for the probability that the system SS is found in one specific microstate ss, with energy EsE_s. Since we're asking about one particular microstate of SS (not a whole macrostate of it), the only freedom left to count is how many microstates the reservoir can be in, given that it must carry whatever energy is left over, EtotalEsE_{\text{total}}-E_s. By the same equal-probability postulate from the previous topic:

P(s)ΩR(EtotalEs)P(s) \propto \Omega_R(E_{\text{total}} - E_s)

Turning a huge reservoir into an exponential

This is where the reservoir's sheer size does all the work. Take the logarithm — which is, by Boltzmann's formula, just the reservoir's entropy divided by kBk_B:

lnΩR(EtotalEs)=SR(EtotalEs)kB\ln\Omega_R(E_{\text{total}}-E_s) = \frac{S_R(E_{\text{total}}-E_s)}{k_B}

Because EsE_s is utterly tiny compared to EtotalE_{\text{total}} (one atom's energy against a whole block of metal's), expand this in a Taylor series around Es=0E_s=0 and keep only the first two terms:

SR(EtotalEs)SR(Etotal)EsSREEtotalS_R(E_{\text{total}}-E_s) \approx S_R(E_{\text{total}}) - E_s\left.\frac{\partial S_R}{\partial E}\right|_{E_{\text{total}}}

The derivative SR/E\partial S_R/\partial E is exactly the statistical definition of inverse temperature, 1/TS/E1/T \equiv \partial S/\partial E — the rate at which a system's entropy grows as you feed it energy. (This is not a new assumption pulled from nowhere: it is precisely what makes two systems in thermal equilibrium have equal TT, since equilibrium is exactly the point where entropy is maximized with respect to any energy exchanged between them, so its derivative with respect to that exchange must vanish for the two systems together — a full statement of this belongs to the laws of thermodynamics, but the definition itself is all we need here.) Since the reservoir is so large that its temperature TT doesn't budge no matter how much energy the tiny system SS borrows from it, treat TT as a fixed constant. Substituting:

SR(EtotalEs)SR(Etotal)EsTS_R(E_{\text{total}}-E_s) \approx S_R(E_{\text{total}}) - \frac{E_s}{T}

Exponentiate to get back to ΩR\Omega_R:

ΩR(EtotalEs)=exp(SR(Etotal)kBEskBT)=ΩR(Etotal)eEs/kBT\Omega_R(E_{\text{total}}-E_s) = \exp\left(\frac{S_R(E_{\text{total}})}{k_B} - \frac{E_s}{k_BT}\right) = \Omega_R(E_{\text{total}})\,e^{-E_s/k_BT}

The first factor, ΩR(Etotal)\Omega_R(E_{\text{total}}), doesn't depend on ss at all — it's swallowed into the overall normalization. What's left is the entire content of the result:

P(s)eEs/kBT\boxed{P(s) \propto e^{-E_s/k_BT}}

This is the Boltzmann distribution. A microstate's probability falls off exponentially with its energy, with the reservoir's temperature setting exactly how fast. High-energy microstates aren't forbidden — they're simply exponentially rarer, because supplying them costs the reservoir entropy it would rather keep.

Left panel: a small box labeled system S in contact with a much larger box labeled reservoir R, with double-headed arrows between them representing constant energy exchange, and the reservoir's size drawn many times larger to indicate it can supply or absorb energy without its own temperature changing. Right panel: a bar chart of energy levels E0 through E4 on the horizontal axis, with bar heights decaying exponentially, illustrating that higher-energy microstates are exponentially less populated according to the Boltzmann factor.

A tiny system borrowing energy from a vast reservoir pays an exponential price in probability for every extra bit of energy it takes — the Boltzmann factor made visible.

The partition function

To turn the proportionality into an actual probability, normalize by summing over every accessible microstate ss of the system:

P(s)=eEs/kBTZ,ZseEs/kBTP(s) = \frac{e^{-E_s/k_BT}}{Z}, \qquad Z \equiv \sum_s e^{-E_s/k_BT}

ZZ, the partition function, is nothing more than the normalizing sum — but don't let that modest description fool you. It is common notational practice to write β1/kBT\beta \equiv 1/k_BT, so that Z(β)=seβEsZ(\beta) = \sum_s e^{-\beta E_s}. Once you have ZZ as a function of β\beta, essentially every thermodynamic quantity you might want falls out of it by straightforward differentiation, with no further physics required.

Average energy, for instance: by definition, E=sEsP(s)=1ZsEseβEs\langle E\rangle = \sum_s E_s P(s) = \frac{1}{Z}\sum_s E_s\,e^{-\beta E_s}. Notice that /β-\partial/\partial\beta applied to a single term eβEse^{-\beta E_s} pulls down exactly a factor of EsE_s:

βeβEs=EseβEs-\frac{\partial}{\partial\beta}e^{-\beta E_s} = E_s\,e^{-\beta E_s}

so summing over ss:

Zβ=sEseβEs=ZE-\frac{\partial Z}{\partial\beta} = \sum_s E_s\,e^{-\beta E_s} = Z\langle E\rangle

giving the compact and extremely useful identity:

E=1ZZβ=lnZβ\langle E\rangle = -\frac{1}{Z}\frac{\partial Z}{\partial \beta} = -\frac{\partial \ln Z}{\partial\beta}

A single derivative of a single function reproduces the average energy of the entire system, without ever summing EsP(s)E_s P(s) directly again. This is the pattern that makes ZZ so central to the whole subject: variance in energy, heat capacity, and (as a later topic will show explicitly) the Helmholtz free energy itself are all obtainable from ZZ by further differentiation, without solving the underlying probability sum from scratch each time.

Worked example

Find the partition function and average energy for (a) a two-level system with energies 00 and ε\varepsilon, and (b) the quantum harmonic oscillator with energy levels En=ω(n+12)E_n = \hbar\omega(n+\tfrac12). (click to reveal the solution)

(a) Two-level system. The system has exactly two accessible microstates, with energies E0=0E_0=0 and E1=εE_1=\varepsilon. The partition function is just the two-term sum:

Z=eβ(0)+eβε=1+eβεZ = e^{-\beta(0)} + e^{-\beta\varepsilon} = 1+e^{-\beta\varepsilon}

The average energy, using the derivative identity:

E=lnZβ=11+eβε(εeβε)=εeβε1+eβε=εeβε+1\langle E\rangle = -\frac{\partial\ln Z}{\partial\beta} = -\frac{1}{1+e^{-\beta\varepsilon}}\cdot\left(-\varepsilon e^{-\beta\varepsilon}\right) = \frac{\varepsilon e^{-\beta\varepsilon}}{1+e^{-\beta\varepsilon}} = \frac{\varepsilon}{e^{\beta\varepsilon}+1}

(the last step multiplies numerator and denominator by eβεe^{\beta\varepsilon}). Check the limits: as T0T\to0 (β\beta\to\infty), E0\langle E\rangle \to 0 — the system is frozen into its ground state, exactly as expected. As TT\to\infty (β0\beta\to0), Eε/2\langle E\rangle \to \varepsilon/2 — the two states become equally populated, so the average sits exactly halfway between them.

(b) Quantum harmonic oscillator. Using the energy levels En=ω(n+12)E_n = \hbar\omega(n+\tfrac12) derived in full in the quantum harmonic oscillator, the partition function is an infinite geometric series:

Z=n=0eβω(n+1/2)=eβω/2n=0(eβω)nZ = \sum_{n=0}^{\infty} e^{-\beta\hbar\omega(n+1/2)} = e^{-\beta\hbar\omega/2}\sum_{n=0}^{\infty}\left(e^{-\beta\hbar\omega}\right)^n

The remaining sum is the standard geometric series n=0xn=1/(1x)\sum_{n=0}^\infty x^n = 1/(1-x) for x<1|x|<1, with x=eβωx=e^{-\beta\hbar\omega}:

Z=eβω/21eβωZ = \frac{e^{-\beta\hbar\omega/2}}{1-e^{-\beta\hbar\omega}}

Average energy, using E=lnZ/β\langle E\rangle = -\partial\ln Z/\partial\beta. First write lnZ=12βωln(1eβω)\ln Z = -\tfrac12\beta\hbar\omega - \ln\left(1-e^{-\beta\hbar\omega}\right), and differentiate term by term:

lnZβ=ω2ωeβω1eβω\frac{\partial\ln Z}{\partial\beta} = -\frac{\hbar\omega}{2} - \frac{\hbar\omega\, e^{-\beta\hbar\omega}}{1-e^{-\beta\hbar\omega}}

(the second term comes from the chain rule: β[ln(1eβω)]=ωeβω1eβω\frac{\partial}{\partial\beta}\left[-\ln(1-e^{-\beta\hbar\omega})\right] = -\frac{\hbar\omega e^{-\beta\hbar\omega}}{1-e^{-\beta\hbar\omega}}). So:

E=ω2+ωeβω1\langle E\rangle = \frac{\hbar\omega}{2} + \frac{\hbar\omega}{e^{\beta\hbar\omega}-1}

(multiplying the second term's numerator and denominator by eβωe^{\beta\hbar\omega} converts eβω/(1eβω)e^{-\beta\hbar\omega}/(1-e^{-\beta\hbar\omega}) into 1/(eβω1)1/(e^{\beta\hbar\omega}-1)). This result deserves a moment of appreciation: the first term, ω/2\hbar\omega/2, is exactly the zero-point energy found from the ladder-operator algebra in the quantum harmonic oscillator — it survives even at T=0T=0, since a quantum oscillator can never sit perfectly still. The second term, ω/(eβω1)\hbar\omega/(e^{\beta\hbar\omega}-1), is ωn\hbar\omega\langle n\rangle where n=1/(eβω1)\langle n\rangle = 1/(e^{\beta\hbar\omega}-1) is the thermal-average occupation number of the oscillator's ladder — precisely the formula Planck first wrote down for a single mode of blackbody radiation, decades before anyone had a ladder operator to justify it. As T0T\to0, n0\langle n\rangle\to0 and Eω/2\langle E\rangle\to\hbar\omega/2, exactly the ground state; as TT\to\infty, nkBT/ω1\langle n\rangle\to k_BT/\hbar\omega\gg1 and EkBT\langle E\rangle\to k_BT, recovering the classical equipartition result you'd expect from an oscillator with no quantization at all.

Where this leads

The partition function has quietly become the load-bearing structure of this whole subject: give it a list of energy levels, and it hands back the average energy — and, as later topics will show, essentially every other thermodynamic quantity — by nothing more than differentiation. Before pushing ZZ further, though, this track needs to make its footing fully explicit: the next topic states the laws of thermodynamics themselves, ties the second law directly to the entropy argument built in microstates and entropy, and ties the first law directly to the conservation of energy already established all the way back in work and energy. Only after that formal footing is in place does it become clear exactly why ZZ deserves the central role this topic has just given it.