How to calculate density of states for different gas models? There are a couple examples I'm trying to understand, all in a box/square of length $L$:


*

*For an ideal gas in 2-D with $\varepsilon=\frac{\hbar^2k^2}{2m}$:$$
D(\varepsilon)=\frac{L^2m}{2\pi\hbar}\,.$$

*For a 2-D Bose gas:$$
D(\varepsilon)~=~\frac{2m}{\pi\hbar^2}L^2 {\qquad} \Longrightarrow {\qquad} N~=~\frac{mL^2}{2\pi\hbar\beta}\sum^\infty_{l=1}\frac{e^{\beta l\mu}}{l}
\,.$$

*For a 3-D relativistic gas, I'm told $\varepsilon=\hbar kc$, though I have no idea how to get the density of states from this.

*I'd also like to be able to do a 3-D Bose gas. I've been trying to get $k$ as a function of $\varepsilon$ and taking the derivative for$$
D(\varepsilon)~=~\frac{\mathrm{d}N}{\mathrm{d}k}\frac{\mathrm{d}k}{\mathrm{d}\varepsilon}
\,,$$but I keep getting stuck on when I'm supposed to be using the volume of the sphere in $k$-space or the box.
Question:  How can the density of states, $D\left(\varepsilon\right)$, be calculated in each of these four models?
 A: To understand how to compute the density of states, you must first understand where it comes from. In statistical physics, we often have sums which look like this:
$$\sum_{s}\sum_{\vec n}$$
where $s$ labels spin and $\vec n$ is a vector of natural numbers labelling the quantum states, and it has as many components as the number of dimensions. We could equally write it as sums over its components, $\sum_{n_1}\sum_{n_2}\sum_{n_3}\cdots$. What exactly we are summing doesn't matter when computing the density of states.
In many calculations, the quantum states are very finely spaced, and we may replace the sum over the quantum numbers with an integral:
$$\sum_{s}\sum_{\vec n}\to \sum_{s}\int dn_1 dn_2 \cdots dn_D =\sum_{s}\int d^D \vec n$$
where $D$ is the number of dimensions. However natural numbers are never actually finely spaced, rather the momenta are so we replace $\vec n$ with $\vec k$, assuming that the system is in a $D$ dimensional box:
$\vec k = \frac{2\pi}{L}\vec n$. Doing this we get
$$\sum_{s}\int d^D \vec n = \sum_{s} \frac{L^D}{(2\pi)^D} \int d^D \vec k$$
If the system is not in a box, the only thing we have to change is to replace $L^D$ with the $D$ dimensional volume $V$ of the system (for example the two-dimensional volume is an area) and carry on as usual.
For simplicity now we'll also replace the sum over spins. If the quantity we're summing is independent of spin then we can replace $\sum_s \to g_s$ where $g_s=2s+1$ is the spin degeneracy. For an electron, $s=1/2$ so $g_s=2$. Of course we don't know what we're summing, so we don't know if it's independent of spin, but when computing the density of states it's usually assumed that it is.
Next thing we do is to notice that usually the quantity we're summing does not depend on the whole vector $\vec k$ but only on its magnitude $|\vec k|=k$. To get rid of the redundancy, we go to $D$ dimensional spherical coordinates (which have one radial component $k$ and $D-1$ angular components). Since the integrand by assumption does not depend on the angular degrees of freedom, we can integrate them out to get the area of the $D-1$ dimensional sphere:
$$\int d^D \vec k = S_{D-1} \int_0^\infty dk \, k^{D-1}$$
You can convince yourself that's true either by staring at it long enough, or by looking at the $D=2$ and $D=3$ cases:
$$\int d^2 \vec k = 2\pi \int_0^\infty dk \, k \,\,\,\,\,\,\,\, \int d^3 \vec k = 4\pi^2 \int_0^\infty dk \, k^2$$
You can find the expression for $S_{D-1}$ in the wikipedia page linked above.
As a summary, up to now we did the following:
$$\sum_{s}\sum_{\vec n}\to \frac{V g_s S_{D-1}}{(2\pi)^D} \int_0^\infty dk \, k^{D-1}$$
At this point, we want to express the integral as one over energy $\epsilon$ rather than over momentum $k$, and to do this we need to know the dispersion relationship $\epsilon = \epsilon(k)$. When can then invert it and substitute it into the integral.
So for example in the $2D$ ideal gas case, $V$ is actually the area $A$, $S_{D-1} = 2\pi$, $g_s=1$ and the dispersion relation is $\epsilon(k)=\hbar^2 k^2/2m$. Inverting, $k=\sqrt{2m \epsilon}/\hbar$ so we get:
$$\frac{A}{2\pi} \int_0^\infty dk \, k = \int_0^\infty \frac{mA}{2\pi \hbar^2} d\epsilon$$
so the density of states in this case is $\frac{mA}{2\pi \hbar^2}$. If you follow the steps above the calculations in the other cases are not hard.
A: Hint: The density of states of energy is related to the density of states in $\textbf{k}$-space as:
$g(E)dE = D g(\textbf{k})d^n(\textbf{k})=Dg_{nD}(k)dk$
where $D$ is the degeneracy of states and $n$ is the dimension of the structure considered. 
From the relation, $g(E)$ ($D(\epsilon)$ in the question) can be defined as:
$g(E) = \frac{Dg_{nD}(k)}{\frac{dE}{dk}}$
Take your first question as an example, $D=1$ as there is no degeneracy for ideal gas, and $n=2$ since it's two-dimensional. Hence:
$g(\textbf{k})d^2\textbf{k} = (\frac{L}{2\pi})^22\pi k dk = g_{2D}(k)dk$
$\frac{dE}{dk}=\frac{\hbar^2k}{m}$
And thus
$g(E) = \frac{(\frac{L}{2\pi})^22\pi k}{\frac{\hbar^2k}{m}}$ 
as desired.
