I'm nearly at the end of this derivation but totally stuck so I'd appreciate a nudge in the right direction

Consider a set of N identical but distinguishable particles in a system of energy E. These particles are to be placed in energy levels $E_i$ for $i = 1, 2 .. r$. Assume that we have $n_i$ particles in each energy level. The two constraints we impose are that $\sum_{i}^{r}n_i = N$ and $\sum_{i}^{r}E_i n_i = E$.

The number of microstates in a given macrostate is given by \begin{equation} \Omega = \frac{N!}{\prod_{i}^r n_{i}!} \end{equation}

We want to maximize this and for ease of notation, we work with $\ln\Omega$ and we use Stirling's approximation ($\ln x! = x\ln x - x$) to obtain \begin{equation} \ln\Omega = N\ln N - N - \sum_{i}^{r}n_i\ln n_i - n_i \end{equation}

Maximizing this function subject to the constraints $\sum_{i}^{r}n_i = N$ and $\sum_{i}^{r}E_i n_i = E$ is a classic Lagrange multiplier problem. We represent the undetermined multipliers to be $\alpha$ and $\beta$ for the two constraints and obtain \begin{align} \frac{\partial\ln\Omega}{\partial n_i} &= \alpha\frac{\partial n_i}{\partial n_i} + \beta\frac{\partial E_i n_i}{\partial n_i} \\ \nonumber \ln n_i &= \alpha + \beta E_i \\ \nonumber \therefore n_i &= e^{\alpha}e^{\beta E_i} \end{align}

Now, we use the first constraint equation to determine $\alpha$. We get \begin{align} \sum_i^r n_i &= N \\ \nonumber \sum_i^r e^{\alpha}e^{\beta E_i} &= N \\ \nonumber e^\alpha &= \frac{N}{\sum_i^re^{\beta E_i}} \\ \nonumber e^\alpha &= \frac{N}{Z} \end{align}

We have introduced the partition function, $Z=\sum_i^re^{\beta E_i}$ in the last line. Next, we have the second constraint equation that determines $\beta$ \begin{align} \sum_i^r E_i n_i &= E \\ \nonumber \frac{\sum_{i}^{r} E_i e^{\beta E_i}}{\sum_i^r e^{\beta E_i}} &= \frac{E}{N} \\ \nonumber \end{align}

I'm assuming I should somehow connect $E$ with $T$ so let's say $E=Nk_B T$. Then we have \begin{align} \frac{N}{Z}\frac{\partial Z}{\partial\beta} &= E \\ \frac{\partial\ln Z}{\partial\beta} &= k_B T \end{align}

How do I get to $\beta = -\frac{1}{k_B T}$ here? Notice that this derivation requires an extra minus sign compared to the usual definition of $\beta$ and this should come out naturally too, shouldn't it?

  • 2
    $\begingroup$ Hint: what actually is $T$? (Think experiment...) $\endgroup$
    – lemon
    Commented Aug 21, 2016 at 15:47
  • $\begingroup$ @lemon Oh dear, I'm really blanking! Did you mean that I shouldn't be relating E and T as I have done? $\endgroup$ Commented Aug 21, 2016 at 17:39
  • $\begingroup$ Indeed. Think back before the time of statistical mechanics; temperature $T$ was simply the thing that thermometers measured, and can be defined in terms of the relevant equation of state. In fact, the usual way to connect $\beta$ with $T$ is to simply derive the ideal gas law from your above formalism... $\endgroup$
    – lemon
    Commented Aug 21, 2016 at 19:01
  • $\begingroup$ @lemon sorry, I can't see how to bring about P or V into this derivation since I have not said anything about either. Integrating my last equation, we simply get $\ln Z = \beta k_B T + constant$ but that doesn't illuminate the problem for me either. Could you elaborate? $\endgroup$ Commented Aug 22, 2016 at 6:19
  • 4
    $\begingroup$ The followimg statement answers your question: "the value of the Lagrange multiplier at the solution of the problem is equal to the rate of change in the maximal value of the objective function as the constraint is relaxed." (from mjo.osborne.economics.utoronto.ca/index.php/tutorial/index/1/… ) $\endgroup$
    – higgsss
    Commented Jul 29, 2019 at 16:57

3 Answers 3


I shall try to explain my understanding of how this problem should be solved. First, I agree with your derivation of
$$ n_i = N e^{\beta E_i}/Z, \qquad (1) $$ where $$ Z = \sum_{j=1}^r e^{\beta E_j} \qquad (2) $$ and $\beta$ is obtained from equation $$ \frac{E}{N} = \frac1Z \sum_{i=1}^r E_i e^{\beta E_i}. \qquad (3) $$ We can make a conclusion now, that $n_i$ and $\beta$ depend on $E$ and $N$.

Our goal is to show that we have Gibbs distribution for $n_i$ and $\beta$ is equal to $-1/k_BT$. How can we relate $\beta$ and $T$? The only way I know is to use the following thermodynamic relation: $$ \frac1T = \left(\frac{\partial S}{\partial E}\right)_N, \qquad (4) $$ To obtain $S$ as a function of $E$ and $N$, we shall use Boltzmann's formula $$ S = k_B\log\Omega. $$ Then $$ S = S_0(N) -k_B\sum_{i=1}^r n_i\log(n_i/e). \qquad (5) $$ here $n_i$ depend on $E$ and $N$. Variation of $S$ induced by variations of $E$ and $N$ can be expressed through variations of $n_i$: $$ \delta S = S_0'(N)\sum_{i=1}^r \delta n_i - k_B\sum_{i=1}^r\delta n_i \log(n_i). \qquad (6) $$ Here $\delta n_i$ are expressed in terms of $\delta E$ and $\delta N$ in a somewhat cumbersome way. Substitution of (1) into (6) gives $$ \delta S = -k_B\beta\sum_{i=1}^r E_i\delta n_i + \mbox{"smthng"}\sum_{i=1}^r \delta n_i. \quad (8) $$ Obviously, $\delta n_i$ satisfy equations: $$ \sum_{i=1}^r \delta n_i = \delta N, \qquad \sum_{i=1} E_i \delta n_i = \delta E.\quad (9) $$ Then (8) and (9) give $$ \delta S = -k_B\beta\delta E + \mbox{"smthng"}\delta N. \quad (10) $$ The last equation gives $$ \left(\frac{\partial S}{\partial E}\right)_N = -k_B\beta. \quad (11) $$ At last, (11) and (4) give: $$ \beta = -\frac1{k_BT}. $$

Update. My explanation just demonstrates the statement of @higgsss's comment.

  • 1
    $\begingroup$ Yes, I meant Gibbs. $\endgroup$
    – Gec
    Commented Jul 30, 2019 at 5:54

First of all, I think the number of microstates should be


$$\ln\Omega=\ln N! -\ln\Pi_in_i! $$

We have

$$\ln(\Pi_i x_i)=\sum_i\ln x_i $$ So

$$\ln\Omega=N\ln N -\sum_i\ln n_i! -N=N\ln N -\sum_i n_i\ln n_i+\sum_i n_i - N$$ $$\ln\Omega=N\ln N-\sum_i n_i\ln n_i$$ Otherwise I have no idea how did you simplify this: $$\ln (\sum n_i!)$$

Or what is that supposed to mean. Check this out as to why I write $\Omega$ like that.

Now back to the problem. I can write

$$\sum_i n_i - N=0~~~and~~~\sum_i E_i n_i-U=0$$ $$\sum_i dn_i =0~~~and~~~\sum_i E_i dn_i=0~~~(*)$$ Let's take a look at differential of $\ln \Omega$

$$d\ln \Omega = d(N\ln N) -\sum \ln n_i dn_i -\sum n_i\frac{dn_i}{n_i}=-\sum \ln n_i dn_i$$

$$d\ln \Omega =-\sum \ln n_i dn_i=0$$

Now we can add (*) equations to the last equation, with two unknowns coefficients $\ln A$ and $\beta$:

$$-\sum \ln n_i dn_i-\ln A \sum_i dn_i +\beta \sum_i E_i dn_i =0$$


$$- \ln n_i -\ln A +\beta E_i =0$$


$$n_i=e^A e^{-\beta E_i}$$

Let's find $A$ and $\beta$ to get it over with:

$$\sum n_i=N=\sum e^A e^{-\beta E_i}$$

And if

$$Z=\sum e^{-\beta E_i}$$


Next we should find $\beta$. Let's use this very important equation $$\frac{1}{T}=\frac{\delta S}{\delta U}$$

First note that

$$\ln n_i =+\beta E_i -\ln A$$


$$d\ln \Omega =-\sum \ln n_i dn_i= -\sum (+\beta E_i -\ln A) dn_i=-\beta \sum E_i dn_i -\ln A \sum dn_i$$ The second term is obviously zero, but because $dE_i=0$ we can rewrite this equationt to get:

$$d\ln \Omega= -\beta d\sum E_i n_i=-\beta dU$$

right? (Of course $dU$ is zero in magnitude, but let's pretend we don't see that)

So if we consider the equation of entropy we have:

$$S=k_B \ln \Omega$$


$$\beta = -\frac{d\ln \Omega}{dU}=-\frac{\delta S}{k_b\delta U}=-\frac{1}{k_bT}$$

My fingers hurt. Hope this help.


In one of the early chapters of Pathria's, "Statistical Mechanics", he provides a fairly simple derivation using two boxes of gas, allowed to conduct heat between them, with a total fixed energy ($E_T$). It still heavily relies on the thermodynamic relation as mentioned by Gec above, and you might want to (re)explore the Carnot cycle and the Clausius theorem if you are unsure where this comes from (Fermi, "Thermodynamics" is an old but excellent book on the theoretical foundations here):

$$\frac{1}{T}=\left( \frac{\partial S}{\partial E} \right) _{N,V} \tag{1} $$

From here, Pathria's argument is fairly straightforward:

  • The total energy, $E_T=E_1+E_2$, is constant.
  • The total number of microstates of the combined system is then, $\Omega_T=\Omega_1\Omega_2$
  • Holding $N$ and $V$ fixed, $\Omega_T(E_T)=\Omega_1(E_1)\Omega_2(E_2)$
  • Differentiate with respect to either $E_1$ or $E_2$ and you will find that the quantity:

$$\frac{\partial \ln \Omega(E_i)}{\partial E_i} = \text{constant at equilibrium, i.e., }T\text{ is unchanging} \equiv \beta \tag{2}$$

Reminding ourselves of $(1)$, we can compute the following division (assuming constant $N$ and $V$, without notating them):

$$\left(\frac{\partial S}{\partial E} \middle/ \frac{\partial \ln \Omega}{\partial E}\right) = \left(\frac{1}{T} \middle/ \text{constant} \right) = \text{another constant} \equiv k_B$$

Let "constant" be $\beta$, and "another constant" be $k_B$,

$$\frac{1}{\beta T} = k_B \tag{3}$$

The difficult thing about statistical mechanics is that there are a number of places where you could define constants, and a number of experiments you could do to validate their values. The ideal gas law, for something like diatomic hydrogen, was empirically determined long before the advent of statistical mechanics. The gas constant and Boltzmann's constant happen to be related by Avogadro's number - stated another way, if you divide the gas constant by Avogadro's number you get a "constant", $k_B$.

What is this "constant"? Let's use the kinetic theory of gases:


Comparing to the ideal gas law (empirically determined), gives:

$$\frac{1}{3}Nmv^2 = nRT$$

Divide both sides by Avogadro's constant, $N_A$, and substitute $n=N/N_A$, $$(N/N_A)mv^2 = 3(N/N_A)(R/N_A)T$$ $$mv^2= 3(\text{constant}) T$$ $$\frac{1}{2}mv^2= \frac{3}{2}(\text{constant}) T$$

So, $R/N_A = \text{constant}=k_B$, is a real number that can be calculated. Now that the value of $k_B$ is known, you might think that $\beta$ is a free parameter. For a variety of reasons it isn't. One such reason is that Maxwell-Boltzmann statistics also comes up with a definition of the very same "another constant":

$$\rho(E_i)=\frac{1}{Z}\exp(-\beta E_i)$$

Where $\rho=N_i/N$ is the probability of being in state with energy $E_i$, and $N_i$ is the average number of particles in the set of states that correspond to $E_i$.

If you compute the average energy of a gas molecule in the box, you'll get:

$$\bar{E} = \frac{1}{N}\sum_i \rho(E_i) E_i = \frac{3}{2\beta} = \frac{1}{2}mv^2$$

So, for this definition to be consistent with the kinetic theory of gases, we must have $(3)$.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.