### 2.5 Calculation of the grand canonical ensemble

Maximize

 ${S}^{\prime }=-k\sum _{i}{p}_{i}ln\left({p}_{i}\right)$ (2.25)

with the restrictions

 (2.26)

Introducing the Lagrange parameters $\alpha$, $\beta$, and $\gamma$ the variation of the function

 $\delta \left[{S}^{\prime }-k\alpha \left(\sum _{i}{p}_{i}-1\right)-k\beta \left(\sum _{i}{p}_{i}{U}_{i}-U\right)-k\gamma \left(\sum _{i}{p}_{i}{N}_{i}-N\right)\right]=0$ (2.27)

 $-ln\left({p}_{i}\right)-1-\alpha -\beta {U}_{i}-\gamma {N}_{i}=0\phantom{\rule{2em}{0ex}}.$ (2.28)

Defining again

 $\frac{1}{Z}=exp\left(-1-\alpha \right)$ (2.29)

we find

 ${p}_{i}=\frac{1}{Z}exp\left(-\beta {U}_{i}-\gamma {N}_{i}\right)\phantom{\rule{1em}{0ex}}\text{and}\phantom{\rule{1em}{0ex}}Z\left(\beta ,V,\gamma \right)=\sum _{i}exp\left(-\beta {U}_{i}-\gamma {N}_{i}\right)\phantom{\rule{1em}{0ex}}.$ (2.30)

We get

 $U=\sum _{i}{p}_{i}{U}_{i}=\frac{\sum _{i}exp\left(-\beta {U}_{i}-\gamma {N}_{i}\right){U}_{i}}{\sum _{i}exp\left(-\beta {U}_{i}-\gamma {N}_{i}\right)}=-\left(\frac{\partial ln\left(Z\right)}{\partial \beta }\right):=U\left(\beta ,V,\gamma \right)$ (2.31)

and

 $N=\sum _{i}{p}_{i}{N}_{i}=\frac{\sum _{i}exp\left(-\beta {U}_{i}-\gamma {N}_{i}\right){N}_{i}}{\sum _{i}exp\left(-\beta {U}_{i}-\gamma {N}_{i}\right)}=-\left(\frac{\partial ln\left(Z\right)}{\partial \gamma }\right):=N\left(\beta ,V,\gamma \right)$ (2.32)

i.e.

 $S=kln\left(Z\right)+\beta kU+\gamma kN\phantom{\rule{2em}{0ex}}.$ (2.33)

The total derivative is:

 $\begin{array}{cc}\begin{array}{rl}\frac{dS}{k}& =\left(\frac{\partial ln\left(Z\right)}{\partial \beta }\right)d\beta +\left(\frac{\partial ln\left(Z\right)}{\partial \gamma }\right)d\gamma +\left(\frac{\partial ln\left(Z\right)}{\partial V}\right)dV+Ud\beta +\beta dU+Nd\gamma +\gamma dN\\ & =\left(\frac{\partial ln\left(Z\right)}{\partial V}\right)dV+\beta dU+\gamma dN\end{array}& \end{array}$ (2.34)

So

 $S=S\left(V,N,U\right)$ (2.35)

and $S$ is the Legendre transformed of $kln\left(Z\right)$.
Let

 $\left(\frac{\partial S}{\partial U}\right):=\frac{1}{T}\phantom{\rule{1em}{0ex}}\text{and}\phantom{\rule{1em}{0ex}}\left(\frac{\partial S}{\partial N}\right):=-\frac{\mu }{T}\phantom{\rule{1em}{0ex}}.$ (2.36)

So

 (2.37)

Following again the procedure for the calculation of the free energy we find

 $\Omega =U-\mu N-TS$ (2.38)

and

 $\Omega \left(T,V,\mu \right)=-kTln\left(Z\left(T,V,\mu \right)\right)\phantom{\rule{2em}{0ex}}.$ (2.39)