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 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 ? 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 (the one we care about) sit in thermal contact with a much larger reservoir . Together they're isolated from everything else, so their combined energy is fixed. Crucially, is enormous compared to — think of a single atom sitting in a block of metal containing other atoms.
Ask for the probability that the system is found in one specific microstate , with energy . Since we're asking about one particular microstate of (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, . By the same equal-probability postulate from the previous topic:
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 :
Because is utterly tiny compared to (one atom's energy against a whole block of metal's), expand this in a Taylor series around and keep only the first two terms:
The derivative is exactly the statistical definition of inverse temperature, — 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 , 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 doesn't budge no matter how much energy the tiny system borrows from it, treat as a fixed constant. Substituting:
Exponentiate to get back to :
The first factor, , doesn't depend on at all — it's swallowed into the overall normalization. What's left is the entire content of the result:
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.
The partition function
To turn the proportionality into an actual probability, normalize by summing over every accessible microstate of the system:
, 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 , so that . Once you have as a function of , 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, . Notice that applied to a single term pulls down exactly a factor of :
so summing over :
giving the compact and extremely useful identity:
A single derivative of a single function reproduces the average energy of the entire system, without ever summing directly again. This is the pattern that makes 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 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 and , and (b) the quantum harmonic oscillator with energy levels . (click to reveal the solution)
(a) Two-level system. The system has exactly two accessible microstates, with energies and . The partition function is just the two-term sum:
The average energy, using the derivative identity:
(the last step multiplies numerator and denominator by ). Check the limits: as (), — the system is frozen into its ground state, exactly as expected. As (), — the two states become equally populated, so the average sits exactly halfway between them.
(b) Quantum harmonic oscillator. Using the energy levels derived in full in the quantum harmonic oscillator, the partition function is an infinite geometric series:
The remaining sum is the standard geometric series for , with :
Average energy, using . First write , and differentiate term by term:
(the second term comes from the chain rule: ). So:
(multiplying the second term's numerator and denominator by converts into ). This result deserves a moment of appreciation: the first term, , is exactly the zero-point energy found from the ladder-operator algebra in the quantum harmonic oscillator — it survives even at , since a quantum oscillator can never sit perfectly still. The second term, , is where 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 , and , exactly the ground state; as , and , 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 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 deserves the central role this topic has just given it.