I've been studying statistical mechanics and in the book there's something the author calls density of states which he introduced in a kind of indirect way. Basically, the author argues that if we have a certain function of the wave vector $f(\mathbf{k})$ and we are dealing with a particle inside a container of volume $V$, if we need to sum this function, on the thermodynamic limit we can replace it by the integral

$$\sum\_\mathbf{k} f(\mathbf{k})=\dfrac{\gamma V}{(2\pi)^3} \int\_M d^{3}\mathbf{k} f(\mathbf{k})$$

then if the function $f$ just depends on the magnitude $k$ of the wave vector this integral simplifies, upon using $d^3\mathbf{k} = k^2 \sin\theta dkd\phi d\theta$

$$\dfrac{\gamma V}{(2\pi)^3} \int\_M d^{3}\mathbf{k} f(\mathbf{k})=\dfrac{\gamma V}{(2\pi)^3}\int\_0^\pi \int\_0^{2\pi}\int\_0^\infty f(k)k^2\sin \theta dkd\phi d\theta =\dfrac{4\pi\gamma V}{(2\pi)^3}\int\_0^\infty f(k)k^2 dk$$

Now if the particle is free, we have $\epsilon = \dfrac{\hbar^2k^2}{2m}$ and then we can change variables to integrate in $\epsilon$. This gives

$$\dfrac{\gamma V}{(2\pi)^3} \int\_M d^{3}\mathbf{k} f(\mathbf{k})=\gamma V\int\_0^\infty D(\epsilon)f(\epsilon)d\epsilon$$

with $D(\epsilon) = \dfrac{(2m)^{3/2}}{(2\pi)^2\hbar^3}\epsilon^{1/2}$. This density of states appeared in a certain indirect way: after changing variables we collect everything into a function $D$.

Now, I imagine if we had another relation $\epsilon = \epsilon(k)$ we could use the same procedure to find another $D(\epsilon)$. In the same way, I imagine in two dimensions only the volume element would change.

In that way, what is there a more direct and general definition of $D(\epsilon)$? If so, how can it be derived and how can it be understood?