# Derivation of temperature / entropy relation from statistical mechanics

I am trying to prove that $$$$\frac{1}{T} := k_B\beta = \frac{\partial S}{\partial E}.$$$$ I have that $$$$E := \sum p_i E_i,$$$$ the Gibbs entropy $$$$S = -k_B \sum_i p_i \ln p_i,$$$$ and by maximising this using Langrange multipliers, I derived the canonical ensemble, $$$$p_i = \frac{e^{-\beta E_i}}{Z},$$$$ where $$$$Z = \sum_i e^{-\beta E_i}.$$$$ My first equation is sometimes taken as a definition of $$\beta$$ but I have already defined it in my derivation of the canonical ensemble. Hence it is something I should be able to prove. First off, I can show from my definitions that \begin{aligned} S &= -\frac{k_B}{Z} \sum e^{-\beta E_i} \ln \left(\frac{e^{-\beta E_i}}{Z}\right) \\ &= \frac{k_B\beta}{Z} \sum E_i e^{-\beta E_i} + k_B\ln Z \\ &= k_B\beta E + k_B \ln Z. \end{aligned} It would be dandy if I could show that $$\frac{\partial \ln Z}{\partial E} = 0$$ because then I'd be done. However, I go through to find that $$$$E = \frac{1}{Z} \sum E_i e^{-\beta E_i} = -\frac{\partial \ln Z}{\partial \beta},$$$$ and so $$$$\frac{\partial E}{\partial Z} = \frac{\partial}{\partial \beta} \frac{\partial \ln Z}{\partial Z} = -Z^{-2} \frac{\partial Z}{\partial \beta} = \frac{ZE}{Z^2} = \frac{E}{Z},$$$$ and then $$$$\frac{\partial \ln Z}{\partial E} = \frac{\partial \ln Z}{\partial Z} \frac{\partial Z}{\partial E} = \frac{1}{Z} \frac{Z}{E} = \frac{1}{E},$$$$ which I'm not sure is legal. However, I also find that $$$$\frac{\partial E}{\partial \ln Z} = -\frac{\partial}{\partial \beta} \frac{\partial \ln Z}{\partial \ln Z} = 0.$$$$ Where am I going wrong? I am aware of this answer which uses the Boltzmann formula for the entropy, but I haven't been able to use that to unpick my derivation. My partial derivatives should be taken at constant volume and particle number, which might have something to do with it, but I don't see how I can apply that.

• Hi Matta. Answers get closed if they're considered to be just about how to solve a problem and don't involve any interesting physics. Typically we describe these as homework like questions though they don't have to be actual homework. They just have to be routine and uninteresting. Your question has been closed for this reason, though I have to say I think that's harsh and I've voted to reopen it. The answer isn't obvious to me so I assume the answer isn't obvious! You can always ask on the Meta site about getting it reopened. That often works. – John Rennie Oct 10 '19 at 8:51
• I think you should also take into account the Boltzmann definition of entropy: $S(U) = k_B \log Ω(U)$. It is also valid for the canonical ensemble. For a better understanding of the relationship between two entropies (Boltzmann and Gibbs) you can see ( damtp.cam.ac.uk/user/tong/statphys.html) , page24 – Aleksey Druggist Oct 10 '19 at 10:52
• Hi John Rennie, thank you for the help. I'll do as you suggest. Also Aleksey Druggist, I'll take a look into that as that might shed light on my suggested answer, thank you. – Matta Oct 11 '19 at 8:54
• @AlekseyDruggist, I have read Tong's notes and I think you need to be a little bit careful. The canonical ensemble does not have a defined energy and so the Boltzmann entropy definition that you provide has no meaning. Even if you replaced it with average $U$, it would still be unclear as to what $\Omega(\langle U \rangle)$ would mean. What Tong does is use a trick to motivate the Gibbs entropy using Boltzmann. Otherwise, they are two different functions: the latter counts microstates as an input and the former takes probability distributions as an input. Unless you mean something else by $U$. – Matta Oct 11 '19 at 10:02
• @Matta, carefulness, excellent quality, I will certainly take into account your advice, thank you. As for the Boltzmann entropy, the same Tong rewrite (at page23) a formula for the canonical partition function as a sum over energy levels by including a degeneracy factor: $$Z =\sum_{E_i} \Omega(E_i)e^{-\beta E_i}=\sum_{E_i} e^{S(E_i)/k_B-\beta E_i}$$ I mean by $U$ a continuous analog of $E_i$ – Aleksey Druggist Oct 11 '19 at 11:40

I use units where $$k_\mathrm{B} = 1$$.

You are correct up to the point where you obtain $$S = \beta E + \log{Z}.$$

Probably the most common source of confusion in thermodynamics is forgetting which variables are held fixed in partial derivatives. In particular, $$\beta = \frac{\partial S{\left(E,V,N\right)}}{\partial E}.$$

$$T$$ is not one of the variables being held fixed in this derivative! Indeed, if we raise $$E$$ without changing $$V$$ or $$N$$, we certainly expect $$T$$ to also rise! So we would need to apply the product rule to the first term to proceed as you desired: $$\frac{\partial(\beta E)}{\partial E} \neq \beta.$$

But I'd rather do things a bit differently. Since you have been working in the canonical ensemble, let us try to start by deriving the thermodynamics of the canonical ensemble.

Let $$F \equiv - T \log{Z} = E - T S$$. We calcuate

\begin{align} \frac{\partial{F}}{\partial T} &= - \log{Z} - T \frac{\partial \log{Z}}{\partial T} \\ &= - \log{Z} - T \frac{\partial \beta}{\partial T} \frac{\partial \log{Z}}{\partial \beta} \\ &= - \log{Z} + \beta \frac{\partial \log{Z}}{\partial \beta}. \end{align}

Using the results you derived, we get

\begin{align} \frac{\partial{F}}{\partial T} = \beta F - \beta E = -S. \end{align}

Now we have entered the realm of thermodynamics - how do we relate the derivatives of $$S$$ to those of $$F$$? Well, keep in mind we're basically trying to get the first law of thermodynamics. So write the equivalent for the canonical free energy:

\begin{align} \mathrm{d}F &= \left(\frac{\partial F}{\partial T}\right)_{V,N} \mathrm{d}T + \left(\frac{\partial F}{\partial V}\right)_{T,N} \mathrm{d}V + \left(\frac{\partial F}{\partial N}\right)_{T,V} \mathrm{d}N \\ &= - S \,\mathrm{d} T + \left(\frac{\partial F}{\partial V}\right)_{T,N} \mathrm{d}V + \left(\frac{\partial F}{\partial N}\right)_{T,V} \mathrm{d}N . \end{align}

But we also have: \begin{align} F &= E - T S\\ \mathrm{d}F &=\mathrm{d}E - T \,\mathrm{d}S- S \, \mathrm{d}T, \end{align}

whence

\begin{align} \mathrm{d}E &= T \, \mathrm{d}{S} + \left(\frac{\partial F}{\partial V}\right)_{T,N} \mathrm{d}V + \left(\frac{\partial F}{\partial N}\right)_{T,V} \mathrm{d}N \\ \mathrm{d}{S} &= \frac{1}{T} \mathrm{d}E - \frac{1}{T} \left(\frac{\partial F}{\partial V}\right)_{T,N} \mathrm{d}V - \frac{1}{T} \left(\frac{\partial F}{\partial N}\right)_{T,V} \mathrm{d}N. \end{align}

We thus read off the desired result, $$\frac{1}{T} =\left( \frac{\partial S}{\partial E} \right)_{V, N}.$$

• As I understand it, TO derives the canonical probability distribution as a distribution maximizing some functional named Gibbs entropy. subject to the constraint that the average energy is fixed (see this method in Tong lecture notes as an exercise on page 24). The question was why the Lagrange multiplier $\beta$ arising in this method should be equal to the iverse temperature $1/k_BT$, which is defined as the derivative of Boltzmann's entropy by energy . There are no thermodynamics in this question – Aleksey Druggist Oct 12 '19 at 10:55
• The question makes no explicit reference to thermodynamic relations other than the one OP wishes to prove, but this answer doesnt assume anything from thermodynamics which wasnt assumed by the question either. I do refer to things like the first law to motivate manipulations but i just use properties that were already derived in the body of the question and calculus. – Kuma Oct 12 '19 at 13:45

Kuma spotted my mistake by pointing out that $$$$\frac{\partial (\beta E)}{\partial E} \neq \beta.$$$$ I wanted to provide the answer in a slightly shorter way. Also setting $$k_B = 1$$, \begin{aligned} \frac{\partial S}{\partial E} &= \beta + E\frac{\partial \beta}{\partial E} + \frac{\partial \ln Z}{\partial E} \\ &= \beta + E\frac{\partial \beta}{\partial E} + \frac{\partial \ln Z}{\partial \beta}\frac{\partial \beta}{\partial E} \\ &= \beta + E\frac{\partial \beta}{\partial E} - E\frac{\partial \beta}{\partial E} \\ &= \beta. \end{aligned}

• It can be more shorter (based on the essence of the Lagrange multiplier method): $S+\beta( \sum {p_iE_i}-E) \rightarrow$ max, so $\frac{\partial S}{\partial E} - \beta=0$ – Aleksey Druggist Oct 13 '19 at 15:41
• You should write that as an answer Aleksey! Very good point. – Kuma Oct 13 '19 at 20:02
• I'm not sure if this is the answer. Remember, in your original answer, you mentioned a different definition of temperature through the derivative with respect to energy $U$ (continuous analog $E_i)$ of the logarithm of the number of microstates with this energy $U$ i.e. Boltzmann's entropy? This is the physical definition of temperature. (Two isolated bodies are brought into contact, the equilibrium condition, etc. ...) The question, I believe, is why the Lagrange multiplier $\beta$ coincides with this temperature (more precisely, with its inverse value)? – Aleksey Druggist Oct 13 '19 at 20:40