Worked examples — Canonical ensemble — partition function Z
Before anything, three reminders of the symbols we lean on the whole way down:
Recall What is
and why do we use it instead of ? ::: . We use it because in the temperature only ever shows up multiplying an energy. Differentiating with respect to cleanly "pulls down" a factor of , which is exactly what an average energy needs.
Recall What is
(Planck's constant) and why does it appear in classical ? ::: is Planck's constant, with units of (energy time) = (position momentum). In a continuous system we sum over states by integrating over the position–momentum plane; each genuinely distinct state occupies a cell of area . Dividing by per degree of freedom turns "area of phase space" into a dimensionless count of states.
Recall The three master formulas we will re-use
::: partition function (sum of Boltzmann weights) ::: average energy ::: energy fluctuation (the spread of about )
The scenario matrix
Every problem a partition function can throw at you falls into one of these cells. The examples below are labelled by which cell they hit; together they cover the whole grid.
| Cell | What makes it different | Example |
|---|---|---|
| A. Cold limit | system freezes into lowest state(s) | Ex 1 |
| B. Hot limit | all states equally likely | Ex 1 |
| C. Degeneracy | levels counted with multiplicity | Ex 2 |
| D. Discrete, infinite ladder | geometric series, must converge | Ex 3 |
| E. Continuous / classical | phase-space integral, Gaussians | Ex 4 |
| F. Fluctuations & heat capacity | second derivative of | Ex 5 |
| G. Many independent particles | factorization , and the | Ex 6 |
| H. Real-world word problem | pick states from physics, then compute | Ex 7 |
| I. Exam twist / degenerate zero | a level shift or a -style trap | Ex 8 |
Ex 1 — Two-level system: both temperature extremes (cells A + B)
Step 1 — Write . Why this step? is by definition the sum of Boltzmann weights over all states — here there are exactly two.
Step 2 — Differentiate. Why this step? The master formula converts "I have " into "I have the average energy" with one derivative — no summing by hand.
Step 3 — Cold limit (cell A). . Why this step? Limits are the cheapest correctness test; they must match physics.
Step 4 — Hot limit (cell B). .
Step 5 — At we have , so .
Recall Numeric value at
:::
Verify: Cold gives ✓, hot gives ✓ (both match the forecast). Units: every term in carries a factor (an energy), the rest is dimensionless — good.
The figure below plots exactly this . Follow the blue curve rising from (cold) up toward the red dashed ceiling at (hot); the yellow dot marks our special point where . Notice the curve never overshoots — energy has nowhere hotter to go than the 50/50 mixture.

Ex 2 — A degenerate three-level system (cell C)
Step 1 — Build with multiplicity. Why this step? Each microstate contributes its own Boltzmann factor. Three microstates at energy contribute . This is the rule in action.
Step 2 — Average energy. Why this step? Same master formula; the degeneracy simply rides along inside .
Step 3 — Hot limit. . Why this step? Confirms the "all four states equal" prediction.
Verify: Cold limit gives ✓. Hot limit ✓ matches forecast. If we set we recover Ex 1's ✓ — the formula degrades gracefully.
Ex 3 — Quantum harmonic oscillator: an infinite ladder (cell D)
Step 1 — Write the sum. Why this step? Pulling out the constant exposes a plain geometric series with common ratio .
Step 2 — Check the ratio is below 1, then sum. Temperature is always positive, so , and ; therefore the exponent is negative, which makes a number strictly between and . A geometric series with converges to : Why this step? The series converges precisely because — the fact that energies grow without bound is exactly what forces below and guarantees a finite answer.
Step 3 — Rewrite as a . Multiply top and bottom by . The numerator ; the denominator becomes , which is exactly by the definition : Why this step? The form is compact and its logarithm differentiates cleanly in the next step.
Step 4 — Average energy. Why this step? The master derivative again; the first term is zero-point energy, the second is the thermal Planck occupation.
Step 5 — High- limit. For , , so . Why this step? Must match the classical oscillator result — quantum and classical agree once thermal energy dwarfs the level spacing.
Verify: Low- limit gives (pure zero-point) ✓. High- gives ✓, matching parent Example 2.
The figure contrasts the two curves. The blue quantum curve flattens onto the green dotted floor as it cools (energy freezes at the zero-point value), while the yellow dashed classical line slides straight through the origin. Watch how blue and yellow merge on the right: once , quantization is invisible.

Ex 4 — Free particle in a box: continuous phase space (cell E)
Step 1 — Set up the phase-space integral. Why this step? For a continuous system we sum over states by integrating over phase space , dividing by Planck's constant (see the recall box above) so each cell of area counts as one state.
Step 2 — Do the integrals. The -integral is just ; the -integral is a Gaussian with : Why this step? The Gaussian is the tool because is exactly the Gaussian shape; its area is a known standard result, so no numerical work is needed.
Step 3 — Average energy. Write : Why this step? Only the -dependence matters for the derivative; the box length and both sit in the constant and drop out.
Verify: One quadratic DOF ✓ (matches forecast and the Equipartition theorem). Units: has units of = energy ✓.
Ex 5 — Two-level fluctuations and heat capacity (cell F)
Before this example we need one new quantity.
Step 1 — Fluctuation from . With , Why this step? The second derivative of is the variance of energy — that identity (from the parent note) turns "compute a spread" into "differentiate twice".
Step 2 — Heat capacity via . Why this step? The fluctuation–response link lets us get without ever differentiating with respect to directly.
Step 3 — Limits. As , the factor . As , the prefactor . So at both ends. Why this step? Confirms the anomaly's two shoulders.
Step 4 — Locate the peak numerically. Maximizing over gives the peak at , i.e. .
Recall Peak of the Schottky heat capacity
::: (where )
Verify: both limits ✓. Peak sits near ✓ as forecast.
In the figure the red curve is : it starts at zero on the cold left, rises to a single hump, then decays back to zero on the hot right. The yellow dot marks the peak at . This lone bump — not a step, not a plateau — is the fingerprint of a two-level system in real heat-capacity data.

Ex 6 — independent atoms: factorization and the trap (cell G)
Step 1 — Factorize. Total energy , so Why this step? , and a sum over independent labels splits into a product of independent sums. This is why is so powerful for large systems.
Step 2 — Total energy. , so Why this step? The logarithm turns the product into a sum, and energy is extensive — it scales linearly with .
Step 3 — The indistinguishable case. If instead these were free identical gas particles, we divide: . Why this step? Swapping two identical particles is not a new microstate; the product overcounts by . Dropping this factor breaks the extensivity of entropy — the Gibbs paradox.
Verify: For distinguishable atoms energies simply add, so ✓. The multiplies by a constant (independent of ), so it changes the free energy and entropy (introduced in Ex 8 and in Helmholtz free energy F) but not — a useful sanity check.
Ex 7 — Real-world word problem: paramagnet in a field (cell H)
Step 1 — Choose states and energies from the physics. Two states: aligned with energy and anti-aligned with energy . So Why this step? The word problem hands us no formula — we must first translate "aligned/anti-aligned" into concrete energies before any machinery applies. The two exponentials combine into by the definition .
Step 2 — Average the observable . Magnetization is , with : Why this step? The Boltzmann distribution weights any observable, not just energy. The aligned state (larger weight, since it has lower energy) carries ; the ratio of the -like top to the -like bottom is exactly .
Step 3 — Cold limit (cell A flavour). , so : every spin locks onto the field. Why this step? At zero temperature there is no energy to borrow, so the system sits in its lowest state — fully aligned.
Step 4 — Hot limit (cell B flavour). , so : the two orientations become equally likely and cancel. Why this step? Infinite temperature erases the energy bias; up and down are equiprobable.
Verify: for ✓ (aligned with the field, matching the forecast). Reversing the field flips the sign of (the function is odd in ) ✓ — physically the magnetization follows the field direction. Units: carries the moment and is dimensionless ✓.
Ex 8 — Exam twist: shifting the energy zero (cell I)
First, the two thermodynamic quantities this example checks:
Step 1 — New partition function. Why this step? The common factor pulls straight out of the sum, so is just times a constant weight.
Step 2 — Probabilities are invariant. . Why this step? The shift cancels top and bottom — this is why only energy differences are ever physical.
Step 3 — Energy and free energy shift by . Using : Why this step? The term differentiates to for the energy, and for (since ). Both shift by the sea-level change, as they must.
Step 4 — Entropy is unchanged. . Why this step? cancels in the difference , so entropy — a count of accessible states — cannot depend on where we put zero energy.
Step 5 — The trap. A level with degeneracy contributes : it simply doesn't exist and adds nothing to . No divergence, no special case — a "missing" level is invisible to the sum. Why this step? Exam questions love to insert a phantom level; the sum handles it automatically.
Verify: Probabilities unchanged ✓ (a constant energy shift is unphysical). and both shift by ✓; entropy unchanged ✓ — all matching the forecast.