How to write equation of state in terms of partition function? While studying quantum gases (fermions, bosons), equation of state written were $PV = k_B T Z_{gr}$, where $Z_{gr}$ is the partition function of grand canonical ensemble. $P$ and $V$ are pressure and volume, respectively. How can we derive this equation of state? Is it same equation that we use for ideal gases ($PV=NRT$) or is it different?
 A: When dealing with quantum gases you have to apply a correction to your result from the ideal gas!
Let us take a non-relativistic ideal gas, in which each particle has an energy of 
$$
\epsilon=\frac{p^2}{2m}.
$$
The ideal gas law follows from
$$
N(T,V,\mu)=\frac{1}{\beta}\frac{\partial\ln Y}{\partial\mu},
$$
so we need an expression for $\ln Y$. For bosons, we can write:
$\begin{align}
Y(T,V,\mu)&=\sum_r\exp\left(-\beta\left(E_r\left(V,N_r\right)-\mu N_r\right)\right)\\
&=\prod_i\sum_{n_{p_i}}\exp(-\beta(\epsilon_{p_i}-\mu)n_{p_i})\\
&=\prod_p\frac{1}{1-\exp(-\beta(\epsilon_p-\mu))}\\
\Rightarrow\ln Y&=-\sum_p\ln(1-\exp(-\beta(\epsilon_p-\mu)))
\end{align}$
A similar calculation yields $$\ln Y=2\sum_p\ln(1+\exp(-\beta(\epsilon_p-\mu)))$$ for fermions.
To find the ideal gas law and its quantum mechanical corrections we need to do a series expansion of those expressions:
$$
\ln Y = (2s+1)\sum_p\left(\exp(-\beta(\epsilon_p-\mu))\pm\frac{1}{2}\exp(-2\beta(\epsilon_p-\mu))+...\right)
$$
with $s=0$ for bosons and $s=1/2$ for fermions.
The possible momentum states are very dense, therefore we can treat the sum as an integral, which yields:
$\begin{align}
\ln Y &= (2s+1)\frac{V}{(2\pi\hbar)^3}\int\!\mathrm{d}^3p\,\exp(\beta\mu)\left(\exp\left(-\frac{p^2}{2mk_BT}\right)\pm\frac{1}{2}\exp(\beta\mu)\exp\left(-\frac{p^2}{mk_BT}\right)+...\right)\\
&=(2s+1)\frac{V}{(2\pi\hbar)^3}\exp(\beta\mu)\frac{1}{2}\sqrt{\pi}\sqrt{mk_BT}\left(2\sqrt{2}+\exp{\beta\mu}+...\right)\\
&:=(2s+1)\frac{V}{\lambda^3}\left(\exp(\beta\mu)\pm2^{-5/2}\exp(2\beta\mu)+...\right)
\end{align}$
in the last step I just summed together some constants, to get the thermal wavelength $\lambda$, as mentioned in another answer.
Now we use $N(T,V,\mu)=\frac{1}{\beta}\frac{\partial\ln Y}{\partial\mu}$. In the zeroth-order approximation we find:
$$
N(T,V,\mu)=\frac{1}{\beta}\frac{\partial\ln Y}{\partial\mu}=\ln Y = \frac{PV}{k_BT},
$$
the ideal gas law. For higher orders we find certain corrections, such that
$$
\ln Y = N\mp\frac{2s+1}{2^{5/2}}\frac{V}{\lambda^3}\exp(2\beta\mu)+...
$$
A: When you got the expression of the grand canonical partition function, which depends on whether you are studying bosons or fermions, you can use the link with the grand potential $ \Phi = -k_BT \ln (Z_{gr})$. 
From this you can use the relation $$ P = -\frac{\partial \Phi}{\partial V},$$
which will give you the pressure in function of the partition function. From here it should be little calculation to get the form $$PV = k_BTZ_{gr}.$$
A: All your questions are related to the choice of the independent variables. The shape of the functions might vary if you work with the canonical ensemble $(T,V,N)$ or the grand-canonical ensemble $(T,V,\mu)$. However, in the thermodynamic limit, all ensembles are equivalent and you should be able to go from one to the other through a change of variables. However, I get to a different expression for the equation of state, are you sure about its validity?

How can we derive this equation of state?

Say you have a very general system in which the canonical partition function in Boltzman's approximation (a.k.a. classical limit) reads:
$Z(T,N,V)=\frac{(V \varphi(T))^N}{N!}$
Where $\varphi$ depends on the system in question, for a three dimensional ideal gas, $\varphi(T)=(\frac{2\pi m k_B T}{h^2})$.
The grand-canonical partition function will then be:
$Z_{gr}(T,\mu,V)=\sum_N e^{\frac{\mu N}{k_B T}}Z(T,N,V)=e^{e^{\frac{\mu }{k_B T}}V \varphi(T)}$.
The associated thermodynamic potential is:
$J(T,\mu,V)=k_BT\log(Z_{gr})=k_B T e^{\frac{\mu }{k_B T}}V \varphi(T)$.
Therefore, pressure is:
$P(T,\mu,V)=(\frac{\partial J}{\partial V})_{\mu,T}= k_B T e^{\frac{\mu }{k_B T}} \varphi(T)$
Now the only thing is to get $\varphi(T)$. From the canonical partition function of one particle: $\varphi(T)=\frac{Z_1(T,V)}{V}$, from the grand-canonical partition function: $\varphi(T)=\frac{\log(Z_{gr}(T,V,\mu))}{V }e^{-\frac{\mu }{k_B T}}$ or from the grand-canonical potential: $\varphi(T)=\frac{J(T,V,\mu)}{k_B T V }e^{-\frac{\mu }{k_B T}}$. The one that approaches the most to your expression is:
$P(T,\mu,V) V=k_B T \log (Z_{gr})$.
One important thing to notice is that all possible ways of getting $\varphi$ lead to the same result (through a different functional expression).

Is it same equation that we use for ideal gases $(PV=NRT)$ or is it different?

Is the same! In order to check it, you have to go from $P(T,\mu,V)$ to $P(T,N,V)$.
$N(T,\mu,V)=(\frac{\partial J(T,\mu,V)}{\partial \mu})_{_{V,T}}=\frac{J(T,\mu,V)}{k_B T} $.
Since $P(T,\mu,V)=\frac{J(T,\mu,V)}{V}$ in one of its forms, combining the last two equations we get:
$P(T,N,V) =\frac{N k_B T}{V}$
