I'm trying to review some statistical mechanics from the following link

In doing so on the topic of variational theory and maximization with Lagrange multipliers, the author states that given a function:

$$ h(x_i) = f(x_i) - \lambda g(x_i), $$

then to extremize we require the condition:

$$ \frac{\partial h}{\partial x_i} = 0. $$

Though this is phrased a little differently than I am used to, the conclusion is the same and so I am okay with it.

However, later on the author solves this example with the case of a Grand Canonical Ensemble (GCE). In my own understanding, the GCE is described by the number of particles, and the energy. I arrived at the same constrain equations as the author however, based on my understanding the the parameteres of the same are described by $(E,N)$, I would have expected that there should have been two equations set to equal zero:

$$ \frac{\partial}{\partial E_n} \left[S - \lambda_E \sum P(E,N) E - \lambda_N \sum P(E,N) N - \lambda_1 \sum P(E,N) \right] = 0, $$ and

$$ \frac{\partial}{\partial N_n} \left[S - \lambda_E \sum P(E,N) E - \lambda_N \sum P(E,N) N - \lambda_1 \sum P(E,N) \right] = 0. $$

I was able to find another text that arrives at the same solutions for the probability function, with different variable substitutions (in terms of $\mu$ and $\beta$) so I presume that this procedure is the correct one. I suspect my confusion is related to idea of: what is a function of what. Which has been a bane of my existence through all of my courses on thermodynamics and statistical mechanics.

Any explanation would be greatly appreciated! :)

  • 1
    $\begingroup$ should be pi and E and N should be $E_i$ and $N_i$ ... In the Link(www2.ph.ed.ac.uk/~mevans/sp/sp2.pdf) they have for Grand Canonical Ensemble (GCE) not $p_i$, but $p_{i,N}$ and so not $N_i$ but $N$ (see (12) at p.8) $\endgroup$ Feb 13, 2022 at 1:13
  • 1
    $\begingroup$ @AlekseyDruggist You're right, I did not look at the author's notation, so I removed my comment to not add another layer of confusion ;) . (I prefer to sum over microstates $i$ with no constraints on the particle number and consider an observable $i\mapsto N_i$, which is of course equivalent. The author seems to prefer to sum over $N$ and over microstates with $N$ particles. This amount to the same thing, of course.) $\endgroup$ Feb 13, 2022 at 8:21
  • 1
    $\begingroup$ Yes, the variables are $\mu$ and $\beta$ (although the identification of these constants with the Lagrange mutipliers should be done separately). Derivatives w.r.t. $\lambda_E$ and $\lambda_N$ (and $\lambda_1$) will just yield the three constraints (normalization, fixed expected energy, fixed expected number of particles). $\endgroup$ Feb 13, 2022 at 15:00
  • 1
    $\begingroup$ The derivatives w.r.t. $p_i$ (or rather $p_{Ni}$ in the notation of your reference) will lead to an equation determining the $p_i$: $\frac{\partial}{\partial p_i} \bigl(\sum_i p_i\log p_i - \lambda_E \sum_i p_i E_i - \lambda_N \sum_i p_i N_i - \lambda_1 \sum_i p_i \bigr) = 0 $ yields $\log p_i + 1 - \lambda_E E_i -\lambda_N N_i - \lambda_1 = 0$, that is, $p_i \propto \exp(\lambda_E E_i + \lambda_N N_i)$ as you want. You still have to argue that $\lambda_E = -\beta$ and $\lambda_N = \beta\mu$ if you wish to obtain the usual form, of course. $\endgroup$ Feb 13, 2022 at 15:00
  • 1
    $\begingroup$ We discuss this in detail in Section 1.2 of our book. (See also Section 1.3 for the link between the Lagrange multipliers and the relevant physical quantities.) $\endgroup$ Feb 13, 2022 at 15:03

1 Answer 1


There are three constraints in the grand canonical ensemble: $$ \sum_{n,j} a(n,j) = \mathcal{N} $$ $$ \sum_{n,j} a(n,j) E_j= \mathcal{N} \bar{E} $$ $$ \sum_{n,j} a(n,j) N_n= \mathcal{N} \bar{N} $$ $a(n,j)$ represents the number of samples with $N_n$ particles and energy $E_j$ in the giant canonical ensemble. $\mathcal{N}$ is the total number of samples. $w=\dfrac{\mathcal{N}!}{\Pi_{n,j}a(n,j)!}$ is the total number of microstates.
When we use the Lagrangian method, the function that needs to be constructed is: $$f({a(n,j),\alpha,\beta, \gamma} = \ln w -\alpha ( \sum_{n,j} a(n,j) - \mathcal{N} )-\beta( \sum_{n,j} a(n,j) E_j - \mathcal{N} \bar{E} ) - \gamma (\sum_{n,j} a(n,j) N_n-\mathcal{N} \bar{N}) $$ The independent variables of the function f are only $ a(n,j),\alpha,\beta, \gamma $.
$ \bar{E}, \bar{N}$ is the expectation of the number of particles and energy given in advance, $E_j, N_n$ is our artificial standard, such as $N_n$ must be $0,1,2,3...$ so they are constants rather than self-energy, and there is no need to take partial derivatives for them.


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.