I recently started my course on Statistical Mechanics, where I have been introduced to the partition function of the canonical (and grand canonical) ensemble. My problem is that I struggle (a lot) with understanding it right. The problem really is the notation I guess, since it can be written as $Z=\sum_i e^{-\beta E_i}$ or as $Z=\sum_i g_i e^{-\beta E_i}$. I know that the first is supposed to be the sum over the states and the second is a sum over the energies (hence the degeneracy factor $g_i$), but this then means that the $E_i$'s are different things, or the labels have to be understood differently. And that's where I get lost...

  • $\begingroup$ The key here is that both sums run over different ranges. If you have 5 states with 2 different energies, for example three states with energy $E_1$ and two with energy $E_2$ you could write Z = $e^{-\beta E_1} + e^{-\beta E_1} + e^{-\beta E_1} + e^{-\beta E_2} + e^{-\beta E_2}$ or equivalently $Z = 3e^{-\beta E_1} + 2e^{-\beta E_2}$ $\endgroup$ Mar 10, 2019 at 17:11

2 Answers 2


If you write $$Z=\sum_{i\in\text{States}}e^{-\beta E_i}$$ then $E_i$ is the energy of state $i$, noting that if two states $i\neq j$ have the same energy, then $E_i=E_j$ and you're just adding the same number twice.

Alternatively, you could group all possible states by their energies, and then sum over all of those energy levels while taking into account how many states correspond to each.
$$Z=\sum_{i\in\text{ Energy Levels}} g_i e^{-\beta E_i}$$ where now $E_i$ denotes the energy of the $i^{th}$ energy "group", and $g_i$ denotes the number of states in it.

As an example, consider a system which has three states called $A,B,$ and $C$. State $A$ has energy $E_A=E_1$ while states $B$ and $C$ have energy $E_B=E_C=E_2$.

By the first definition, the partition function is

$$Z = \sum_{i\in\{A,B,C\}} e^{-\beta E_i} = e^{-\beta E_A} + e^{-\beta E_B} + E^{-\beta E_C}$$ $$ = e^{-\beta E_1} + e^{-\beta E_2} + e^{-\beta E_2} = e^{-\beta E_1} + 2e^{-\beta E_2}$$

and by the second,

$$Z = \sum_{i\in\{1,2\}} g_i e^{-\beta E_i} = g_1 e^{-\beta E_1} + g_2 e^{-\beta E_2}$$ $$ = e^{-\beta E_1} + 2 e^{-\beta E_2}$$

  • $\begingroup$ Oh wow, that was pretty easy to understand. Thank you so much! I cannot believe that I spent hours on trying to understand something "as simple" as that :) My mistake was to take the labels to be the same, if that makes sense. $\endgroup$
    – pjHart1000
    Mar 10, 2019 at 17:19
  • $\begingroup$ @pjHart1000 Not to worry, it happens to all of us over and over again. That's a common mistake to make - never be afraid to use more descriptive annotation or labels in your notes or your actual work to help keep those issues clear. $\endgroup$
    – J. Murray
    Mar 10, 2019 at 17:25

The short answer is "forgot about it". The ideal of partition function came from combinatorics, (https://en.wikipedia.org/wiki/Partition_(number_theory) ) but it become a very convenient things for statmec as a tool for counting probably states. Just be aware that $Z$ was most of the time for single particle. Your notation with $g_i$ is probably saying that the states is weighted, that at energy $E_i$ there's $g_i$ fold degeneracy.


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.