Thermodynamic Quantities from the Partition Function

Thermodynamics gives you a web of relations — dU=T dS−p dV+μ dN\mathrm dU=T\,\mathrm dS-p\,\mathrm dV+\mu\,\mathrm dN, Maxwell relations, response functions — but it never tells you the value of anything. It cannot predict the pressure of argon at 300 K300\text{ K} or the entropy of a mole of neon; those numbers have to be measured and fed in. Statistical mechanics closes that gap with a single object. Once you know the energy spectrum {Ei}\{E_i\} of a system and form the canonical partition function Z(T,V,N)=∑ie−βEiZ(T,V,N)=\sum_i e^{-\beta E_i}, every thermodynamic quantity becomes a derivative of ln⁡Z\ln Z — a fixed, mechanical recipe with no further physics required. This article is that recipe. The cleanest bridge is the Helmholtz free energy F=−kBTln⁡ZF=-k_BT\ln Z. Because dF=−S dT−p dV+μ dN\mathrm dF=-S\,\mathrm dT-p\,\mathrm dV+\mu\,\mathrm dN, the natural variables of FF are exactly (T,V,N)(T,V,N) — the variables ZZ already depends on — so entropy, pressure, and chemical potential are each a single partial derivative. Internal energy comes even more directly as U=−∂βln⁡ZU=-\partial_\beta\ln Z. First derivatives give the averages (U,S,p,μU,S,p,\mu); second derivatives give the widths of the distributions and the response coefficients, the archetype being ⟨ΔE2⟩=kBT2CV\langle\Delta E^2\rangle=k_BT^2C_V. The article's owned result is that all four state functions descend from one scalar ln⁡Z(T,V,N)\ln Z(T,V,N) and that the extraction is self-consistent: the Gibbs–Helmholtz identity U=∂β(βF)U=\partial_\beta(\beta F) recovers U=−∂βln⁡ZU=-\partial_\beta\ln Z, and S=−∂TFS=-\partial_T F agrees with S=kB(ln⁡Z+βU)S=k_B(\ln Z+\beta U) — the loop closes symbolically. We run the whole machine on the monatomic ideal gas end to end: spectrum in, and out come pV=NkBTpV=Nk_BT, U=32NkBTU=\tfrac32Nk_BT, the Sackur–Tetrode entropy with its 52\tfrac52, and μ=kBTln⁡(nλT3)\mu=k_BT\ln(n\lambda_T^3). Every number here is python-verified.

⚡ Key Takeaways
  • The canonical partition function Z(T,V,N)=∑ie−βEiZ(T,V,N)=\sum_i e^{-\beta E_i} is the generating function of equilibrium thermodynamics: every macroscopic quantity is a derivative of ln⁡Z\ln Z (β=1/kBT\beta=1/k_BT).
  • Internal energy is U=−∂βln⁡ZU=-\partial_\beta\ln Z; the Helmholtz free energy F=−kBTln⁡ZF=-k_BT\ln Z is the single most economical bridge to thermodynamics.
  • Entropy, pressure, and chemical potential are first derivatives of FF: S=−∂TFS=-\partial_T F, p=−∂VFp=-\partial_V F, μ=∂NF\mu=\partial_N F, matching dF=−S dT−p dV+μ dN\mathrm dF=-S\,\mathrm dT-p\,\mathrm dV+\mu\,\mathrm dN.
  • Second derivatives give fluctuations and response: ⟨ΔE2⟩=∂β2ln⁡Z=kBT2CV\langle\Delta E^2\rangle=\partial_\beta^2\ln Z=k_BT^2C_V is the prototype fluctuation–response relation.
  • The recipe is self-consistent (Gibbs–Helmholtz U=∂β(βF)U=\partial_\beta(\beta F) closes the F↔U↔SF\leftrightarrow U\leftrightarrow S loop) and modular (open the system → replace ZZ by Ξ\Xi, FF by Ω\Omega; the derivative machine is identical).
  • Key idea: one scalar function ln⁡Z(T,V,N)\ln Z(T,V,N) generates all of equilibrium thermodynamics — its first derivatives are the averages U,S,p,μU,S,p,\mu and its second derivatives are the fluctuations and response functions.
💡 The Core Insight

All of equilibrium thermodynamics is encoded in one scalar, ln⁡Z(T,V,N)\ln Z(T,V,N). First derivatives generate the averages — U=−∂βln⁡ZU=-\partial_\beta\ln Z, and S,p,μS,p,\mu from F=−kBTln⁡ZF=-k_BT\ln Z via dF=−S dT−p dV+μ dN\mathrm dF=-S\,\mathrm dT-p\,\mathrm dV+\mu\,\mathrm dN — while second derivatives generate the fluctuations and response functions (⟨ΔE2⟩=kBT2CV\langle\Delta E^2\rangle=k_BT^2C_V). The extraction is self-consistent by the Gibbs–Helmholtz identity.

The physical picture

Picture ln⁡Z(β,V,N)\ln Z(\beta,V,N) as a single smooth surface floating over the (β,V,N)(\beta,V,N) space. Nothing else is needed: the slope of that surface along β\beta is the average energy, the slope along VV is (up to kBTk_BT) the pressure, the slope along NN is the chemical potential, and the curvature along β\beta is the energy variance — which is the heat capacity. Thermodynamics is the differential geometry of this one surface. That is the whole content of the subject once ZZ is known. Why does a slope of ln⁡Z\ln Z give an average? Purely mechanically: differentiating Z=∑ie−βEiZ=\sum_i e^{-\beta E_i} with respect to β\beta pulls a factor −Ei-E_i out of each term, and dividing by ZZ turns the sum into a Boltzmann-weighted average, −∂βln⁡Z=1Z∑iEie−βEi=⟨E⟩-\partial_\beta\ln Z=\frac1Z\sum_i E_i e^{-\beta E_i}=\langle E\rangle. Every formula in this article is this same trick applied to a different variable — differentiate with respect to VV instead and you pull out ∂Ei/∂V\partial E_i/\partial V, the microscopic force, whose average is minus the pressure.

Figure
One scalar ln Z, four state functions. Each arrow is a single derivative: ∂ᵦ gives U, ∂ᵥ gives p, ∂ₙ gives μ, and −k_BT ln Z is F itself. Second derivatives (curvature) give the fluctuations.
ln Z (T, V, N) U = −∂ᵦ ln Z S = −∂_T F p = k_BT ∂ᵥ ln Z μ = −k_BT ∂ₙ ln Z F = −k_BT ln Z (bridge)

There is a deeper reason first and second derivatives split so cleanly into "averages" and "widths." Because ln⁡Z\ln Z is the logarithm of a sum of exponentials, it is the cumulant-generating function of the energy distribution: its nn-th β\beta-derivative is the nn-th cumulant of EE. The first cumulant is the mean, ⟨E⟩\langle E\rangle; the second is the variance, ⟨ΔE2⟩\langle\Delta E^2\rangle; and no fresh assumption is needed — averages and fluctuations live in the same object because they are successive derivatives of it. The punchline plot below shows the payoff: for the ideal gas, one ln⁡Z(T)\ln Z(T) curve simultaneously delivers UU (its β\beta-slope), SS (its TT-slope of FF), and CVC_V (its curvature) — four thermodynamic quantities read off one graph.

Figure
The ideal-gas ln Z(T) at fixed V, N. Its β-slope is U = 3/2 N k_BT (linear in T), its curvature feeds C_V = 3/2 N k_B (constant), and −k_BT ln Z is F. One curve, all the thermodynamics.
Tln Z ln Z grows as (3/2)N ln T + … slope → U curvature → C_V = 3/2 N k_B

The core equations

Everything begins with one sum. The canonical partition function collects the Boltzmann weight of every microstate, or equivalently every energy level weighted by its degeneracy Ω(E)\Omega(E). It is the normalization that makes the probabilities pi=e−βEi/Zp_i=e^{-\beta E_i}/Z sum to one, and it is the generating object for all that follows.

Z(β,V,N)=∑ie−βEi=∑EΩ(E) e−βE,β=1kBT(1)Z(\beta,V,N)=\sum_i e^{-\beta E_i}=\sum_E \Omega(E)\,e^{-\beta E},\qquad \beta=\frac{1}{k_BT} \qquad (1)

where: ZZ — canonical partition function (dimensionless); EiE_i — energy of microstate ii, which depends on VV and NN; Ω(E)\Omega(E) — degeneracy / density of states at energy EE. The dependence of the levels on volume is what makes pressure computable. The internal energy is the first β\beta-derivative of ln⁡Z\ln Z. This is the mechanical trick in its purest form: differentiating brings down a factor of energy and dividing by ZZ averages it.

U=⟨E⟩=−(∂ln⁡Z∂β)V,N=kBT2(∂ln⁡Z∂T)V,N(2)U=\langle E\rangle=-\left(\frac{\partial\ln Z}{\partial\beta}\right)_{V,N}=k_BT^2\left(\frac{\partial\ln Z}{\partial T}\right)_{V,N} \qquad (2)

where: UU — internal energy. The second form follows from ∂β=−kBT2∂T\partial_\beta=-k_BT^2\partial_T (chain rule for β=1/kBT\beta=1/k_BT), and is the version to use when your ZZ is written in terms of TT. The Helmholtz free energy is the single bridge from which SS, pp, and μ\mu all descend, because its differential exactly matches the variables ZZ depends on.

F=−kBTln⁡Z,dF=−S dT−p dV+μ dN(3)F=-k_BT\ln Z,\qquad \mathrm dF=-S\,\mathrm dT-p\,\mathrm dV+\mu\,\mathrm dN \qquad (3)

where: FF — Helmholtz free energy. Reading off the three partials gives the master trio: S=−(∂F/∂T)V,NS=-(\partial F/\partial T)_{V,N}, p=−(∂F/∂V)T,Np=-(\partial F/\partial V)_{T,N}, μ=(∂F/∂N)T,V\mu=(\partial F/\partial N)_{T,V} — the pressure and chemical potential carry no explicit kBTk_BT prefactor when written through FF; they do when written directly through ln⁡Z\ln Z. Written directly through ln⁡Z\ln Z, the same three quantities are:

S=kB ⁣(ln⁡Z+βU),p=kBT ⁣(∂ln⁡Z∂V)T,N,μ=−kBT ⁣(∂ln⁡Z∂N)T,V(4)S=k_B\!\left(\ln Z+\beta U\right),\quad p=k_BT\!\left(\frac{\partial\ln Z}{\partial V}\right)_{T,N},\quad \mu=-k_BT\!\left(\frac{\partial\ln Z}{\partial N}\right)_{T,V} \qquad (4)

where: SS — entropy; pp — pressure; μ\mu — chemical potential. The entropy form is S=(U−F)/TS=(U-F)/T rewritten: S=kBln⁡Z+U/TS=k_B\ln Z+U/T. Every equilibrium quantity is now a derivative of the one scalar ln⁡Z\ln Z. Second derivatives generate fluctuations and response. The archetype links the energy variance (a property of the equilibrium ensemble) to the heat capacity (how the system responds to heating):

⟨ΔE2⟩=(∂2ln⁡Z∂β2)V,N=−(∂U∂β)V,N=kBT2 CV(5)\langle\Delta E^2\rangle=\left(\frac{\partial^2\ln Z}{\partial\beta^2}\right)_{V,N}=-\left(\frac{\partial U}{\partial\beta}\right)_{V,N}=k_BT^2\,C_V \qquad (5)

where: CV=(∂U/∂T)V,NC_V=(\partial U/\partial T)_{V,N} — heat capacity at constant volume. Because a variance is non-negative, this forces CV≥0C_V\ge0: thermal stability is guaranteed by statistics, and relative fluctuations shrink as N−1/2N^{-1/2}.

Derivation AThe master table: all four state functions from one scalar ln Z, and the self-consistency loop

This is the article's owned result. The claim is stronger than "you can compute thermodynamics from ZZ": it is that the four state functions U,S,p,μU,S,p,\mu are literally derivatives of the single scalar ln⁡Z(T,V,N)\ln Z(T,V,N), and that the extraction is internally consistent — the two routes to UU (directly as −∂βln⁡Z-\partial_\beta\ln Z, and thermodynamically via the Gibbs–Helmholtz identity from FF) must agree, and the two routes to SS (as −∂TF-\partial_T F and as kB(ln⁡Z+βU)k_B(\ln Z+\beta U)) must agree. The goal is to assemble the table and then prove the loop closes, so the recipe cannot be self-contradictory. The strategy: define F=−kBTln⁡ZF=-k_BT\ln Z, read off its partials, then verify the Gibbs–Helmholtz round-trip U=∂β(βF)U=\partial_\beta(\beta F) recovers Eq. (2).

Step 1. Assemble the four averages. From F=−kBTln⁡ZF=-k_BT\ln Z with dF=−S dT−p dV+μ dN\mathrm dF=-S\,\mathrm dT-p\,\mathrm dV+\mu\,\mathrm dN:   U=−∂βln⁡Z\;U=-\partial_\beta\ln Z,   S=−∂TF=kBln⁡Z+U/T\;S=-\partial_T F=k_B\ln Z+U/T,   p=−∂VF=kBT ∂Vln⁡Z\;p=-\partial_V F=k_BT\,\partial_V\ln Z,   μ=∂NF=−kBT ∂Nln⁡Z\;\mu=\partial_N F=-k_BT\,\partial_N\ln Z. Why: FF's natural variables are (T,V,N)(T,V,N), exactly what ZZ depends on, so each conjugate variable is one clean partial — no Legendre transform or extra input required.

Step 2. Check the two roads to SS meet. The thermodynamic definition gives S=−∂TF=−∂T(−kBTln⁡Z)=kBln⁡Z+kBT ∂Tln⁡Z=kBln⁡Z+U/TS=-\partial_T F=-\partial_T(-k_BT\ln Z)=k_B\ln Z+k_BT\,\partial_T\ln Z=k_B\ln Z+U/T, using U=kBT2∂Tln⁡ZU=k_BT^2\partial_T\ln Z from Eq. (2). This is identical to S=kB(ln⁡Z+βU)S=k_B(\ln Z+\beta U). Why: the product rule on −kBTln⁡Z-k_BT\ln Z produces one term that is kBln⁡Zk_B\ln Z and one that is exactly U/TU/T — the entropy formula is not an independent postulate but a consequence of the definitions.

Step 3. Close the Gibbs–Helmholtz loop for UU. Write βF=β(−kBTln⁡Z)=−ln⁡Z\beta F=\beta(-k_BT\ln Z)=-\ln Z (since βkBT=1\beta k_BT=1). Differentiate with respect to β\beta at fixed V,NV,N:   ∂β(βF)=−∂βln⁡Z=U\;\partial_\beta(\beta F)=-\partial_\beta\ln Z=U. So U=∂β(βF)U=\partial_\beta(\beta F), and equivalently U=−T2 ∂T(F/T)U=-T^2\,\partial_T(F/T). Why: this is the Gibbs–Helmholtz relation; it reproduces the direct definition U=−∂βln⁡ZU=-\partial_\beta\ln Z from the free energy alone, proving the two definitions of UU are one and the same.

Step 4. Conclude self-consistency. The two independent routes to UU agree (Step 3) and the two routes to SS agree (Step 2); pp and μ\mu each have a single definition. Therefore the map ln⁡Z↦(U,S,p,μ)\ln Z\mapsto(U,S,p,\mu) is well-defined and cannot contradict itself: it is one scalar generating four mutually consistent state functions. Why: a recipe that computes the same quantity two ways and gets two answers would be worthless — the closed loop is what certifies that ln⁡Z\ln Z deserves to be called the generating function of thermodynamics. *Verified: S=−∂TFS=-\partial_T F equals kB(ln⁡Z+βU)k_B(\ln Z+\beta U) and U=∂β(βF)=−T2∂T(F/T)=−∂βln⁡ZU=\partial_\beta(\beta F)=-T^2\partial_T(F/T)=-\partial_\beta\ln Z all confirmed symbolically in verify_aq-sm-thermodynamics-from-partition-function.py.*

Derivation BThe whole ideal gas from its spectrum: PV=Nk_BT, U=3/2 Nk_BT, Sackur-Tetrode S, and mu

The goal is to run the complete extraction machine once, on the monatomic ideal gas, so that a single ln⁡Z\ln Z delivers all four state functions with their exact numerical prefactors — the ideal-gas law, the equipartition energy, the Sackur–Tetrode entropy with its characteristic 52\tfrac52, and the chemical potential μ=kBTln⁡(nλT3)\mu=k_BT\ln(n\lambda_T^3). This is the concrete payoff of the master table: no separate derivation for each quantity, just four derivatives of one function. The strategy is to compute the single-particle Z1Z_1, factorize with the Gibbs 1/N!1/N!, and differentiate ln⁡Z\ln Z term by term.

Step 1. Build ln⁡Z\ln Z. With H=p2/2mH=p^2/2m the single-particle partition function is Z1=V/λT3Z_1=V/\lambda_T^3, λT=h/2πmkBT\lambda_T=h/\sqrt{2\pi m k_BT}, so ZN=Z1N/N!Z_N=Z_1^N/N! and ln⁡Z=Nln⁡(V/λT3)−ln⁡N!≈Nln⁡ ⁣(V/NλT3)+N\ln Z=N\ln(V/\lambda_T^3)-\ln N!\approx N\ln\!\big(V/N\lambda_T^3\big)+N using Stirling. Note λT3∝T−3/2\lambda_T^3\propto T^{-3/2}, so ln⁡Z\ln Z contains +32Nln⁡T+\tfrac32N\ln T. Why: the Gaussian momentum integral gives λT\lambda_T, the 1/N!1/N! replaces VV by V/NV/N to keep FF extensive, and isolating the TT-dependence in λT\lambda_T is what makes the temperature derivatives trivial.

Step 2. Energy and pressure. U=−∂βln⁡Z=kBT2∂Tln⁡Z=kBT2⋅3N2T=32NkBTU=-\partial_\beta\ln Z=k_BT^2\partial_T\ln Z=k_BT^2\cdot\tfrac{3N}{2T}=\tfrac32Nk_BT, so CV=32NkBC_V=\tfrac32Nk_B. And p=kBT ∂Vln⁡Z=kBT⋅N/Vp=k_BT\,\partial_V\ln Z=k_BT\cdot N/V, i.e. pV=NkBTpV=Nk_BT. Why: only the 32Nln⁡T\tfrac32N\ln T term carries temperature (giving equipartition, 12kBT\tfrac12k_BT per momentum degree of freedom) and only the Nln⁡VN\ln V term carries volume (giving the ideal-gas law) — each state function reads off its own term.

Step 3. Entropy. S=kBln⁡Z+U/T=NkB[ln⁡(V/NλT3)+1]+32NkB=NkB[ln⁡(V/NλT3)+52]S=k_B\ln Z+U/T=Nk_B\big[\ln(V/N\lambda_T^3)+1\big]+\tfrac32Nk_B=Nk_B\big[\ln(V/N\lambda_T^3)+\tfrac52\big] — the Sackur–Tetrode form. The 32\tfrac32 from U/T=32NkBU/T=\tfrac32Nk_B combines with the +1+1 from Stirling to make the famous 52\tfrac52. Why: the 52\tfrac52 is not arbitrary — it is exactly 11 (Gibbs correction) plus 32\tfrac32 (three translational half-degrees), a fingerprint of monatomic translational motion counted correctly.

Step 4. Chemical potential. μ=−kBT ∂Nln⁡Z=−kBT ∂N[Nln⁡(V/NλT3)+N]=kBTln⁡(NλT3/V)=kBTln⁡(nλT3)\mu=-k_BT\,\partial_N\ln Z=-k_BT\,\partial_N\big[N\ln(V/N\lambda_T^3)+N\big]=k_BT\ln(N\lambda_T^3/V)=k_BT\ln(n\lambda_T^3), with n=N/Vn=N/V. Since a classical gas is dilute, nλT3≪1n\lambda_T^3\ll1, so μ<0\mu<0 (strongly negative). Why: ∂N\partial_N of Nln⁡(V/N)N\ln(V/N) leaves ln⁡(V/N)−1\ln(V/N)-1, which combines with the explicit +N+N to give the compact ln⁡(nλT3)\ln(n\lambda_T^3) — the chemical potential measures the free-energy cost of adding one particle, negative because there is entropic room for it. *Verified: U=32NkBTU=\tfrac32Nk_BT, pV=NkBTpV=Nk_BT, S=NkB[ln⁡(V/NλT3)+52]S=Nk_B[\ln(V/N\lambda_T^3)+\tfrac52] (the 52\tfrac52), and μ=kBTln⁡(nλT3)\mu=k_BT\ln(n\lambda_T^3) all confirmed symbolically; argon at 300 K300\text{ K}, 1 atm1\text{ atm} gives S=154.8 J mol−1K−1S=154.8\text{ J mol}^{-1}\text{K}^{-1} in the verify script.*

Limiting cases

The extraction recipe in informative regimes:

CaseResultMeaning
High temperatureβ→0\beta\to0: ln⁡Z→ln⁡Ωtot\ln Z\to\ln\Omega_{\text{tot}}, U→EˉU\to\bar E, S→kBln⁡ΩtotS\to k_B\ln\Omega_{\text{tot}}All states equally weighted; entropy saturates at kBln⁡(states)k_B\ln(\text{states}).
Low temperatureβ→∞\beta\to\infty: F→E0−kBTln⁡g0F\to E_0-k_BT\ln g_0, U→E0U\to E_0, S→kBln⁡g0S\to k_B\ln g_0Ground level dominates; residual entropy kBln⁡g0k_B\ln g_0 (third law if g0=1g_0=1).
Independent modesln⁡Z=∑aln⁡Za\ln Z=\sum_a\ln Z_aU,S,CVU,S,C_V all additive over modes; extensivity automatic.
Open systemZ→ΞZ\to\Xi, F→Ω=−kBTln⁡ΞF\to\Omega=-k_BT\ln\XiSame machine: N=−∂μΩN=-\partial_\mu\Omega, ⟨ΔN2⟩=kBT ∂μ⟨N⟩\langle\Delta N^2\rangle=k_BT\,\partial_\mu\langle N\rangle.
Ideal gaspV=NkBTpV=Nk_BT, U=32NkBTU=\tfrac32Nk_BT, SS = Sackur–TetrodeThe full worked example; four state functions from one ln⁡Z\ln Z.
⚠️ “Pressure is minus the derivative of the energy U with respect to volume”

It is tempting to write p=−∂U/∂Vp=-\partial U/\partial V by analogy with mechanics, but in the canonical ensemble that is wrong. Pressure is minus the derivative of the free energy at fixed temperature, p=−(∂F/∂V)T,N=kBT(∂ln⁡Z/∂V)T,Np=-(\partial F/\partial V)_{T,N}=k_BT(\partial\ln Z/\partial V)_{T,N} — not of the internal energy. The two differ by a T∂S/∂VT\partial S/\partial V term, which for a real system is not negligible: for the ideal gas (∂U/∂V)T=0(\partial U/\partial V)_T=0 entirely (energy is volume-independent), so −∂U/∂V-\partial U/\partial V would give zero pressure, an absurdity. The pressure comes wholly from the entropy's volume dependence — the gas pushes out because more volume means more accessible microstates, not because expanding lowers its energy. The general rule: every conjugate variable is a derivative of the potential whose natural variables include the one you hold fixed. Hold TT fixed → differentiate FF. Hold SS fixed → differentiate UU. Mixing them up is the single most common sign-and-factor error in the whole recipe. The same warning applies to μ\mu: it is +(∂F/∂N)T,V+(\partial F/\partial N)_{T,V}, not a derivative of UU.

Worked examples

1 · The full ideal gas: argon at room conditions (a real number, four ways)

Take one mole of argon (m=39.95 um=39.95\,u) at T=300 KT=300\text{ K} occupying V=0.024465 m3V=0.024465\text{ m}^3 (about 1 atm1\text{ atm}). Compute, from the one ln⁡Z\ln Z, the pressure, internal energy, molar entropy, and chemical potential — and check they are mutually consistent through F=U−TSF=U-TS.

Step 1. Thermal wavelength: λT=h/2πmkBT=15.95 pm\lambda_T=h/\sqrt{2\pi m k_BT}=15.95\text{ pm}, so nλT3=(NA/V)λT3=9.98×10−8n\lambda_T^3=(N_A/V)\lambda_T^3=9.98\times10^{-8} — indeed ≪1\ll1, the gas is safely classical.

Step 2. Pressure and energy from the derivatives: p=NkBT/V=1.02×105 Pa=1.01 atmp=Nk_BT/V=1.02\times10^{5}\text{ Pa}=\mathbf{1.01\text{ atm}}, and U=32NkBT=32RT=3741 J mol−1U=\tfrac32Nk_BT=\tfrac32RT=\mathbf{3741\text{ J mol}^{-1}} (with R=8.314R=8.314). These used only ∂Vln⁡Z\partial_V\ln Z and ∂βln⁡Z\partial_\beta\ln Z.

Step 3. Entropy from S=kBln⁡Z+U/TS=k_B\ln Z+U/T: S=NAkB[ln⁡(V/NAλT3)+52]=R[−16.12+2.5]S=N_Ak_B[\ln(V/N_A\lambda_T^3)+\tfrac52]=R[-16.12+2.5]… wait, carefully ln⁡(V/NAλT3)=−ln⁡(nλT3)=16.12\ln(V/N_A\lambda_T^3)=-\ln(n\lambda_T^3)=16.12, so S=R[16.12+2.5]=8.314×18.62=154.8 J mol−1K−1S=R[16.12+2.5]=8.314\times18.62=\mathbf{154.8\text{ J mol}^{-1}\text{K}^{-1}} — the measured standard molar entropy of argon.

Step 4. Chemical potential and the consistency check: μ=kBTln⁡(nλT3)=−6.68×10−20 J\mu=k_BT\ln(n\lambda_T^3)=-6.68\times10^{-20}\text{ J} per atom, i.e. μ=−40.2 kJ mol−1\mu=\mathbf{-40.2\text{ kJ mol}^{-1}} — strongly negative, as expected for a dilute gas. Finally F=U−TS=3741−300×154.8=−42.7 kJ mol−1F=U-TS=3741-300\times154.8=\mathbf{-42.7\text{ kJ mol}^{-1}}, and independently F=−kBTln⁡Z=−NkBT[ln⁡(V/NλT3)+1]=−R⋅300⋅17.12=−42.7 kJ mol−1F=-k_BT\ln Z=-Nk_BT[\ln(V/N\lambda_T^3)+1]=-R\cdot300\cdot17.12=-42.7\text{ kJ mol}^{-1} — the two ways to get FF agree, closing the loop numerically.

2 · The two-level system: energy from ln Z (exam level)

A system of NN independent, distinguishable two-level units has a gap ε\varepsilon (levels 00 and ε\varepsilon). Use only the extraction recipe to find UU, and evaluate it at kBT=εk_BT=\varepsilon.

Step 1. Spectrum → ZZ: each unit has Z1=1+e−βεZ_1=1+e^{-\beta\varepsilon}, so ln⁡Z=Nln⁡(1+e−βε)\ln Z=N\ln(1+e^{-\beta\varepsilon}) (distinguishable lattice sites, no 1/N!1/N!).

Step 2. Apply U=−∂βln⁡ZU=-\partial_\beta\ln Z: U=−N⋅−εe−βε1+e−βε=Nε e−βε1+e−βε=Nεeβε+1U=-N\cdot\dfrac{-\varepsilon e^{-\beta\varepsilon}}{1+e^{-\beta\varepsilon}}=\dfrac{N\varepsilon\,e^{-\beta\varepsilon}}{1+e^{-\beta\varepsilon}}=\dfrac{N\varepsilon}{e^{\beta\varepsilon}+1}.

Step 3. Boundary values: as T→0T\to0 (βε→∞\beta\varepsilon\to\infty), U→0U\to0 (all in the ground state); as T→∞T\to\infty (βε→0\beta\varepsilon\to0), U→Nε/2U\to N\varepsilon/2 (both levels equally full). The energy saturates — it cannot exceed Nε/2N\varepsilon/2, unlike a gas.

Step 4. At kBT=εk_BT=\varepsilon we have βε=1\beta\varepsilon=1, so U/(Nε)=1/(e+1)=1/3.718=0.269U/(N\varepsilon)=1/(e+1)=1/3.718=\mathbf{0.269}. The system holds only 26.9%26.9\% of its maximum energy when the thermal scale equals the gap — the same ln⁡Z\ln Z recipe that gave the ideal gas gives a bounded, saturating system with no change of method.

PF
partition function
statistical-mechanics concept · Gibbs 1902

The partition function is the hinge on which statistical mechanics turns: the object that converts a microscopic list of energies into every macroscopic thermodynamic number. Its name is a translation of the German Zustandssumme — "sum over states" — which is why it is universally denoted ZZ. J. Willard Gibbs gave it its modern, general role in his 1902 treatise Elementary Principles in Statistical Mechanics, where he showed that this single sum over the microstates of a system in a heat bath is a complete thermodynamic potential in disguise: differentiate its logarithm and out fall the energy, entropy, free energy, pressure, chemical potential, and all the fluctuations. The word "partition" reflects its dual job — it partitions the total probability among the microstates (via pi=e−βEi/Zp_i=e^{-\beta E_i}/Z) and it sums their Boltzmann weights. What makes it the central object of the whole field is precisely the theme of this article: thermodynamics is not a separate science bolted onto mechanics but the calculus of ln⁡Z\ln Z. The same construction reappears everywhere — as the Euclidean path integral of quantum field theory, as a transfer-matrix trace in lattice models, and as the (notoriously intractable) normalizing constant of probabilistic machine-learning models. Master how UU, SS, pp, and μ\mu descend from ln⁡Z\ln Z and you have mastered the core computational skill of statistical physics.

⏳ History
1868
— Boltzmann derives the exponential energy distribution for a system in thermal contact with a reservoir.
1900
— Planck evaluates a partition function over oscillator quanta to obtain the blackbody spectrum, introducing h and k_B.
1902
— Gibbs's Elementary Principles in Statistical Mechanics gives the partition function and the ensemble formalism their systematic, general form.
1907
— Einstein extracts the specific heat of solids from an oscillator partition function, explaining the low-T fall of C_V.
1912
— Sackur and Tetrode independently obtain the absolute entropy of a monatomic ideal gas, fixing the additive constant with h.

Where this lives today

The extraction machine is the daily workhorse of computational thermodynamics. In quantum chemistry and chemical engineering, molecular partition functions — factorized into translational, rotational, vibrational, and electronic pieces and assembled from spectroscopic constants — are differentiated exactly as in this article to tabulate standard entropies, enthalpies, Gibbs energies, and equilibrium constants; the JANAF and NIST thermochemical tables are, at bottom, vast collections of ln⁡Z\ln Z derivatives. In materials science, first-principles free energies from density-functional theory plus phonon partition functions predict phase diagrams by locating where two F(T,V)F(T,V) surfaces cross. The same recipe scales to the largest simulations in science. Lattice quantum chromodynamics computes the equation of state of hot nuclear matter — the pressure and entropy of the quark–gluon plasma probed at RHIC and the LHC — as numerical β\beta- and VV-derivatives of a partition function that is a 10910^9-dimensional path integral. And in machine learning, the "free energy" −ln⁡Z-\ln Z of an energy-based model (a Boltzmann machine, a diffusion model's score) is exactly the quantity whose gradients drive training; the intractability of ZZ that Gibbs never had to confront numerically is now the central computational bottleneck of the field. Wherever a system is described by an energy function and a temperature, the road from micro to macro still runs through the derivatives of ln⁡Z\ln Z.

Check yourself

Going further

References. Pathria & Beale, Statistical Mechanics, 3rd ed., Ch. 3 · Kardar, Statistical Physics of Particles, Ch. 4 · Reif, Fundamentals of Statistical and Thermal Physics, Ch. 6 · Sethna, Statistical Mechanics: Entropy, Order Parameters, and Complexity, Ch. 6 · Callen, Thermodynamics, Ch. 16 · Gibbs, Elementary Principles in Statistical Mechanics (1902).

Provenance. The extraction relations (U=−∂βln⁡ZU=-\partial_\beta\ln Z, F=−kBTln⁡ZF=-k_BT\ln Z, S=−∂TFS=-\partial_T F, p=−∂VFp=-\partial_V F, μ=∂NF\mu=\partial_N F, ⟨ΔE2⟩=kBT2CV\langle\Delta E^2\rangle=k_BT^2C_V) and the Gibbs–Helmholtz identity are standard (Pathria Ch. 3; Kardar Ch. 4). A verifier should reproduce: the ideal-gas chain U=32NkBTU=\tfrac32Nk_BT, pV=NkBTpV=Nk_BT, the Sackur–Tetrode 52\tfrac52, and μ=kBTln⁡(nλT3)\mu=k_BT\ln(n\lambda_T^3); the self-consistency loop S=−∂TF=kB(ln⁡Z+βU)S=-\partial_T F=k_B(\ln Z+\beta U) and U=∂β(βF)=−∂βln⁡ZU=\partial_\beta(\beta F)=-\partial_\beta\ln Z; and the two-level U=Nε/(eβε+1)U=N\varepsilon/(e^{\beta\varepsilon}+1). Numerical instances for argon at 300 K300\text{ K}, 1 atm1\text{ atm} (p=1.01 atmp=1.01\text{ atm}, U=3741 J/molU=3741\text{ J/mol}, S=154.8 J/mol/KS=154.8\text{ J/mol/K}, μ=−40.2 kJ/mol\mu=-40.2\text{ kJ/mol}, F=−42.7 kJ/molF=-42.7\text{ kJ/mol}) and the two-level value U/Nε=0.269U/N\varepsilon=0.269 at kBT=εk_BT=\varepsilon are recomputed in verify_aq-sm-thermodynamics-from-partition-function.py. hh, kBk_B, NAN_A (CODATA).

Builds on: Canonical Ensemble · Canonical Partition Function · Boltzmann Factor. Leads to: Helmholtz Free Energy from the Partition Function · Energy Fluctuations in the Canonical Ensemble · Heat Capacity and Fluctuation-Response Relation · Grand Potential.

Why is the free energy F, and not the energy U, the "master" potential to differentiate?

Because FF's natural variables are (T,V,N)(T,V,N) — precisely the variables the partition function depends on. Thermodynamics says dF=−S dT−p dV+μ dN\mathrm dF=-S\,\mathrm dT-p\,\mathrm dV+\mu\,\mathrm dN, so if you know F(T,V,N)F(T,V,N) you get SS, pp, and μ\mu as three clean partial derivatives. The internal energy UU, by contrast, has natural variables (S,V,N)(S,V,N); to get pp from UU you must hold entropy fixed, which is experimentally awkward and not what ZZ hands you. Since the canonical ensemble fixes TT (not SS), the free energy is the potential that matches the control variables. This is a general lesson: pick the thermodynamic potential whose natural variables are the ones you actually hold constant, and every conjugate quantity becomes a single derivative.

How can one function ln Z give both averages and fluctuations?

Because ln⁡Z\ln Z, viewed as a function of β\beta, is the cumulant-generating function of the energy distribution. Differentiating it with respect to −β-\beta once gives the first cumulant (the mean ⟨E⟩\langle E\rangle), twice gives the second cumulant (the variance ⟨ΔE2⟩\langle\Delta E^2\rangle), three times gives the third, and so on — this is the mathematical definition of a cumulant generator, and ln⁡\ln of a sum of exponentials is exactly one. Physically, the first derivative tracks how the average energy shifts as you cool the system (a response), and the second tracks how much the energy spontaneously jitters at fixed temperature (a fluctuation). Because they are consecutive derivatives of the same object, the fluctuation and the response turn out to be equal up to factors of kBT2k_BT^2 — that is the fluctuation–response theorem, ⟨ΔE2⟩=kBT2CV\langle\Delta E^2\rangle=k_BT^2C_V, built straight into the structure of ln⁡Z\ln Z.

Do I use β-derivatives or T-derivatives — they look different?

They are the same thing through the chain rule, and you should use whichever matches how your ZZ is written. Since β=1/kBT\beta=1/k_BT, we have ∂β=−kBT2 ∂T\partial_\beta=-k_BT^2\,\partial_T. So U=−∂βln⁡ZU=-\partial_\beta\ln Z becomes U=kBT2 ∂Tln⁡ZU=k_BT^2\,\partial_T\ln Z; both give the identical energy. If your partition function comes out naturally in β\beta (common for oscillators and two-level systems, where Z=1/(2sinh⁡(βℏω/2))Z=1/(2\sinh(\beta\hbar\omega/2)) or 1+e−βε1+e^{-\beta\varepsilon}), use ∂β\partial_\beta. If it comes out in TT (common for the ideal gas, where λT∝T−1/2\lambda_T\propto T^{-1/2} and ln⁡Z\ln Z contains 32Nln⁡T\tfrac32N\ln T), use ∂T\partial_T. The two conventions differ only by the factor −kBT2-k_BT^2, and mixing them up (forgetting that factor, or its sign) is a frequent slip — the sign is negative because raising TT lowers β\beta.

Why does the chemical potential of a classical gas come out negative?

Because μ=kBTln⁡(nλT3)\mu=k_BT\ln(n\lambda_T^3) and a classical gas is dilute, meaning nλT3≪1n\lambda_T^3\ll1, so the logarithm is a large negative number. Physically, μ\mu is the free-energy cost of adding one more particle at fixed TT and VV. Adding a particle to a dilute gas raises the entropy a lot (there is plenty of empty phase space for it), and since F=U−TSF=U-TS, a large entropy gain means a large decrease in free energy — hence a negative μ\mu. The quantity nλT3n\lambda_T^3 is the "phase-space occupancy": it compares the interparticle spacing to the thermal de Broglie wavelength. When it approaches 11, μ→0\mu\to0 and quantum statistics take over; the gas is on the verge of degeneracy. So the sign and size of μ\mu are a direct readout of how far a gas is from the quantum regime.

Is this recipe exact, or does it assume the thermodynamic limit?

The derivative relations themselves — U=−∂βln⁡ZU=-\partial_\beta\ln Z, F=−kBTln⁡ZF=-k_BT\ln Z, S=−∂TFS=-\partial_T F, and so on — are exact for any system in the canonical ensemble, of any size, with no thermodynamic-limit assumption. What does require large NN is the interpretation of these ensemble averages as sharp thermodynamic values. For small systems the energy genuinely fluctuates by a relative amount ⟨ΔE2⟩/U∼N−1/2\sqrt{\langle\Delta E^2\rangle}/U\sim N^{-1/2}, so "the" energy is only well-defined up to that spread. For a mole (N∼1024N\sim10^{24}) the spread is one part in 101210^{12} — utterly negligible — so the canonical UU is indistinguishable from a fixed number and matches the microcanonical result. The recipe is thus exact as a statement about averages, and becomes a statement about definite thermodynamic quantities only when NN is large enough to suppress fluctuations. This is also why ensembles become equivalent in the thermodynamic limit.

Where did the ground-state energy go — does the zero of energy matter?

For most quantities it does not, and for a few it does, so be consistent. If you shift every energy by a constant E0E_0, then Z→e−βE0ZZ\to e^{-\beta E_0}Z and ln⁡Z→ln⁡Z−βE0\ln Z\to\ln Z-\beta E_0. This changes UU by E0E_0 and FF by E0E_0 (as it must — you moved the origin), but it leaves the heat capacity, entropy, pressure, and all fluctuations completely unchanged, because those are derivatives that annihilate a constant. So for computing CVC_V, SS, or pp you may set the ground state to zero and forget E0E_0. Where it matters is any absolute energy or free energy that you compare across systems: chemical equilibrium constants depend on the real energy difference between reactant and product ground states, and the zero-point energy 12ℏω\tfrac12\hbar\omega of each vibrational mode is a genuine contribution. The rule: differences are physical, the overall zero is a convention, but be consistent whenever you compare two systems.

How does this canonical recipe carry over to open systems?

It carries over essentially unchanged, with two substitutions. When the system can exchange particles as well as energy with a reservoir, you replace the canonical partition function ZZ by the grand partition function Ξ=∑NeβμNZN\Xi=\sum_N e^{\beta\mu N}Z_N, and the Helmholtz free energy FF by the grand potential Ω=−kBTln⁡Ξ\Omega=-k_BT\ln\Xi. The derivative machine is identical: dΩ=−S dT−p dV−N dμ\mathrm d\Omega=-S\,\mathrm dT-p\,\mathrm dV-N\,\mathrm d\mu, so entropy, pressure, and now the average particle number ⟨N⟩=−(∂Ω/∂μ)T,V\langle N\rangle=-(\partial\Omega/\partial\mu)_{T,V} are single derivatives of Ω\Omega. Second derivatives give the new fluctuation: ⟨ΔN2⟩=kBT(∂⟨N⟩/∂μ)\langle\Delta N^2\rangle=k_BT(\partial\langle N\rangle/\partial\mu), the exact analogue of ⟨ΔE2⟩=kBT2CV\langle\Delta E^2\rangle=k_BT^2C_V. So learning the canonical recipe is not a special case — it is the template, and opening the system to particle flow just adds one more control variable (μ\mu) and one more fluctuation (⟨ΔN2⟩\langle\Delta N^2\rangle) to the same scheme.

Before this

Where this leads