Until now we have only considered systems with a fixed value of energy, for which we have seen that the phase space volume is related to the entropy.
This kind of ensemble is however really restricting also because the computations made within it are quite complicated (in The monoatomic ideal gas we had to resort to the geometry of hyperspheres in order to compute the phase space volume of the ideal gas, which is the simplest system we can think of!). We therefore need to generalize our considerations to systems which have $V$ and $N$ fixed, but variable energy; in other words we want to see what happens when we remove the constraint of keeping the energy of a system fixed.
This is the essence of the *canonical ensemble*.
However, in order to determine the properties of this ensemble the only thing we can do is to use the tools that we already know, namely the microcanonical ensemble. What we are going to do therefore, in just a few words, is to consider an isolated system (for which the methods of the microncanonical ensemble apply) and see what happens if we consider a small portion of it.

Let us therefore consider a macroscopic isolated system, which we call the *heat bath*, at temperature $T$ composed of $N_{\text{b}}$ particles, and a small (but still macroscopic) subsystem of the bath containing $N$ particles (namely $N_{\text{b}},N\gg 1$ but $N\ll N_{\text{b}}$); for now $N$ and $N_{\text{b}}$ are fixed so the "walls" that enclose the small subsystem are fixed and impermeable and only allow the exchange of energy between the two; we also call $E$ the energy of the whole system.

The situation can be represented as follows:

Now, since the total system (the heat bath and the small subsystem) is isolated we can apply to it the tools of the microcanonical ensemble; in particular the probability density in phase space of the whole system will be:

$\rho (\mathbb {Q} _{\text{b}},\mathbb {P} _{\text{b}},\mathbb {Q} ,\mathbb {P} )={\frac {1}{\Omega (E)}}\delta \left[{\mathcal {H}}_{\text{b}}(\mathbb {Q} _{\text{b}},\mathbb {P} _{\text{b}})+{\mathcal {H}}(\mathbb {Q} ,\mathbb {P} )+{\mathcal {V}}(\mathbb {Q} _{\text{b}},\mathbb {Q} )-E\right]$

where

${\mathcal {V}}(\mathbb {Q} _{\text{b}},\mathbb {Q} )$ is the term containing the interaction between the heat bath and the subsystem. This term

*must* exist if we want the two systems to exchange energy, but what we now suppose is that it is neglibigle with respect to the other terms (the energy

$E$ and the Hamiltonians).
Since we want to study the properties of the small subsystem we are interested in finding a probability density which does not contain any information about the heat bath; in other words we want to determine the so called

*marginalized* probability density:

$\rho (\mathbb {Q} ,\mathbb {P} )=\int \rho (\mathbb {Q} _{\text{b}},\mathbb {P} _{\text{b}},\mathbb {Q} ,\mathbb {P} )d\Gamma _{\text{b}}$

namely:

$\rho (\mathbb {Q} ,\mathbb {P} )={\frac {1}{\Omega (E)}}\int \delta \left[{\mathcal {H}}_{\text{b}}(\mathbb {Q} _{\text{b}},\mathbb {P} _{\text{b}})-\left(E-{\mathcal {H}}(\mathbb {Q} ,\mathbb {P} )\right)\right]d\Gamma _{\text{b}}$

Now, by definition:

$\Omega _{\text{b}}(E')=\int \delta \left({\mathcal {H}}_{\text{b}}(\mathbb {Q} _{\text{b}},\mathbb {P} _{\text{b}})-E'\right)d\Gamma _{\text{b}}$

so we can write:

$\rho (\mathbb {Q} ,\mathbb {P} )={\frac {\Omega _{\text{b}}(E-{\mathcal {H}}(\mathbb {Q} ,\mathbb {P} ))}{\Omega (E)}}$

From the fundamental postulate of statistical mechanics, in terms of the entropy

$S_{\text{b}}$ of the heat bath we have:

$\Omega _{\text{b}}(E-{\mathcal {H}})=e^{{\frac {1}{k_{B}}}S_{\text{b}}(E-{\mathcal {H}})}$

Since the subsystem is much smaller than the heat bath we have

^{[1]}${\mathcal {H}}\ll E$ and so we can expand

$S_{\text{b}}$ around

$E$:

$\Omega _{\text{b}}(E-{\mathcal {H}})=e^{{\frac {1}{k_{B}}}\left(S_{\text{b}}(E)-{\mathcal {H}}{\frac {\partial }{\partial E}}S_{\text{b}}(E)+{\frac {{\mathcal {H}}^{2}}{2}}{\frac {\partial ^{2}}{\partial E^{2}}}S_{\text{b}}(E)+\cdots \right)}$

Since:

${\frac {\partial S_{\text{b}}}{\partial E}}={\frac {1}{T}}\quad \quad {\frac {\partial ^{2}S_{\text{b}}}{\partial E^{2}}}={\frac {\partial }{\partial E}}{\frac {1}{T}}=-{\frac {1}{T^{2}}}{\frac {\partial T}{\partial E}}=-{\frac {1}{T^{2}}}\left({\frac {\partial E}{\partial T}}\right)^{-1}=-{\frac {1}{T^{2}C_{V}^{\text{b}}}}$

where

$C_{V}^{\text{b}}$ is the specific heat of the bath at constant volume, then:

$\Omega _{\text{b}}(E-{\mathcal {H}})=e^{{\frac {1}{k_{B}}}\left(S_{\text{b}}(E)-{\frac {\mathcal {H}}{T}}-{\frac {{\mathcal {H}}^{2}}{2}}{\frac {1}{T^{2}C_{V}^{\text{b}}}}+\cdots \right)}$

Now,

${\mathcal {H}}\propto N$ and

${\mathcal {H}}^{2}/C_{V}^{\text{b}}\propto N^{2}/N_{\text{b}}=N(N/N_{\text{b}})\ll N$: all the terms beyond the first order can be neglected

^{[2]}. Considering that

$\Omega (E)=\int d\Gamma d\Gamma _{\text{b}}\delta ({\mathcal {H}}_{\text{b}}+{\mathcal {H}}-E)=\int d\Gamma \Omega _{\text{b}}(E-{\mathcal {H}})$, this leads to the following expression of the

*canonical probability density*:

$\rho (\mathbb {Q} ,\mathbb {P} )={\frac {e^{-\beta {\mathcal {H}}(\mathbb {Q} ,\mathbb {P} )+{\frac {1}{k_{B}}}S_{\text{b}}(E)}}{\int d\Gamma e^{-\beta {\mathcal {H}}(\mathbb {Q} ,\mathbb {P} )+{\frac {1}{k_{B}}}S_{\text{b}}(E)}}}={\frac {e^{-\beta {\mathcal {H}}(\mathbb {Q} ,\mathbb {P} )}}{\int d\Gamma e^{-\beta {\mathcal {H}}(\mathbb {Q} ,\mathbb {P} )}}}$

where:

$Z=\int d\Gamma e^{-\beta {\mathcal {H}}(\mathbb {Q} ,\mathbb {P} )}$

is called

*partition function* of the system. Sometimes

$e^{-\beta {\mathcal {H}}}$ is called

*Boltzmann weight*.

- ↑ In fact, $E\propto N+N_{\text{b}}$ while ${\mathcal {H}}\propto N\ll N_{\text{b}}\approx N+N_{\text{b}}$, so indeed ${\mathcal {H}}\ll E$.
- ↑ They are all terms that are smaller the bigger the heat bath is.
This fact could also be justified saying that we can consider the limit where the dimensions of the heat bath tend to infinity, therefore $C_{V}^{\text{b}}\to \infty$ and we can neglect all the terms from the second order on.