TL;DR
The partition function is one number that adds up the Boltzmann factor over every state a system can be in. Dividing each factor by gives the probability of that state. The logarithm of carries the thermodynamics: energy, entropy and free energy all come from it.
Where you'll see it: computing the average energy of a gas, a magnet or a molecule at a given temperature, predicting how a chemical reaction shifts with temperature, and estimating free-energy differences in computer simulations.
Intuition
A system at fixed temperature does not sit in one state. It keeps wandering through its possible states, and the Boltzmann distribution says how often it visits each one: low-energy states dominate, high-energy states are rarer (see Boltzmann Distribution). To turn that into numbers you need a normalising total, the sum of all the weights, so that the probabilities add to 1. That total is the partition function.
It is worth thinking of as a count of how many states the system effectively has access to at temperature . A state with energy far above contributes almost nothing to the count. A state with energy well below contributes almost one full unit. So is roughly the number of states that are "reachable" given the thermal energy available.
For a system with just two states, the ground state at energy 0 and an excited state at energy , the partition function is . The plot below shows how it depends on the ratio .
- two-state Z
The reason matters beyond normalising probabilities is that it packs all the thermodynamics into a single function. If you know how depends on temperature, you know the rest.
The math
Let a system have states labelled , with energies . Let be the absolute temperature in kelvin and the Boltzmann constant. Write as shorthand for the inverse thermal energy.
For a system in thermal equilibrium with a heat bath at temperature , the partition function is
The sum runs over every state of the system, counted once each. The probability of state is then .
Probabilities and averages
The probabilities follow directly from the definition, and they sum to 1 by construction: .
The average energy is the probability-weighted sum of the energies, . There is a shortcut. Differentiate with respect to :
So
One derivative of the logarithm gives the average energy. No separate sum over probabilities is needed.
Free energy and entropy
Define the Helmholtz free energy by
From with , the entropy follows as . Substituting gives
This also agrees with the Gibbs entropy . Taking the logarithm of gives . Multiplying by and summing gives , and since this is the same expression.
Differences between systems
Only ratios of partition functions are needed to compare two systems, or two conditions of the same system, at the same temperature. The free-energy difference is
This is why simulations often estimate ratios rather than itself. Any constant shift in all energies multiplies every term by the same factor , so it cancels from the probabilities and from differences of free energy, but it shifts the absolute value of by .
Worked examples
Example 1: a two-state magnet
A tiny magnet has two states. In a field its magnetic moment either aligns with the field, with energy , or points against it, with energy . Choose the temperature so that , which means .
- Boltzmann factors: aligned gives ; opposed gives .
- Partition function: .
- Probability aligned: .
- Probability opposed: .
- Average energy in units of : . This matches , the closed form from .
- Entropy in units of : .
Interpretation: the magnet is aligned about 88 percent of the time. Its entropy, 0.37 , is well below the maximum of that two equally likely states would give. The gap between the two states is large enough to bias the system, but not large enough to freeze it.
Example 2: a vibrating molecule
A diatomic molecule vibrates like a mass on a spring. Its energy levels are for , where is the energy quantum. Let . The partition function is a geometric series (see Summation Notation):
- Set , which means .
- Partition function: .
- Cross-check: the same value is .
- Ground-state probability: , which equals exactly.
- Average energy from the shortcut: .
- Check against the sum: the probabilities of levels to are , , , , and . Weighting their energies and adding the small tail gives about 1.08, in agreement with step 5.
Interpretation: at this temperature the molecule is in its ground level 63 percent of the time, and the average energy sits just above the zero-point energy . Now take a carbon monoxide bond, whose corresponds to about 3100 kelvin. At room temperature , so is close to and almost every molecule sits in the ground level. The partition function tells you that the vibration is frozen out and does not contribute to the heat capacity.
Tradeoffs and failure modes
The partition function at fixed temperature, volume and particle number is the right object for a system in contact with a heat bath. It stops being the right object when the setup changes.
| Situation | Problem | Better choice |
|---|---|---|
| The system is isolated, so its total energy is fixed | Temperature is not fixed, so the canonical does not apply | The microcanonical ensemble, which counts states with energy |
| Particles can exchange with a reservoir | The number of particles changes, so at fixed is incomplete | The grand partition function, which uses a Chemical Potential |
| Particles are identical | Counting each arrangement as distinct overcounts, which gives wrong entropy for gases | A correction for classical gases, or Fermi-Dirac Statistics and Bose statistics for quantum particles (see Indistinguishable Particles) |
| The state space is huge, for example many interacting spins | is a sum of exponentially many terms and cannot be enumerated | Sampling with the Metropolis Algorithm or Monte Carlo Method, which estimate averages without computing |
| Interactions are strong and near a critical point | has no simple closed form, and approximations break down | Coarse-graining methods such as the Renormalization Group |
Two more failure modes come up often in practice. First, the zero of energy is arbitrary. Shifting all energies changes by a constant factor and changes by the same shift, but leaves probabilities alone, so an answer for absolute free energy is only meaningful relative to a reference. Second, the equilibrium describes a system at rest. A system pushed far out of equilibrium does not have its populations given by the Boltzmann formula, although certain exact identities, such as the Jarzynski equality, still relate work done on it to equilibrium free-energy differences.
History
The idea grew out of Ludwig Boltzmann's work in the 1870s and 1880s on the statistical meaning of entropy. Boltzmann wrote the sum of weights over states as a single quantity, which in German is called the Zustandssumme, or state sum. It is the older name for what is now called the partition function. Exact dates for the early papers vary between sources, so treat the decade as approximate.
J. Willard Gibbs gave the systematic framework in his 1902 book on statistical mechanics, developing the ensembles and free-energy relations that are used today. The English name "partition function" came into use later. This framework made the sum over states the central tool of statistical mechanics.
The idea caught on because it turned thermodynamics into a calculation. Given the energy levels of a molecule, a crystal or a magnet, one function predicts its heat capacity, its entropy and its response to pressure or field. The same logic underlies modern simulation, where averages are estimated by sampling rather than by summing over all states.
Check yourself
QuestionRecall: what does dividing each Boltzmann factor by accomplish?Show answer
Each factor is a weight, not a probability, because the weights do not add up to 1. Dividing each one by , which is the sum of all the weights, turns them into probabilities that sum to 1. The division does not change the ratio between any two states.
QuestionComputation: a two-level system has a ground state at energy 0 and an excited state at energy . What is , and what fraction of the system is in the excited state?Show answer
. The excited-state probability is , so about 27 percent of the system is in the excited state.
QuestionWhy: the average energy is written as rather than as a sum of . What does the logarithm buy you?Show answer
Both give the same answer, but the derivative form needs only as a function of . Once is known in closed form, one differentiation gives the average energy, with no need to list every state and its probability. It also extends to the entropy and free energy, which all come from the same function.
QuestionApplied: a simulation needs the free-energy difference between two conditions of a molecule, but computing either directly is infeasible. Why is estimating the ratio enough?Show answer
The free-energy difference is , so the ratio is all that is needed. Common factors such as the zero-point energy and any constant prefactor cancel between the two conditions. Simulation methods can estimate such ratios by sampling transitions between the conditions, which avoids computing either partition function on its own.