Deriving the Boltzmann Distribution by Maximizing Weight

Imagine shaking a jar of a trillion trillion coins, each coin a molecule that can land on one of many energy levels. Only one arrangement of energies dominates overwhelmingly, and it dominates so completely that it is effectively the only arrangement ever observed. Finding that single dominant arrangement, by maximizing a weight function under fixed constraints, is how the Boltzmann distribution is actually derived rather than assumed. This derivation matters because it converts a combinatorial counting problem into the exponential population law that underlies nearly all of chemical thermodynamics. Reaction equilibria, spectroscopic intensities, and heat capacities all trace back to this single result. This article walks through the full derivation. You will see how Stirling's approximation tames huge factorials. You will see how Lagrange multipliers enforce fixed total particles and fixed total energy. You will arrive at the exponential population law and meet the two multipliers that become β\beta and the partition function later.

Key takeaways
  • The dominant configuration is the one that maximizes the statistical weight WW, subject to fixed total particles NN and fixed total energy EE.
  • Taking ln⁡W\ln W and applying Stirling's approximation turns a product of factorials into a manageable sum.
  • Two Lagrange multipliers, α\alpha and β\beta, enforce the constraints ∑ini=N\sum_i n_i = N and ∑iniεi=E\sum_i n_i \varepsilon_i = E.
  • Maximizing ln⁡W\ln W leads directly to ni∝e−βεin_i \propto e^{-\beta \varepsilon_i}, the Boltzmann population law.
  • Later work identifies β=1/kBT\beta = 1/k_BT and the normalizing sum as the molecular partition function qq.
  • Key idea: the Boltzmann distribution is not postulated — it is the unique population pattern that maximizes the number of microstates consistent with fixed NN and EE.
The core insight

Among all the ways to distribute NN molecules over energy levels while keeping the total number and total energy fixed, one distribution corresponds to vastly more microstates than any other, and locating it by maximizing ln⁡W\ln W with two Lagrange multipliers yields the exponential Boltzmann population law.

The physical picture

Consider NN molecules distributed among energy levels ε0,ε1,ε2,…\varepsilon_0, \varepsilon_1, \varepsilon_2, \dots with populations n0,n1,n2,…n_0, n_1, n_2, \dots. A particular set of populations is called a configuration. Prerequisite material shows that the number of microstates (ways of assigning distinguishable molecules to levels) realizing a given configuration is the statistical weight

W=N!n0! n1! n2!⋯W = \frac{N!}{n_0! \, n_1! \, n_2! \cdots}

For a mole of molecules, N≈6×1023N \approx 6 \times 10^{23}, and WW for the most probable configuration is so astronomically larger than WW for any neighboring configuration that fluctuations away from it are utterly negligible. This is the key physical fact that licenses replacing "the average over all configurations" by "the single most probable configuration." The task is therefore an optimization problem: find the set {ni}\{n_i\} that maximizes WW (equivalently ln⁡W\ln W, which is monotonic in WW and far easier to differentiate), subject to two physical constraints that cannot be relaxed — the total number of molecules is fixed at NN, and the total energy is fixed at EE. Without constraints, the trivial maximum of WW would just pile every molecule into one level or spread them arbitrarily; the constraints are what make the answer physically meaningful and produce the characteristic exponential decay of populations with energy. The method of Lagrange multipliers is the natural tool here because the constraints are equalities that couple all the nin_i together. Rather than eliminating variables, we introduce two multipliers, conventionally α\alpha and −β-\beta, one for each constraint, and extremize an augmented function. The resulting stationarity condition, applied level by level, gives an equation for each nin_i individually — this is the payoff of the Lagrange method: a coupled global problem decomposes into independent single-level equations.

Figure
Configurations compared: a sharply peaked weight function versus a flat guess
configuration index (populations n_i) ln W maximum at n_i* (Boltzmann) width ~ 1/sqrt(N): negligible for N = 6 x 10^23

The core relations

W=N!∏ini!W = \frac{N!}{\prod_i n_i!}

where: NN is the total number of molecules and nin_i is the population of level ii with energy εi\varepsilon_i.

ln⁡W≈Nln⁡N−N−∑i(niln⁡ni−ni)\ln W \approx N \ln N - N - \sum_i \left( n_i \ln n_i - n_i \right)

where: Stirling's approximation ln⁡x!≈xln⁡x−x\ln x! \approx x\ln x - x has been applied to N!N! and to every ni!n_i!.

∑ini=N,∑iniεi=E\sum_i n_i = N, \qquad \sum_i n_i \varepsilon_i = E

where: these are the fixed-total-particles and fixed-total-energy constraints, enforced with multipliers α\alpha and β\beta.

ni=eαe−βεin_i = e^{\alpha} e^{-\beta \varepsilon_i}

where: α\alpha fixes the overall scale (tied to NN) and β\beta controls how sharply population falls with energy.

niN=e−βεi∑je−βεj\frac{n_i}{N} = \frac{e^{-\beta \varepsilon_i}}{\sum_j e^{-\beta \varepsilon_j}}

where: the denominator is the molecular partition function q=∑je−βεjq = \sum_j e^{-\beta \varepsilon_j}, introduced properly in the next article.

Derivation AFrom maximizing W to the Boltzmann population law

Goal. Find the populations {ni}\{n_i\} that maximize the statistical weight W=N!/∏ini!W = N!/\prod_i n_i! subject to ∑ini=N\sum_i n_i = N and ∑iniεi=E\sum_i n_i \varepsilon_i = E, and show this forces ni∝e−βεin_i \propto e^{-\beta \varepsilon_i}.

Step 1. Take the logarithm. Because ln⁡\ln is monotonically increasing, maximizing WW is equivalent to maximizing ln⁡W\ln W, and logarithms convert the unwieldy product of factorials into a sum:

ln⁡W=ln⁡N!−∑iln⁡ni!\ln W = \ln N! - \sum_i \ln n_i!

Step 2. Apply Stirling's approximation. For large xx, ln⁡x!≈xln⁡x−x\ln x! \approx x \ln x - x. Since chemically relevant NN and every populated nin_i are enormous (of order Avogadro's number or a large fraction thereof), this approximation is essentially exact for our purposes:

ln⁡W≈(Nln⁡N−N)−∑i(niln⁡ni−ni)\ln W \approx \left( N \ln N - N \right) - \sum_i \left( n_i \ln n_i - n_i \right)

Using ∑ini=N\sum_i n_i = N, the two "−N-N" and "−∑ini-\sum_i n_i" terms cancel, leaving the compact working form

ln⁡W≈Nln⁡N−∑iniln⁡ni\ln W \approx N \ln N - \sum_i n_i \ln n_i

Step 3. Build the Lagrange function. We want to extremize ln⁡W\ln W subject to two constraints. Introduce multipliers α\alpha for the particle-number constraint and −β-\beta for the energy constraint, and form

L=ln⁡W+α ⁣(N−∑ini)−β ⁣(E−∑iniεi)\mathcal{L} = \ln W + \alpha\!\left( N - \sum_i n_i \right) - \beta\!\left( E - \sum_i n_i \varepsilon_i \right)

At a stationary point, L\mathcal{L} is extremized with respect to each nin_i independently, as if the constraints did not couple them — this is precisely the power of the method: differentiate freely, then use the constraints to fix α\alpha and β\beta afterward.

Step 4. Differentiate with respect to a single nkn_k. Treating all nin_i as independent variables and using ∂(niln⁡ni)/∂nk=ln⁡nk+1\partial(n_i \ln n_i)/\partial n_k = \ln n_k + 1 (nonzero only for i=ki = k):

∂L∂nk=−(ln⁡nk+1)−α+βεk=0\frac{\partial \mathcal{L}}{\partial n_k} = -\left( \ln n_k + 1 \right) - \alpha + \beta \varepsilon_k = 0

(The Nln⁡NN \ln N term in ln⁡W\ln W does not depend on any individual nkn_k and drops out.)

Step 5. Solve for nkn_k. Rearranging,

ln⁡nk=−1−α+βεk\ln n_k = -1 - \alpha + \beta \varepsilon_k

Exponentiating both sides,

nk=e−1−α eβεkn_k = e^{-1-\alpha} \, e^{\beta \varepsilon_k}

This has the wrong sign in the exponent for a physically sensible population (it would grow with energy). The resolution is a sign convention: because higher-energy levels must be less populated, the Lagrange multiplier for energy is conventionally written as +β+\beta multiplying −εk-\varepsilon_k from the start, i.e. the constraint term in L\mathcal L is taken as −β(E−∑iniεi)-\beta(E - \sum_i n_i\varepsilon_i) with β>0\beta>0 defined so that the physical solution reads

nk=eα′e−βεkn_k = e^{\alpha'} e^{-\beta \varepsilon_k}

where α′=−1−α\alpha' = -1-\alpha absorbs constants. (Equivalently, one simply defines β\beta as the multiplier that makes the exponent negative; its sign is fixed by physical requirement, its magnitude by the constraints — this is confirmed independently once β\beta is identified with 1/kBT1/k_BT in the next stage of the theory.)

Step 6. Apply the normalization constraint. Summing nk=eα′e−βεkn_k = e^{\alpha'} e^{-\beta\varepsilon_k} over all levels must reproduce NN:

N=∑ini=eα′∑ie−βεiN = \sum_i n_i = e^{\alpha'} \sum_i e^{-\beta \varepsilon_i}

so

eα′=N∑ie−βεie^{\alpha'} = \frac{N}{\sum_i e^{-\beta \varepsilon_i}}

Step 7. Assemble the final population law. Substituting back:

niN=e−βεi∑je−βεj\boxed{\dfrac{n_i}{N} = \dfrac{e^{-\beta \varepsilon_i}}{\displaystyle\sum_j e^{-\beta \varepsilon_j}}}

The remaining multiplier β\beta is fixed by the energy constraint ∑iniεi=E\sum_i n_i \varepsilon_i = E, and, as shown in later work, β=1/kBT\beta = 1/k_BT. The denominator is the molecular partition function qq.

Worked examples

Example 1 — Two levels, small numbers, checking the maximization directly. Take a toy system with only two non-degenerate levels, ε0=0\varepsilon_0 = 0 and ε1=ε\varepsilon_1 = \varepsilon, and N=4N = 4 molecules total, so configurations are (n0,n1)=(4,0),(3,1),(2,2),(1,3),(0,4)(n_0, n_1) = (4,0), (3,1), (2,2), (1,3), (0,4). Statistical weights:

W(4,0)=4!4!0!=1,W(3,1)=4!3!1!=4,W(2,2)=4!2!2!=6W(4,0) = \frac{4!}{4!0!} = 1, \quad W(3,1) = \frac{4!}{3!1!} = 4, \quad W(2,2) = \frac{4!}{2!2!} = 6
W(1,3)=4!1!3!=4,W(0,4)=4!0!4!=1W(1,3) = \frac{4!}{1!3!} = 4, \quad W(0,4) = \frac{4!}{0!4!} = 1

Without any energy constraint, (2,2)(2,2) is most probable, consistent with ni∝e−βεin_i \propto e^{-\beta \varepsilon_i} at β=0\beta = 0 (equal populations when there's no energetic penalty and levels are non-degenerate). Now suppose the total energy is fixed at E=1εE = 1\varepsilon (so only configuration (3,1)(3,1) satisfies both n0+n1=4n_0+n_1=4 and n0⋅0+n1⋅ε=εn_0\cdot 0 + n_1 \cdot \varepsilon = \varepsilon). Here the constraint eliminates all but one configuration, and (3,1)(3,1) is trivially "most probable" — it's the only allowed one. This illustrates why real systems with huge NN and continuous-looking level spacing need the full machinery: many configurations satisfy the constraints, and Stirling plus Lagrange multipliers pick out the dominant one among a combinatorially vast set, something a 4-particle toy model is too small to show numerically but which the derivation guarantees in general. Check the general formula on this toy problem using the Lagrange result with β\beta chosen so n1/n0=e−βεn_1/n_0 = e^{-\beta \varepsilon}. If βε=ln⁡3\beta \varepsilon = \ln 3 (i.e., e−βε=1/3e^{-\beta\varepsilon} = 1/3), then n1/n0=1/3n_1/n_0 = 1/3, giving n0=3,n1=1n_0 = 3, n_1 = 1 out of N=4N=4 — exactly matching the constrained configuration found above. The value of β\beta is fixed uniquely by requiring the mean energy per molecule equal E/N=ε/4E/N = \varepsilon/4; solving n1ε/N=ε/4n_1\varepsilon/N = \varepsilon/4 with n1=1,N=4n_1=1, N=4 gives exactly ε/4\varepsilon/4, confirming self-consistency.

Example 2 — Molar-scale system: verifying Stirling's approximation is safe. Suppose N=1.00N = 1.00 mol =6.022×1023= 6.022 \times 10^{23} molecules, and at the most probable configuration the ground level holds n0=5.5×1023n_0 = 5.5 \times 10^{23} molecules with the rest in excited levels. We check that Stirling's approximation ln⁡x!≈xln⁡x−x\ln x! \approx x\ln x - x is trustworthy at this scale, and estimate how sharply peaked ln⁡W\ln W is. Using the more accurate Stirling series, ln⁡x!=xln⁡x−x+12ln⁡(2πx)+⋯\ln x! = x\ln x - x + \tfrac12 \ln(2\pi x) + \cdots, the correction term for x=N=6.022×1023x = N = 6.022\times10^{23} is

12ln⁡(2πN)=12ln⁡(3.784×1024)≈12(56.27)≈28.1\tfrac12 \ln(2\pi N) = \tfrac12 \ln(3.784\times10^{24}) \approx \tfrac12 (56.27) \approx 28.1

Compare this to the leading term:

Nln⁡N=(6.022×1023)(54.94)≈3.31×1025N \ln N = (6.022\times10^{23})(54.94) \approx 3.31\times10^{25}

The correction (≈28) is smaller than the leading term (≈3.31×10253.31\times10^{25}) by a factor of about 102410^{24}, so dropping it is an utterly safe approximation — this is exactly why Stirling's approximation, poor for small xx, becomes essentially exact for chemical-scale populations. Next, estimate the sharpness of the peak in ln⁡W\ln W around the most probable configuration. A standard result (from expanding ln⁡W\ln W to second order in a small deviation δn\delta n from the maximum) shows the weight falls by a factor of ee when a single population changes by roughly δn∼ni\delta n \sim \sqrt{n_i}. For n0=5.5×1023n_0 = 5.5\times10^{23},

n0≈7.4×1011\sqrt{n_0} \approx 7.4\times10^{11}

So relative fluctuations are of order

δn0n0≈7.4×10115.5×1023≈1.3×10−12\frac{\delta n_0}{n_0} \approx \frac{7.4\times10^{11}}{5.5\times10^{23}} \approx 1.3\times10^{-12}

a fractional deviation of about one part in 101210^{12}. This confirms numerically that the "most probable configuration" is, for all practical purposes, the only configuration ever realized in a macroscopic sample — justifying Step 1's replacement of an ensemble average by a single dominant term.

Limiting cases & common traps

SituationWhat happensCommon error
Small NN (few particles)Stirling's approximation is inaccurate; multiple configurations are comparably probableApplying the derivation naively to small toy systems and expecting sharp peaking
β→0\beta \to 0All levels become equally populated regardless of energyForgetting this corresponds to the infinite-temperature limit, not zero temperature
Degenerate levelsEach level's population must be weighted by its degeneracy gig_i, giving ni∝gie−βεin_i \propto g_i e^{-\beta\varepsilon_i}Dropping degeneracy factors when levels are not simple singlets
Negative-looking exponent in Step 5A sign convention, not a physical errorConcluding the derivation is wrong because of the raw exponent sign before fixing conventions
Identifying β\betaβ=1/kBT\beta = 1/k_BT only established in later thermodynamic reasoning, not from combinatorics aloneAssuming β\beta's physical meaning is derivable from Lagrange multipliers alone

The chemist behind it

Ludwig Boltzmann built the statistical foundation connecting microscopic mechanics to macroscopic thermodynamics, arguing controversially in the 1870s that entropy could be understood as a measure of the number of microstates. His ideas met fierce resistance from physicists who doubted the atomic hypothesis itself, yet the maximization argument presented here — count the ways, apply the constraints, find the overwhelming maximum — is essentially the reasoning path he pioneered, later formalized with the tools of Lagrange and Stirling by Gibbs, Planck, and others who built the modern statistical mechanical framework on his foundation.

Origins · 1 minLudwig Eduard Boltzmann and how this was discovered
LE
Ludwig Eduard Boltzmann
1844–1906 · Austrian physicist who linked entropy to the counting of microstates, laying the combinatorial foundation this derivation formalizes

Ask the tutor: How does this derivation change if the energy levels are degenerate, and where does the degeneracy factor gig_i enter the final population law?

Why maximize ln W instead of W directly?

Both give the same maximizing configuration because the natural logarithm is a strictly increasing function, so wherever WW has its peak, ln⁡W\ln W has its peak too. The practical reason to work with ln⁡W\ln W is that Stirling's approximation is naturally stated in terms of ln⁡x!\ln x!, and sums are far easier to differentiate than products of factorials. Differentiating WW itself would require the product rule across every level simultaneously, a much messier calculation with no compensating benefit.

Why do we need Lagrange multipliers instead of just substituting the constraints in directly?

Direct substitution would mean solving for one nin_i in terms of all the others and eliminating it, which destroys the symmetric, level-by-level structure of the problem and quickly becomes intractable with many levels. Lagrange multipliers let us differentiate as though every nin_i were free, producing one simple equation per level. The two multipliers are then fixed afterward using the original constraints, which is far more tractable than constrained substitution.

Is the derivation valid if the energy levels are continuous rather than discrete?

Yes, with a modification: sums over discrete levels become integrals over a continuous energy variable, weighted by a density of states. The same maximization logic applies, and Stirling's approximation is equally valid because the populations involved remain macroscopically large. The final result is structurally identical, an exponential Boltzmann factor e−βεe^{-\beta\varepsilon}, now appearing inside an integral rather than a discrete sum.

Does this derivation tell us what beta actually is?

No. The Lagrange multiplier method only shows that β\beta exists as a single parameter controlling the energy dependence of populations, fixed in principle by the constraint ∑iniεi=E\sum_i n_i\varepsilon_i = E. Identifying β\beta with 1/kBT1/k_BT requires a separate thermodynamic argument, connecting the statistical definition of entropy to the classical thermodynamic relation between entropy, energy, and temperature. That identification is the subject of the next stage of this development.

Why does this derivation assume distinguishable molecules with the N!/(product of n_i!) formula?

This weight formula matches the prerequisite discussion of microstates and configurations, which treats molecules as distinguishable for counting purposes, appropriate for localized particles such as atoms fixed on lattice sites. For indistinguishable gas-phase molecules, a corrected weight formula avoids overcounting, but the same Lagrange multiplier maximization procedure applies unchanged and yields the identical exponential population law, only the leading normalization details differ.

Before this

Where this leads