The canonical ensemble describes systems that can exchange energy with a large heat bath at fixed temperature. It's one of the most practical tools in statistical mechanics because real experiments usually involve systems at controlled temperature rather than perfectly isolated ones. Through the partition function, the canonical ensemble connects microscopic energy levels to every thermodynamic quantity you'd want to calculate.
Definition of canonical ensemble
The canonical ensemble applies to a system in thermal equilibrium with a heat bath at fixed temperature . The system can exchange energy with its surroundings, so its energy fluctuates, but the average energy stays constant. This setup is the natural framework for calculating macroscopic properties from microscopic interactions.
System and heat bath
The "system" is whatever collection of particles you're studying. The "heat bath" (or thermal reservoir) is a much larger system whose temperature doesn't change when energy flows in or out, because its heat capacity is enormous compared to the system's.
- Energy flows freely between system and bath until thermal equilibrium is reached
- The system's temperature equals the bath temperature , which stays fixed
- The system's energy is not fixed; only the temperature is constrained
Probability distribution function
The probability of finding the system in microstate with energy follows the Boltzmann distribution:
where is the inverse temperature, is Boltzmann's constant, and is the partition function (defined below).
- Higher-energy microstates are exponentially less probable than lower-energy ones
- The factor is called the Boltzmann factor
- The normalization condition is what defines
Partition function
The partition function is the single most important quantity in the canonical ensemble. Once you have it, you can extract essentially all thermodynamic information about the system.
Derivation of partition function
Start from the normalization requirement on the Boltzmann distribution. Summing over all microstates and setting the result equal to 1 gives:
For systems with a continuous energy spectrum, the sum becomes an integral weighted by the density of states , which counts how many microstates exist at energy :
Properties of partition function
- depends on temperature, volume, and particle number, but not on which microstate the system happens to be in
- The Helmholtz free energy follows directly:
- Derivatives of with respect to , , or other parameters generate thermodynamic quantities (internal energy, pressure, entropy, etc.)
- acts as a generating function: taking successive derivatives produces ensemble averages and fluctuation measures
Thermodynamic quantities
All standard thermodynamic quantities can be derived from the partition function. The key relations are worth memorizing, since they come up constantly.
Internal energy
The internal energy is the ensemble average of the energy:
This includes all kinetic and potential energy contributions. As temperature rises, higher-energy microstates become more accessible, so generally increases with .
Entropy
Entropy in the canonical ensemble can be written in two equivalent ways. The Gibbs (or Shannon) form is:
Substituting the Boltzmann distribution into this expression and simplifying gives the more practical formula:
Entropy increases with temperature because more microstates become comparably probable at higher .
Helmholtz free energy
The Helmholtz free energy is the thermodynamic potential natural to the canonical ensemble (constant and ):
At constant temperature and volume, a system in equilibrium minimizes . This is the canonical ensemble's version of the second law.

Fluctuations in canonical ensemble
Because the system exchanges energy with the bath, its energy isn't perfectly sharp. These fluctuations carry physical meaning and connect directly to measurable response functions.
Energy fluctuations
The variance of the energy measures how broadly the energy is distributed around its mean:
A powerful result links this variance to the heat capacity:
The relative fluctuation scales as , where is the number of particles. For macroscopic systems (), relative fluctuations are negligibly small. This is why the canonical and microcanonical ensembles agree in the thermodynamic limit.
Specific heat
The heat capacity at constant volume is:
Equivalently, using the fluctuation relation:
This second form is useful because it shows that is always non-negative (it's a variance divided by positive quantities). Peaks or divergences in signal phase transitions, since large energy fluctuations occur near critical points.
Applications of canonical ensemble
Ideal gas
For non-interacting particles in a box, the single-particle partition function factorizes into translational, rotational, and vibrational contributions. The translational part alone gives:
where is the thermal de Broglie wavelength. From the full -particle partition function (with the Gibbs factor for indistinguishable particles), you recover the ideal gas law and the equipartition result: each quadratic degree of freedom contributes to the average energy.
Paramagnetism
Consider non-interacting spin- magnetic moments in an external field . Each spin has energy , so the single-spin partition function is:
From this you can derive the average magnetization and the Curie law for the magnetic susceptibility:
At low (large ), spins align with the field. At high , thermal fluctuations randomize the spins and the magnetization vanishes.
Harmonic oscillator
The quantum harmonic oscillator has energy levels with The partition function is a geometric series:
This result is central to modeling molecular vibrations and phonons in solids. At high temperature (), you recover the classical equipartition result . At low temperature, the system freezes into the ground state and the specific heat drops toward zero.
Canonical ensemble vs microcanonical ensemble
These two ensembles describe different physical setups. The microcanonical ensemble describes an isolated system at fixed energy . The canonical ensemble describes a system at fixed temperature in contact with a heat bath.
Equivalence in thermodynamic limit
As , the two ensembles give identical predictions for all intensive thermodynamic quantities. This happens because relative energy fluctuations vanish as , so the canonical energy distribution becomes sharply peaked around the microcanonical energy. In practice, you can use whichever ensemble makes the calculation easier.

Practical differences
- Canonical: fixes , allows energy fluctuations. Calculations are usually simpler because the partition function factorizes nicely for non-interacting systems.
- Microcanonical: fixes , no fluctuations. More fundamental conceptually, but the combinatorial counting of microstates is often harder.
- Most experimental setups correspond to the canonical ensemble (system in a thermostat), which is why it's used more frequently in practice.
Connection to statistical mechanics
Bridge to thermodynamics
The canonical ensemble provides explicit formulas connecting microscopic quantities to thermodynamic potentials:
- gives the Helmholtz free energy
- Differentiate to get entropy (), pressure (), and other response functions
- The second law of thermodynamics emerges naturally: the equilibrium state maximizes entropy (or equivalently minimizes at constant )
- Equations of state follow from appropriate derivatives of
Boltzmann factor
The Boltzmann factor is the fundamental weight in the canonical ensemble. It can be derived by considering a small system in contact with a large reservoir and using the microcanonical ensemble for the combined (system + reservoir) setup. The key steps:
-
The total system is isolated, so the combined system is microcanonical with total energy
-
The number of reservoir microstates when the system has energy is
-
Expanding to first order in (valid because ) yields
This derivation shows that temperature is fundamentally a statistical property, defined through of the reservoir.
Numerical methods
For systems with many interacting particles, the partition function can't be evaluated analytically. Numerical methods sample the Boltzmann distribution directly.
Monte Carlo simulations
Monte Carlo methods generate a sequence of configurations distributed according to . The most common algorithm is Metropolis-Hastings:
-
Start from some configuration with energy
-
Propose a random change (e.g., flip a spin, move a particle)
-
Calculate the energy change
-
If , accept the move
-
If , accept with probability ; otherwise reject
-
Repeat; after many steps, the sampled configurations follow the Boltzmann distribution
This approach is widely used for the Ising model, lattice gases, polymers, and other systems where direct summation over microstates is impossible.
Molecular dynamics
Molecular dynamics (MD) solves Newton's equations of motion numerically for all particles. To sample the canonical ensemble rather than the microcanonical one, you couple the system to a thermostat (e.g., Nosé-Hoover). MD provides both equilibrium thermodynamic averages and dynamical information like diffusion coefficients and time correlation functions. Applications range from protein folding to materials science.
Limitations and extensions
Quantum canonical ensemble
When quantum effects matter (low temperatures, light particles, discrete energy spectra), the classical sum over states is replaced by a trace over the quantum Hamiltonian:
This naturally incorporates quantum statistics: bosons obey Bose-Einstein statistics and fermions obey Fermi-Dirac statistics. Zero-point energy is included automatically. The quantum canonical ensemble is essential for understanding phenomena like superconductivity, superfluidity, and quantum phase transitions.
Non-equilibrium considerations
The canonical ensemble strictly applies only to systems in thermal equilibrium. For systems driven out of equilibrium by external forces, temperature gradients, or time-dependent fields, extensions are needed. Fluctuation theorems (like the Jarzynski equality) generalize free energy relations to non-equilibrium processes. These results connect irreversible work measurements to equilibrium free energy differences and are actively applied to biological systems, active matter, and driven quantum systems.