Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Partition functions

The puzzle: the number you divide by

Module 11 introduced the partition function almost as an afterthought. A system in contact with a bath at temperature TT is found in microstate ss with probability e−βEs/Ze^{-\beta E_s}/Z, and ZZ is whatever makes those probabilities add up to one:

Z=∑se−βEs,β=1kBT.Z = \sum_s e^{-\beta E_s} , \qquad \beta = \frac{1}{\kB T} .

A bookkeeping constant, it seemed. Now do something that looks pointless with it: take its logarithm, and differentiate with respect to β\beta.

A harmonic oscillator of level spacing ε\varepsilon, against kBT/ε\kB T/\varepsilon on a logarithmic axis. The four panels are, top to bottom, the mean energy UU, the entropy SS, the free energy FF (all three in units of ε\varepsilon or kB\kB) and the heat capacity CC in units of kB\kB. The black curves are the exact results, computed from the probabilities level by level. The blue dots are computed from nothing but the single number ln⁡Z\ln Z at each temperature and its neighbours, by the difference formulas this module derives. The step between neighbours shrinks as the animation runs (its size relative to β\beta is printed in the top panel), and the dots settle onto the curves. The free energy needs no derivative, only ln⁡Z\ln Z itself, so its dots sit on the curve from the start.

Nothing in the dots knows the levels, the probabilities or the energy. Each dot comes from ln⁡Z\ln Z evaluated at three nearby temperatures, and yet the mean energy, the entropy, the free energy and the heat capacity all come out exactly.

The answer is a short calculation, and it makes ZZ the central object of equilibrium statistical mechanics. Once you have it, every thermodynamic quantity follows by differentiation; the rest of the course computes ZZ for one system after another.

Predict before you calculate

Commit to an answer for each of these before reading on. Write them down.

  1. What does ∂ln⁡Z/∂β\partial \ln Z/\partial\beta give — a quantity you already know, or something new? With what sign?

  2. A salt of independent magnetic moments sits in a weak magnetic field. You halve the temperature at fixed field. Does its magnetization rise or fall, and by roughly what factor?

  3. Keep adding energy to that salt until more moments point against the field than along it. Does its temperature rise without limit, jump to infinity, or turn negative? And if you then touch it to a body at room temperature, which way does heat flow?

  4. A harmonic oscillator is very hot, kBT≫ℏω\kB T \gg \hbar\omega. How much energy does it hold on average? And when it is very cold?

Explore the model

The laboratory has one machine at its centre: a function that is handed ln⁡Z\ln Z and nothing else, and returns UU, SS, FF and CC. It is run on three systems — a two-level system, a paramagnet of many independent moments, and a harmonic oscillator — and every output is checked against the system’s closed-form result. The laboratory then turns the paramagnet upside down, and last puts module 01’s simulated Einstein solid under the oscillator’s partition function.

The first animation follows the paramagnet’s entropy as energy is poured into it.

A paramagnet of N=100N = 100 moments. Left: its entropy S/kB=ln⁡ΩS/\kB = \ln\Omega against its energy in units of μB\mu B, from all moments along the field (U=−100 μBU = -100\,\mu B) to all against it (U=+100 μBU = +100\,\mu B). The red segment is the tangent at the current energy (red dot). Right: the slope of that tangent, β=(1/kB) dS/dU\beta = (1/\kB)\,\mathrm{d}S/\mathrm{d}U, in units of 1/(μB)1/(\mu B). It is positive on the left half, zero at the top of the dome, and negative on the right half, where adding energy removes microstates.

The second animation cools an oscillator.

A harmonic oscillator of level spacing ℏω\hbar\omega, cooled from kBT=5 ℏω\kB T = 5\,\hbar\omega to kBT=0.08 ℏω\kB T = 0.08\,\hbar\omega. Left: the probability of each level nn (bars). Right: the heat capacity C/kBC/\kB against kBT/ℏω\kB T/\hbar\omega (black curve); the dashed line is the equipartition value C=kBC = \kB, and the red dot marks the current temperature. While several levels are occupied the heat capacity sits near the plateau; once only the ground level is left, it collapses.

Run the laboratory now, then come back. Four things are worth doing before you read on:

Derive the result

System and boundary. A system with a fixed list of energy levels — the level energies depend on nothing that changes during the argument — in contact with a large bath at temperature TT. Where the system has a volume, it is held fixed; where it sits in a field, the field is held fixed.

Independent variable. The temperature, through β=1/(kBT)\beta = 1/(\kB T). Everything is a function of β\beta at fixed levels.

Sign convention. The course convention holds,

dU=δQ+δWon,\mathrm{d}U = \dbar Q + \dbar \Won ,

and with the levels fixed no work is done, δWon=0\dbar \Won = 0: every change in the system’s mean energy is heat exchanged with the bath.

Route. Seven steps. The partition function is recalled; its first derivative gives UU, its second the energy fluctuations and CVC_V; the free energy follows and is checked against module 10; independent subsystems factorize; and two systems are worked in full — the paramagnet, which leads to negative temperatures, and the harmonic oscillator, which leads back to equipartition.

Step 1: the partition function, recalled

ZZ is a sum of Boltzmann factors, one per microstate. At low temperature only the lowest levels contribute; as TT rises more terms join in. So ZZ counts, roughly, how many microstates are thermally accessible — which already suggests it knows something.

Which levels matter. A level contributes to ZZ in proportion to e−βEe^{-\beta E}. A level 5 kBT5\,\kB T above the ground state is occupied less than one time in a hundred (e−5=0.0067e^{-5} = 0.0067); one 10 kBT10\,\kB T up, less than once in twenty thousand. At any temperature only the levels within a few kBT\kB T of the ground state matter, and the rest of the spectrum might as well not exist.

Step 2: the mean energy

Differentiate ZZ term by term. Each term’s derivative brings down its own energy:

∂Z∂β=−∑sEs e−βEs.\frac{\partial Z}{\partial \beta} = -\sum_s E_s \, e^{-\beta E_s} .

Divide by ZZ, and the right-hand side becomes the average of EsE_s over the Boltzmann distribution.

The logarithm is not decoration: ∂ln⁡Z/∂β=(∂Z/∂β)/Z\partial \ln Z/\partial\beta = (\partial Z/\partial\beta)/Z, and dividing by ZZ is what turns the weighted sum into an average. That is the whole reason ZZ knows the energy. It is a sum of exponentials in β\beta, and differentiating an exponential brings its exponent down.

For module 11’s two-level system, Z=1+e−βΔZ = 1 + e^{-\beta\Delta} and

U=−∂∂βln⁡(1+e−βΔ)=Δ e−βΔ1+e−βΔ=ΔeβΔ+1,U = -\frac{\partial}{\partial\beta} \ln\left(1 + e^{-\beta\Delta}\right) = \frac{\Delta\, e^{-\beta\Delta}}{1 + e^{-\beta\Delta}} = \frac{\Delta}{e^{\beta\Delta} + 1} ,

module 11’s result, obtained this time without writing down a single probability.

Step 3: the heat capacity, and the fluctuations

Differentiate once more. U=−∂ln⁡Z/∂βU = -\partial\ln Z/\partial\beta is itself a ratio, so

∂2ln⁡Z∂β2=1Z∂2Z∂β2−(1Z∂Z∂β)2=⟨E2⟩−⟨E⟩2.\frac{\partial^2 \ln Z}{\partial \beta^2} = \frac{1}{Z}\frac{\partial^2 Z}{\partial\beta^2} - \left(\frac{1}{Z}\frac{\partial Z}{\partial\beta}\right)^2 = \langle E^2 \rangle - \langle E \rangle^2 .

The second derivative is the variance of the energy: in the canonical ensemble the system’s energy is not fixed, and this is how widely it spreads. The same second derivative is also −∂U/∂β-\partial U/\partial\beta, and converting from β\beta to TT with dβ=−dT/(kBT2)\mathrm{d}\beta = -\mathrm{d}T/(\kB T^2) gives

−∂U∂β=kBT2∂U∂T.-\frac{\partial U}{\partial \beta} = \kB T^2 \frac{\partial U}{\partial T} .

With the levels fixed — fixed volume and particle number — every change of UU is heat, so ∂U/∂T\partial U/\partial T is the heat capacity at constant volume, CV=(∂U/∂T)V,NC_V = (\partial U/\partial T)_{V,N}.

Two consequences follow at once. First, CV≥0C_V \ge 0 for every system in canonical equilibrium, because a variance cannot be negative: the thermal stability that module 09 demanded of S(U)S(U) is automatic here. Second, a quantity that describes the response of a system — how much heat it takes to warm it — is fixed by how much its energy fluctuates when left alone. Module 18 is built on that idea; here it costs three lines.

This is why ln⁡Z\ln Z rather than ZZ is the natural object. Its derivatives in β\beta are, up to sign, the cumulants of the energy distribution — the mean, the variance and the higher ones in turn. A function whose derivatives produce a distribution’s moments is called a generating function, and ln⁡Z\ln Z is the generating function of the canonical energy distribution. That is the answer to the puzzle: the normalization is not a single number but a function of β\beta, and its shape encodes every moment of the distribution it normalizes.

Step 4: the free energy — derived, not defined

The mean energy and its fluctuations came out of ln⁡Z\ln Z directly. The entropy and the free energy need one more step, and it is worth doing slowly, because it is where the statistical and the thermodynamic descriptions have to meet.

Module 10 defined the Helmholtz free energy F=U−TSF = U - TS, with no mention of microstates, and showed that S=−(∂F/∂T)V,NS = -(\partial F/\partial T)_{V,N}. Consider the candidate

FZ≡−kBTln⁡Z.F_Z \equiv -\kB T \ln Z .

Take its temperature derivative. Using ∂ln⁡Z/∂T=(∂ln⁡Z/∂β)(dβ/dT)=U/(kBT2)\partial\ln Z/\partial T = (\partial\ln Z/\partial\beta)(\mathrm{d}\beta/\mathrm{d}T) = U/(\kB T^2),

−∂FZ∂T=kBln⁡Z+kBTUkBT2=U−FZT.-\frac{\partial F_Z}{\partial T} = \kB \ln Z + \kB T \frac{U}{\kB T^2} = \frac{U - F_Z}{T} .

So if we define SZ=−∂FZ/∂TS_Z = -\partial F_Z/\partial T, then FZ=U−TSZF_Z = U - T S_Z, with UU the mean energy of step 2: the candidate has exactly the structure of module 10’s free energy. That is necessary, but it is not yet proof, because SZS_Z has so far only been named. What has to be shown is that SZS_Z is the thermodynamic entropy — the one module 07 defined through heat, and module 08 through counting. Two checks settle it.

It obeys Clausius. With the levels fixed, SZ=kB(ln⁡Z+βU)S_Z = \kB(\ln Z + \beta U), so

dSZ=kB(∂ln⁡Z∂β dβ+U dβ+β dU)=kBβ dU=δQT,\mathrm{d}S_Z = \kB\left(\frac{\partial\ln Z}{\partial\beta}\,\mathrm{d}\beta + U\,\mathrm{d}\beta + \beta\,\mathrm{d}U\right) = \kB\beta\,\mathrm{d}U = \frac{\dbar Q}{T} ,

since the first two terms cancel (∂ln⁡Z/∂β=−U\partial\ln Z/\partial\beta = -U) and dU=δQ\mathrm{d}U = \dbar Q at fixed levels. Module 07’s entropy is defined, up to a constant, by exactly dS=δQrev/T\mathrm{d}S = \dbar Q_{\mathrm{rev}}/T.

It counts microstates. Substituting ln⁡Ps=−βEs−ln⁡Z\ln P_s = -\beta E_s - \ln Z into −∑sPsln⁡Ps-\sum_s P_s \ln P_s gives βU+ln⁡Z\beta U + \ln Z, so

SZ=−kB∑sPsln⁡Ps,S_Z = -\kB \sum_s P_s \ln P_s ,

the Gibbs entropy of the Boltzmann distribution. When all Ω\Omega accessible microstates are equally probable, Ps=1/ΩP_s = 1/\Omega and this is module 08’s kBln⁡Ω\kB\ln\Omega — which also fixes the constant that Clausius leaves free. As T→0T \to 0 the system settles into its g0g_0 ground microstates and SZ→kBln⁡g0S_Z \to \kB\ln g_0, their count.

That is a theorem, and it is worth being precise about why. Module 10’s FF was already defined — as a Legendre transform of UU, with nothing statistical about it. The statement F=−kBTln⁡ZF = -\kB T\ln Z says that a quantity computed from a list of energy levels equals that thermodynamic function, and it had to be checked: the entropy it implies had to obey Clausius and agree with the count of microstates. Writing F=−kBTln⁡ZF = -\kB T\ln Z as a definition would skip exactly the step that connects statistical mechanics to thermodynamics.

The payoff is enormous. Module 10 showed that F(T,V,N)F(T, V, N) is a fundamental relation: every equilibrium property at fixed temperature follows from it. So ln⁡Z\ln Z, computed from the levels, is the fundamental relation of the system — pressure, chemical potential and all, once the levels are allowed to depend on VV and NN.

Step 5: independent subsystems factorize

Most systems of interest are made of many parts. Suppose a system consists of NN subsystems that do not interact, so that a microstate of the whole is a list (s1,s2,…,sN)(s_1, s_2, \ldots, s_N) of one microstate for each part and its energy is the sum E=Es1+Es2+⋯+EsNE = E_{s_1} + E_{s_2} + \cdots + E_{s_N}. The Boltzmann factor of a sum is a product, and the sum over all lists breaks into a product of sums.

Because ln⁡ZN\ln Z_N is NN times ln⁡z\ln z, so is everything derived from it: UU, SS, FF, CC and the variance σE2\sigma_E^2 are all extensive. The spread, though, grows only as the square root:

σE∣U∣=N σ1N ∣u1∣∝N−1/2,\frac{\sigma_E}{|U|} = \frac{\sqrt{N}\,\sigma_1}{N\,|u_1|} \propto N^{-1/2} ,

the same N−1/2N^{-1/2} that narrowed module 08’s multiplicity peak and module 11’s canonical energy distribution, now arriving from a derivative of ln⁡Z\ln Z.

“Distinguishable” matters. A crystal’s magnetic moments sit on labelled lattice sites, and swapping two of them gives a different microstate. Identical gas molecules are not labelled, and counting every permutation as a new microstate overcounts by N!N!. That correction is the subject of the advanced section; nothing in the core needs it.

Step 6: the paramagnet, worked in full

A paramagnet is a material whose atoms carry permanent magnetic moments that do not interact with one another. In a field BB, a moment μ\mu pointing along the field has energy −μB-\mu B and one pointing against it +μB+\mu B (a spin-1/2 moment, like an unpaired electron, has only these two orientations). One moment is a two-level system with gap 2μB2\mu B, and with x=μB/(kBT)x = \mu B/(\kB T),

z=ex+e−x=2cosh⁡x,ln⁡ZN=Nln⁡(2cosh⁡x).z = e^{x} + e^{-x} = 2\cosh x , \qquad \ln Z_N = N \ln(2\cosh x) .

The energy follows from step 2, and the net moment along the field — the magnetization MM — from U=−MBU = -MB:

U=−NμBtanh⁡x,M=Nμtanh⁡(μBkBT).U = -N\mu B \tanh x , \qquad M = N\mu \tanh\left(\frac{\mu B}{\kB T}\right) .
Left, magnetization against field over temperature, an S-shaped curve rising linearly then flattening at one, with a straight dashed line along its initial slope. Right, heat capacity against temperature on a logarithmic axis, a single peak.

(a) The paramagnet’s magnetization, M/(Nμ)M/(N\mu), against μB/(kBT)\mu B/(\kB T) (black), with the Curie law M=Nμ2B/(kBT)M = N\mu^2 B/(\kB T) (dashed) and saturation at M=NμM = N\mu (dotted). (b) Its heat capacity per moment, C/(NkB)C/(N\kB), against kBT/(μB)\kB T/(\mu B) on a logarithmic axis: a single peak — the Schottky anomaly — near kBT=0.83 μB\kB T = 0.83\,\mu B, dying at both ends.

The two limits are the physics.

The heat capacity, from step 3, is a two-level system’s for each moment, C=NkB x2/cosh⁡2xC = N\kB\,x^2/\cosh^2 x. It vanishes when cold (every moment aligned, nothing to excite) and when hot (the moments already split half and half, and further heating changes nothing), with a peak in between. Such a peak in the measured heat capacity of a solid is the fingerprint of a set of two-level systems hidden in it.

The paramagnet at fixed energy. So far the paramagnet has been in contact with a bath. Now isolate it and count instead, as module 08 did for coins. With nn of the NN moments pointing against the field, the energy is

U=μB (2n−N),U = \mu B\,(2n - N) ,

running from −NμB-N\mu B (all aligned) to +NμB+N\mu B (all reversed), and the number of microstates is the binomial coefficient Ω=(Nn)\Omega = \binom{N}{n}. The entropy S=kBln⁡(Nn)S = \kB \ln\binom{N}{n} is the dome of the second animation: zero at both ends, where there is only one way to arrange the moments, and largest at U=0U = 0, where half point each way.

Now apply module 09’s definition of temperature, 1/T=∂S/∂U1/T = \partial S/\partial U. A moment reversed costs 2μB2\mu B, and by Stirling ∂ln⁡(Nn)/∂n=ln⁡[(N−n)/n]\partial \ln\binom{N}{n}/\partial n = \ln[(N - n)/n], so

β=1kB∂S∂U=12μBln⁡N−nn.\beta = \frac{1}{\kB}\frac{\partial S}{\partial U} = \frac{1}{2\mu B}\ln\frac{N - n}{n} .

For n<N/2n < N/2 — more moments along the field than against — β\beta is positive, and inverting gives n/(N−n)=e−2βμBn/(N - n) = e^{-2\beta\mu B}, the Boltzmann ratio of the canonical calculation. At n=N/2n = N/2 the dome is flat: β=0\beta = 0, an infinite temperature. And for n>N/2n > N/2 the dome slopes down: adding energy removes microstates, β\beta is negative, and so is TT.

What does a negative temperature mean? Not what the number suggests. The honest way to find out is to ask what temperature is for: deciding which way heat flows.

Put the paramagnet (body 1) in contact with any other body (body 2), the pair isolated. Energy dU1\mathrm{d}U_1 passes into body 1 and dU2=−dU1\mathrm{d}U_2 = -\mathrm{d}U_1 leaves body 2, and the total entropy changes by

dStotkB=β1 dU1+β2 dU2=(β1−β2) dU1.\frac{\mathrm{d}S_{\mathrm{tot}}}{\kB} = \beta_1\,\mathrm{d}U_1 + \beta_2\,\mathrm{d}U_2 = (\beta_1 - \beta_2)\,\mathrm{d}U_1 .

The second law, in module 08’s counting form, says the pair moves toward more microstates, dStot>0\mathrm{d}S_{\mathrm{tot}} > 0. So energy flows into body 1 when β1>β2\beta_1 > \beta_2 and out of it when β1<β2\beta_1 < \beta_2: heat flows from the body with the smaller β\beta to the body with the larger one. For two positive temperatures this is the familiar rule, hot to cold. But now take an inverted paramagnet, β1<0\beta_1 < 0, and any ordinary body at any positive temperature, β2>0\beta_2 > 0.

A negative temperature is not below absolute zero. It is above infinite temperature. The paramagnet with more moments reversed than aligned holds more energy than it would at any positive temperature — at T=+∞T = +\infty the moments split exactly half and half — and it will give some of that energy to anything at a positive temperature it touches, however hot. The quantity that orders hotness is −β-\beta, not TT; TT merely has an awkward jump from +∞+\infty to −∞-\infty in the middle, at the top of the dome, where nothing physical happens at all.

This is also why module 11 found that heating never inverts a two-level population: a bath at positive temperature has β>0\beta > 0 and can only bring the system to β>0\beta > 0. An inverted population is not a very hot equilibrium with a positive-temperature bath; it has to be made some other way, and the advanced section says how.

Step 7: the harmonic oscillator, and equipartition recovered

The last system has infinitely many levels, equally spaced: En=ℏω (n+1/2)E_n = \hbar\omega\,(n + 1/2) for n=0,1,2,…n = 0, 1, 2, \ldots — a quantum harmonic oscillator, and one of module 01’s Einstein-solid oscillators, with ℏω\hbar\omega its energy quantum. With x=ℏω/(kBT)x = \hbar\omega/(\kB T) the partition function is a geometric series,

z=∑n=0∞e−x(n+1/2)=e−x/21−e−x,z = \sum_{n=0}^{\infty} e^{-x(n + 1/2)} = \frac{e^{-x/2}}{1 - e^{-x}} ,

and step 2 gives

U=ℏω(12+1eℏω/(kBT)−1).U = \hbar\omega\left(\frac{1}{2} + \frac{1}{e^{\hbar\omega/(\kB T)} - 1}\right) .

The ℏω/2\hbar\omega/2 is the zero-point energy, the ground level’s own energy. It shifts UU and FF by a constant and changes neither SS nor CC; module 01, counting quanta above the ground state, simply left it out. Step 3 gives the heat capacity,

C=kB(ℏω/(kBT)2sinh⁡(ℏω/(2kBT)))2.C = \kB \left(\frac{\hbar\omega/(\kB T)}{2\sinh\big(\hbar\omega/(2\kB T)\big)}\right)^2 .

A solid of NN atoms has 3N3N vibrational modes. If each held kBT\kB T, its heat capacity would be 3NkB3N\kB at every temperature — the Dulong–Petit law, which fits many solids at room temperature and fails for all of them when cold, because the modes freeze out. How they freeze out, mode by mode, is module 16.

Verify computationally

Every number below comes from thermolab.partition. Level spacings are ε=10−21 J\varepsilon = 10^{-21}\ \mathrm{J} for the two-level gap and the oscillator quantum (ε/kB=72.4 K\varepsilon/\kB = 72.4\ \mathrm{K}), and the paramagnet’s moments are Bohr magnetons, μ=9.274×10−24 J T−1\mu = 9.274 \times 10^{-24}\ \mathrm{J\,T^{-1}}, in B=1 TB = 1\ \mathrm{T} (μB/kB=0.672 K\mu B/\kB = 0.672\ \mathrm{K}).

1. The machine. thermo_from_z is handed a function returning ln⁡Z(T)\ln Z(T), and nothing else. It differentiates in β\beta with central differences,

U≈−ln⁡Z(β+h)−ln⁡Z(β−h)2h,σE2≈ln⁡Z(β+h)−2ln⁡Z(β)+ln⁡Z(β−h)h2,U \approx -\frac{\ln Z(\beta + h) - \ln Z(\beta - h)}{2h} , \qquad \sigma_E^2 \approx \frac{\ln Z(\beta + h) - 2\ln Z(\beta) + \ln Z(\beta - h)}{h^2} ,

then sets C=σE2/(kBT2)C = \sigma_E^2/(\kB T^2), F=−kBTln⁡ZF = -\kB T \ln Z and S=(U−F)/TS = (U - F)/T. The step hh is a fixed fraction of β\beta itself.

2. The step, and why it cannot be too small. Both difference formulas are second order: their truncation error falls as h2h^2. Measured on the oscillator at kBT=ℏω\kB T = \hbar\omega, halving the step from β/10\beta/10 to β/160\beta/160 divides the error of UU by 4.02, 4.00, 4.00, 4.00.

The rise is roundoff error. The formulas subtract values of ln⁡Z\ln Z that agree in more and more of their sixteen significant digits as hh shrinks, and the difference is left with fewer and fewer correct ones. The first difference divides that loss by hh, the second by h2h^2, which is why CC suffers first. The best step balances the two errors: about ϵ1/3β\epsilon^{1/3}\beta for UU and ϵ1/4β\epsilon^{1/4}\beta for CC, with ϵ=2.2×10−16\epsilon = 2.2 \times 10^{-16} the float’s relative precision, and those are the defaults. The same cancellation is what degrades CC in item 1’s tails. Where CC is exponentially small, ln⁡Z\ln Z barely curves, and its curvature is buried under the digits it shares at three neighbouring points. There a sum over the levels, which never subtracts, is the better tool.

3. F=−kBTln⁡ZF = -\kB T\ln Z, tested against module 10’s FF. The laboratory computes the oscillator’s free energy twice. Once from ln⁡Z\ln Z. Once as U−TSU - TS, with U=∑nEnPnU = \sum_n E_n P_n and the Gibbs entropy S=−kB∑nPnln⁡PnS = -\kB \sum_n P_n \ln P_n both summed from the probabilities, so that no ln⁡Z\ln Z appears in the second computation at all. At 20, 72.4 and 300 K300\ \mathrm{K} the two agree to 2×10−162 \times 10^{-16}, 2×10−152 \times 10^{-15} and exactly — rounding in the last digit. The entropy that ln⁡Z\ln Z implies is the entropy the probabilities carry, which is step 4’s second check made numerical.

4. The paramagnet’s magnetization. For 104 electron moments in 1 T1\ \mathrm{T}:

TT (K)3001501010.30.1
M/(Nμ)M/(N\mu)0.002240.004480.06710.5860.9781.000
Curie law0.002240.004480.06720.6722.246.72

Halving the temperature from 300 to 150 K150\ \mathrm{K} multiplies MM by 1.99999. Below about 1 K1\ \mathrm{K} the Curie law predicts more than every moment can give, and the true curve saturates.

5. Fluctuations shrink as N−1/2N^{-1/2}. From the reconstructed second derivative of ln⁡ZN\ln Z_N at 1 K1\ \mathrm{K}, the relative energy fluctuation σE/∣U∣\sigma_E/|U| of the paramagnet is 0.437 for 10 moments, 0.0437 for 1000 and 0.00138 for 106. The fitted exponent is -0.5000000, and going from 104 to 106 moments divides the fluctuation by 10.0000.

6. The dome, and the heat that leaves it. For N=100N = 100 moments the entropy rises from 0 to 66.78 kB66.78\,\kB at U=0U = 0 (against the Nln⁡2=69.31 kBN\ln 2 = 69.31\,\kB of Stirling’s leading term), and the slope read off by central difference gives

moments reversed10304950517085
TT (K)0.621.6033.9±∞\pm\infty-33.9-1.60-0.79

— symmetric about the peak, with the sign flipping as the tangent passes over the top.

Even the 1344 K1344\ \mathrm{K} solid, whose own temperature is more than a thousand times the magnitude of the paramagnet’s, takes energy from it. The count settles the paramagnet at 50 reversed moments — as close to T=±∞T = \pm\infty as a finite system gets — never at a positive temperature below the solid’s, which would mean giving up still more.

7. Equipartition, and freeze-out. The oscillator’s mean energy per kBT\kB T, measured above the ground state, is 0.9950 at kBT=100 ℏω\kB T = 100\,\hbar\omega, 0.951 at 10 ℏω10\,\hbar\omega, 0.582 at ℏω\hbar\omega and 0.0005 at 0.1 ℏω0.1\,\hbar\omega. Its heat capacity is 0.9992 kB0.9992\,\kB, 0.921 kB0.921\,\kB, 0.171 kB0.171\,\kB and 0.0045 kB0.0045\,\kB at 10, 1, 0.2 and 0.1 ℏω0.1\,\hbar\omega.

8. Module 01’s solid, under the oscillator’s partition function. Module 01 simulated two Einstein solids trading quanta and read each one’s temperature by equipartition, T=U/(nkB)T = U/(n\kB) per oscillator. Its model specification warned that this reading fails when cold. The oscillator partition function supplies the exact reading: inverting U(T)U(T) above the ground state,

T=ℏωkBln⁡(1+nℏω/U),T = \frac{\hbar\omega}{\kB \ln\big(1 + n\hbar\omega/U\big)} ,

which is also module 09’s temperature, from the slope of the Einstein solid’s S(U)S(U) — the two agree to 10-14. For kBT≫ℏω\kB T \gg \hbar\omega it is equipartition’s reading plus half a quantum.

Energy per oscillator against temperature, both on logarithmic axes. A black curve bends down away from a straight dashed line at low temperature; blue points with small error bars lie on the black curve; open grey circles lie on the dashed line.

Mean quanta per oscillator against kBT/ℏω\kB T/\hbar\omega. Black: the oscillator partition function’s U(T)U(T) above the ground state. Dashed: equipartition, U=kBTU = \kB T, module 01’s reading. Blue: the endpoints of module 01’s simulation at seven energies — two solids of 40 oscillators, 8 seeds each — placed at the temperature the partition function assigns them. Grey circles: the same endpoints at the temperature module 01’s equipartition reading assigns. The shaded band, kBT>2ℏω\kB T > 2\hbar\omega, is where the two readings differ by less than about a quarter.

The simulation supplies the energies; the partition function supplies the thermometer. The simulation cannot choose between the two thermometers: both say that two solids of one quantum size settle at equal energy per oscillator, and that is all it shows. What decides between them is module 09’s slope of S(U)S(U), which the partition function reproduces and equipartition only approaches. The overlay illustrates, and the derivation of step 7 establishes: nothing in these numbers proves the oscillator formula, which rests on the levels being ℏω(n+1/2)\hbar\omega(n + 1/2).

Transfer the idea

The recipe — list the levels, sum the Boltzmann factors, differentiate the logarithm — works for any system whose levels you know.

Looking ahead:

Worked examples

Try each one before opening its solution.

Worked example 1 — everything from one sum. A two-level system has gap Δ=2 kBT\Delta = 2\,\kB T. Find ln⁡Z\ln Z, UU, FF, SS and CC.

Solution

Z=1+e−2=1.1353Z = 1 + e^{-2} = 1.1353, so ln⁡Z=0.1269\ln Z = 0.1269. Then

U=Δe2+1=0.1192 Δ,F=−kBTln⁡Z=−0.1269 kBT,U = \frac{\Delta}{e^{2} + 1} = 0.1192\,\Delta , \qquad F = -\kB T\ln Z = -0.1269\,\kB T ,
SkB=ln⁡Z+UkBT=0.1269+2×0.1192=0.365,CkB=x2ex(ex+1)2∣x=2=0.420.\frac{S}{\kB} = \ln Z + \frac{U}{\kB T} = 0.1269 + 2 \times 0.1192 = 0.365 , \qquad \frac{C}{\kB} = \frac{x^2 e^x}{(e^x + 1)^2}\bigg|_{x=2} = 0.420 .

Check: U−TS=(0.2384−0.3653) kBT=−0.1269 kBT=FU - TS = (0.2384 - 0.3653)\,\kB T = -0.1269\,\kB T = F.

Worked example 2 — aligning electron moments. Electron moments in a 1 T1\ \mathrm{T} field. What fraction of the saturation magnetization is reached at 300 K300\ \mathrm{K}? How cold must the salt be for 90%90\%?

Solution

At 300 K300\ \mathrm{K}, x=μB/(kBT)=9.274×10−24/(1.381×10−23×300)=0.00224x = \mu B/(\kB T) = 9.274 \times 10^{-24}/(1.381 \times 10^{-23} \times 300) = 0.00224, and tanh⁡x=0.00224\tanh x = 0.00224: about two moments in a thousand, net. For 90%90\%, tanh⁡x=0.9\tanh x = 0.9 gives x=1.472x = 1.472, so

T=μB1.472 kB=0.46 K.T = \frac{\mu B}{1.472\,\kB} = 0.46\ \mathrm{K} .

A field of 1 T1\ \mathrm{T} is a weak perturbation at room temperature; aligning electron moments takes a fraction of a kelvin.

Worked example 3 — why air has five, not seven. Nitrogen’s vibration has ℏω/kB=3353 K\hbar\omega/\kB = 3353\ \mathrm{K}. Estimate its contribution to CVC_V per molecule at 300 K300\ \mathrm{K} and 1000 K1000\ \mathrm{K}.

Solution

With x=3353/Tx = 3353/T, C/kB=x2ex/(ex−1)2C/\kB = x^2 e^x/(e^x - 1)^2. At 300 K300\ \mathrm{K}, x=11.18x = 11.18 and C=0.0017 kBC = 0.0017\,\kB. At 1000 K1000\ \mathrm{K}, x=3.35x = 3.35 and C=0.42 kBC = 0.42\,\kB. Equipartition would give the full kB\kB — the two quadratic terms that would lift a diatomic gas from 52\tfrac52 to 72 kB\tfrac72\,\kB per molecule. At room temperature they are frozen out.

Worked example 4 — which way does the heat go? A crystal’s nuclear moments are prepared with 85%85\% of them reversed; its temperature is −0.79 K-0.79\ \mathrm{K}. It is touched to a copper block at 300 K300\ \mathrm{K}. Which way does heat flow, and does the answer change if the copper is at 3 K3\ \mathrm{K}?

Solution

The moments have β1=1/(kB×(−0.79 K))<0\beta_1 = 1/(\kB \times (-0.79\ \mathrm{K})) < 0; the copper has β2>0\beta_2 > 0 at either temperature. Heat flows from smaller β\beta to larger, so it flows from the moments to the copper in both cases. The negative-temperature system is hotter than the copper at any positive temperature. The reversed moments relax back toward alignment and the copper warms.

Worked example 5 — a zero-point question. An oscillator of quantum ℏω\hbar\omega is at kBT=ℏω\kB T = \hbar\omega. What is its mean energy with the zero point, and without it? Which of UU, FF, SS and CC depend on the choice?

Solution

U=ℏω (1/2+1/(e−1))=ℏω (0.5+0.582)=1.082 ℏωU = \hbar\omega\,(1/2 + 1/(e - 1)) = \hbar\omega\,(0.5 + 0.582) = 1.082\,\hbar\omega with the zero point, 0.582 ℏω0.582\,\hbar\omega without. Removing the zero point multiplies every Boltzmann factor by eβℏω/2e^{\beta\hbar\omega/2}, so ln⁡Z\ln Z gains βℏω/2\beta\hbar\omega/2: UU and FF both drop by ℏω/2\hbar\omega/2, and S=(U−F)/TS = (U - F)/T and CC are unchanged. Only differences of energy are physical here.

Worked example 6 — how steady is a macroscopic magnet? The laboratory finds σE/∣U∣=1.382/N\sigma_E/|U| = 1.382/\sqrt{N} for the paramagnet at 1 K1\ \mathrm{K} in 1 T1\ \mathrm{T}. What is it for a sample of 1020 moments?

Solution

1.382/1020=1.4×10−101.382/\sqrt{10^{20}} = 1.4 \times 10^{-10}. The energy of a macroscopic sample in canonical equilibrium is sharp to about a part in ten billion, even though each moment’s own energy swings between −μB-\mu B and +μB+\mu B.

Check your understanding

  1. A system with fixed energy levels is in contact with a bath. What is -d(ln Z)/d(beta), with beta = 1/(k_B T)?

    A. The mean energy U of the system. B. The free energy F of the system. C. Nothing physical -- Z only normalizes the probabilities, so its derivative has no meaning. D. The entropy S of the system, divided by k_B.

    Check your answer

    Correct answer: A — The mean energy U of the system.

    • A. Right. Differentiating Z = sum_s exp(-beta E_s) brings down -E_s in every term, and dividing by Z -- which is what the logarithm does -- turns that sum into an average: -d(ln Z)/d(beta) = sum_s E_s P_s = U. The second derivative gives the variance of the energy.

    • B. The free energy is -k_B T ln Z itself, with no derivative taken. Differentiating ln Z in beta gives the mean energy; U and F differ by TS.

    • C. Z is a function of beta, not a single number, and its shape carries the energy distribution. Its logarithm’s first derivative is -U and its second is the variance of E: ln Z is the generating function of the canonical energy distribution.

    • D. The entropy needs both ln Z and its derivative: S = k_B (ln Z + beta U). The derivative alone is -U.

  2. A two-level system has levels 0 and Delta, with Delta = 2 k_B T. Using U = -d(ln Z)/d(beta), what is its mean energy, as a multiple of Delta?

    Check your answer

    Correct answer: 0.1192 (± 0.002)

    ln Z = ln(1 + exp(-beta Delta)), so U = Delta exp(-beta Delta)/(1 + exp(-beta Delta)) = Delta/(exp(2) + 1) = 0.119 Delta. If you answered 0.135, you gave the population ratio exp(-2), not the excited fraction. If you answered 0.5, you gave the infinite-temperature limit.

  3. What is the status of the statement F = -k_B T ln Z?

    A. A theorem -- it holds because the entropy it implies was checked to obey dS = dQ/T and to equal the Gibbs count of microstates, so it is module 10’s F = U - TS. B. A definition -- statistical mechanics defines the free energy as -k_B T ln Z. C. An approximation, valid only for large systems. D. An empirical law, found by measuring free energies.

    Check your answer

    Correct answer: A — A theorem -- it holds because the entropy it implies was checked to obey dS = dQ/T and to equal the Gibbs count of microstates, so it is module 10’s F = U - TS.

    • A. Right. Module 10 defined F = U - TS before any ensemble existed. That -k_B T ln Z equals it had to be shown: its entropy k_B (ln Z + beta U) obeys Clausius’s dS = dQ/T at fixed levels and equals -k_B sum P ln P. The laboratory computes -k_B T ln Z and U - TS independently and finds them equal to rounding.

    • B. This is the misconception that F = -k_B T ln Z is a definition. The free energy was already defined, thermodynamically, as U - TS. Calling the formula a definition skips the step that connects the two descriptions: checking that the entropy it implies is the thermodynamic entropy.

    • C. Nothing in the derivation needs a large system: it holds exactly for any system with fixed levels in contact with a bath, even a single two-level system.

    • D. It is derived, not measured: from the Boltzmann distribution plus two checks on the entropy. Experiments test the model levels, not the formula.

  4. A crystal’s magnetic moments have been prepared with more of them pointing against the field than along it, so their temperature is negative. The crystal is touched to a copper block at room temperature. Which way does heat flow?

    A. Out of the moments and into the copper -- a negative-temperature system is hotter than any positive-temperature one. B. Into the moments -- a negative temperature is colder than absolute zero, so they are colder than the copper. C. No heat flows, because the two temperatures cannot be compared. D. It depends on whether the copper is hotter than the magnitude of the negative temperature.

    Check your answer

    Correct answer: A — Out of the moments and into the copper -- a negative-temperature system is hotter than any positive-temperature one.

    • A. Right. The total entropy changes by k_B (beta_1 - beta_2) dU_1, and it must rise. With beta_1 < 0 < beta_2, that needs dU_1 < 0. In the laboratory an inverted paramagnet gives energy to a solid at 0.56 K, 14 K and 1344 K alike. Ordered by hotness, negative temperatures lie above T = infinity.

    • B. This is the misconception that negative temperature means colder than absolute zero. The moments hold more energy than at any positive temperature -- at T = infinity they split half and half, and here more point against the field. They give energy to anything at a positive temperature, however hot.

    • C. They can be compared through beta = (1/k_B) dS/dU, which runs continuously from positive through zero to negative. Heat flows from the smaller beta to the larger.

    • D. The magnitude does not matter. Every negative beta is smaller than every positive beta, so energy leaves the moments whatever the copper’s temperature -- the laboratory’s 1344 K solid still takes energy from a -0.79 K paramagnet.

  5. A paramagnet is in a weak field, mu B << k_B T. Its temperature is halved at fixed field. By what factor does its magnetization change?

    Check your answer

    Correct answer: 2.0 (± 0.05)

    In the Curie regime M = N mu^2 B/(k_B T), so halving T doubles M. The laboratory finds a factor of 1.99999 between 300 K and 150 K in a 1 T field. If you answered 1, you were thinking of saturation, where every moment is already aligned. If you answered 4, you squared the temperature: the Curie law is 1/T, not 1/T^2.

  6. A harmonic oscillator with level spacing hbaromega is in contact with a bath at k_B T = hbaromega/20. What is its heat capacity?

    A. Exponentially small, about k_B (hbaromega/(k_B T))^2 exp(-hbaromega/(k_B T)) -- the oscillator has frozen out. B. k_B, as for every oscillator at every temperature -- which is why a solid has C = 3 N k_B. C. k_B / 2, because only the kinetic energy still counts. D. Infinite, because the energy changes abruptly between levels.

    Check your answer

    Correct answer: A — Exponentially small, about k_B (hbaromega/(k_B T))^2 exp(-hbaromega/(k_B T)) -- the oscillator has frozen out.

    • A. Right. At k_B T << hbar*omega the first excited level is out of reach, and the smallest amount of energy the oscillator can take is a whole quantum the bath almost never supplies. Here C = 400 exp(-20) k_B, about 8e-7 k_B.

    • B. This is the misconception that the Dulong-Petit value holds at all temperatures. C = k_B per oscillator is equipartition, the high-temperature limit k_B T >> hbar*omega. When cold the oscillator freezes out, and solids’ heat capacities fall toward zero -- module 16 follows this for real solids.

    • C. Freezing out is not a matter of losing one quadratic term: the whole oscillator stops absorbing heat, because its excited levels are out of reach. C falls exponentially, not by half.

    • D. The canonical mean energy is a smooth function of temperature, so C is finite; and when cold it is tiny, since almost no oscillator is excited at all.

  7. Two paramagnets are at the same temperature and in the same field: one has N = 10^4 moments, the other N = 10^6. By what factor is the relative energy fluctuation sigma_E/|U| of the small one larger than that of the large one?

    Check your answer

    Correct answer: 10.0 (± 0.2)

    For independent moments ln Z_N = N ln z, so U grows as N and the variance d^2(ln Z)/d(beta)^2 also grows as N; sigma_E grows as sqrt(N) and sigma_E/|U| falls as N^(-1/2). A hundredfold increase in N divides it by 10. If you answered 100, you let sigma_E stay fixed while U grew; if you answered 1, you treated the relative spread as a property of the material rather than of the sample’s size.

  8. U is reconstructed from ln Z with the central difference -[ln Z(beta + h) - ln Z(beta - h)]/(2h). The step h is halved, and it is still far larger than the step at which roundoff matters. What happens to the error?

    A. It falls by a factor of about four, because the central difference is second order. B. It halves, because the error is proportional to the step. C. It does not change, because the formula is exact for any step. D. It grows, because a smaller step always makes the subtraction less accurate.

    Check your answer

    Correct answer: A — It falls by a factor of about four, because the central difference is second order.

    • A. Right. The truncation error of a central difference is proportional to h^2. The laboratory measures an order of 2.002 +/- 0.001: each halving divides the error by 4.00.

    • B. That is a one-sided difference, first order. The symmetric formula cancels the h term, and the leading error is h^2 f’‘’/6.

    • C. It is exact only when ln Z is a quadratic in beta, which it never is here. The error is proportional to h^2 and to the third derivative of ln Z.

    • D. That is roundoff, and it wins only for very small steps -- in the laboratory below about 1e-5 of beta for U. Above that, truncation dominates and a smaller step is better.

  9. In three or four sentences: why does the normalization constant Z determine a system’s thermodynamics, and what had to be checked before writing F = -k_B T ln Z?

    Check your answer

    Z is a function of beta, and each term exp(-beta E_s) carries its state’s energy in the exponent, so differentiating ln Z in beta produces averages over the Boltzmann distribution: the first derivative is -U, the second the variance of E, which equals k_B T^2 C_V. ln Z is thus the generating function of the energy distribution. For F: the free energy had already been defined in module 10 as U - TS, so -k_B T ln Z had to be shown to equal it -- the entropy it implies, k_B (ln Z + beta U), was checked to obey dS = dQ/T at fixed levels and to equal the Gibbs sum -k_B sum P ln P. A strong answer names both checks and calls the result a theorem.

Exam-style problems for this module — the ones worth doing with a pen — are collected in the problem set.

Explain it in your own words

Answer in a few sentences each.

  1. A classmate says: “ZZ is just the normalization constant; the physics is in the Boltzmann factors.” Convince them otherwise, using step 2.

  2. Rewrite this sentence so that it is correct: “Negative temperature means colder than absolute zero.” Say what ∂S/∂U\partial S/\partial U has to do with it.

  3. Is F=−kBTln⁡ZF = -\kB T \ln Z a definition or a theorem? What had to be checked before it could be written down?

  4. Why does a harmonic oscillator stop absorbing heat when it is cold, while a classical oscillator — module 06’s — never does?

Advanced: the ideal gas, the Gibbs factor, and real negative temperatures

One particle in a box. A particle of mass mm in a box of volume VV has translational levels too closely spaced to see individually at ordinary temperatures. Counting them — one state per cell of volume h3h^3 in position–momentum space, a result stated here and derived in module 17 — turns the sum into an integral with the value

z=Vλ3,λ=h2πmkBT,z = \frac{V}{\lambda^3} , \qquad \lambda = \frac{h}{\sqrt{2\pi m \kB T}} ,

where λ\lambda is the thermal wavelength: 1.6×10−11 m1.6 \times 10^{-11}\ \mathrm{m} for argon at 300 K300\ \mathrm{K}. So zz is, roughly, the number of thermal-wavelength cubes that fit in the box. Step 2 gives U=32kBTU = \tfrac32 \kB T at once, since ln⁡z=ln⁡V+32ln⁡T+const\ln z = \ln V + \tfrac32\ln T + \text{const} — equipartition for three quadratic terms.

N particles, and the factor N! If the particles were distinguishable, step 5 would give ZN=zNZ_N = z^N. But identical particles are not labelled: exchanging two of them does not produce a new microstate, and zNz^N counts each configuration N!N! times. The corrected partition function is

ZN=zNN!=1N!(Vλ3)N.Z_N = \frac{z^N}{N!} = \frac{1}{N!}\left(\frac{V}{\lambda^3}\right)^N .

The correction is not cosmetic. Without it the entropy is not extensive: doubling NN and VV together should double SS, but with ZN=zNZ_N = z^N it overshoots by 2NkBln⁡22N\kB\ln 2 — the entropy of mixing two samples of the same gas, which is module 08’s Gibbs paradox. With the 1/N!1/N! and Stirling’s ln⁡N!≈Nln⁡N−N\ln N! \approx N\ln N - N, step 4 gives

S=NkB[ln⁡(VNλ3)+52],S = N\kB\left[\ln\left(\frac{V}{N\lambda^3}\right) + \frac52\right] ,

the Sackur–Tetrode equation that module 09 stated. For argon at 300 K300\ \mathrm{K} and 1 bar1\ \mathrm{bar}, V/(Nλ3)=1.0×107V/(N\lambda^3) = 1.0 \times 10^7 and S=18.6 NkBS = 18.6\,N\kB. The test suite checks that thermo_from_z applied to this ln⁡ZN\ln Z_N reproduces module 09’s formula, and that dropping the 1/N!1/N! breaks extensivity by exactly 2NkBln⁡22N\kB\ln 2.

The derivation also says when it fails. V/(Nλ3)≫1V/(N\lambda^3) \gg 1 means the particles are far apart compared with their thermal wavelength, so that no two ever compete for one state and dividing by N!N! is enough. When Nλ3N\lambda^3 approaches VV — dense, cold gases, electrons in a metal — it is not, and module 17’s quantum statistics take over.

Negative temperatures in the laboratory. A population with more moments against the field than along it cannot be reached by heating, but it can be reached by reversing the field faster than the moments can follow. Purcell and Pound did exactly this in 1951 with the nuclear moments of lithium in a LiF crystal: after a sudden reversal of the field, the nuclear spins were at a negative temperature and relaxed back through ±∞\pm\infty over minutes, the timescale on which they exchanged energy with the lattice. Every laser relies on a population inversion in the same sense: its working levels are held at a negative temperature, and the light it emits is the energy that flows out of them.

Two caveats keep this honest. The spins can be assigned a temperature only because they reach equilibrium among themselves much faster than they reach it with the lattice; the spin system is then isolated enough to have its own S(U)S(U). And negative temperatures exist only for degrees of freedom with an energy ceiling. The same crystal’s vibrations have none, so the crystal as a whole is never at a negative temperature.