Integral with a Dirac Delta and a Heaviside Theta function in statistical mechanics $$I=\frac{4\pi L }{h^2}\int_{-L}^{L} dy \int_{0}^{+\infty} dp \delta(\epsilon-\frac{p^2}{2m}-ky)$$ I put $\epsilon-ky=\epsilon_1$ so the integral:
$$I=\frac{4\pi L }{h^2}\int_{-L}^{L} dy \int_{0}^{+\infty} dp \delta(\epsilon_1-\frac{p^2}{2m})$$ now from the identity $\delta(f(p))=\frac{\delta(p-p_0)}{f'(p_0)}$, here $p_0=\pm\sqrt{2m\epsilon_1}$ so the integral becomes:
$$I=\frac{4\pi L m}{p_0h^2}\int_{-L}^{L} dy \int_{0}^{+\infty} dp [\delta(p-p_0)+\delta(p+p_0)]\theta(\epsilon_1)$$ with the choice of this theta, the integral becomes:
$$I=\frac{4\pi Lm }{h^2}\int_{-L}^{L} dy \theta(\epsilon_1)=\frac{4\pi Lm }{h^2}\int_{-L}^{L} dy \theta(\epsilon-ky)$$ and the integral solution is:
$$I=\frac{4 \pi Lm}{h^2k}[(\epsilon+kL)\theta(\epsilon+kL)+2kL\theta(\epsilon-kL)]$$ but the solution should be:
$$I=\frac{12 \pi Lm}{h^2k}[(\epsilon+kL)\theta(\epsilon+kL)-(\epsilon-kL)\theta(\epsilon-kL)]$$ could you please tell me where I'm wrong?
The $\theta$ function is the Heaviside function.
 A: Using the notation for positive and negative parts, OP's integral becomes
$$\begin{align}\frac{h^2}{4\pi L }I~=~&\int_{[-L,L]}~\mathrm{d}y \int_{\mathbb{R}_+} \!\mathrm{d}p~ \delta(\epsilon-\frac{p^2}{2m}-ky)\cr
~\stackrel{k,m>0}{=}&\frac{\sqrt{2m}}{k}\int_{\mathbb{R}_+} \!\mathrm{d}p\int_{[-kL,kL]}~\mathrm{d}y ~ \delta(\epsilon-p^2-y)\cr
~=~&\frac{\sqrt{2m}}{k}\int_{\mathbb{R}_+} \!\mathrm{d}p~1_{\{-kL\leq \epsilon-p^2\leq kL\}}(p)\cr
~=~&\frac{\sqrt{2m}}{k}\int_{\mathbb{R}_+} \!\mathrm{d}p~1_{\{\epsilon-kL\leq p^2\leq \epsilon+kL\}}(p)\cr
~=~&\frac{\sqrt{2m}}{k}( \sqrt{(\epsilon+kL)^+}-\sqrt{(\epsilon-kL)^+} ). 
\end{align} $$
A: Changing the order of integration gives
$$
I
= \frac{4\pi L }{h^2}\int_{-L}^{L} dy \int_{0}^{+\infty} dp \, \delta(\epsilon-\frac{p^2}{2m}-ky)
= \frac{4\pi L }{h^2} \int_{0}^{+\infty} dp \int_{-L}^{L} dy \, \delta(\epsilon-\frac{p^2}{2m}-ky) \\
= \{ z = ky \}
= \frac{4\pi L }{h^2} \int_{0}^{+\infty} dp \int_{-kL}^{kL} \frac{1}{k}dz \, \delta(\epsilon-\frac{p^2}{2m}-z)
= \frac{4\pi L }{h^2} \frac{1}{k} \int_{0}^{+\infty} dp \, \chi_{[-kL,kL]}(\epsilon-\frac{p^2}{2m})
.
$$
The last integrand equals $1$ when
$$
-kL \leq \epsilon-\frac{p^2}{2m} \leq kL \\
\Updownarrow \\
-kL \leq \frac{p^2}{2m}-\epsilon \leq kL \\
\Updownarrow \\
\epsilon-kL \leq \frac{p^2}{2m} \leq \epsilon+kL \\
\Updownarrow \\
2m(\epsilon-kL) \leq p^2 \leq 2m(\epsilon+kL) \\
\Updownarrow \\
\sqrt{2m(\epsilon-kL)} \leq p \leq \sqrt{2m(\epsilon+kL)} \\
$$
So,
$$
\int_0^\infty dp \, \chi_{[-kL,kL]}(\epsilon-\frac{p^2}{2m})
= \sqrt{2m(\epsilon+kL)} - \sqrt{2m(\epsilon-kL)}
$$
and we end up with
$$
I 
= \frac{4\pi L}{h^2} \frac{1}{k} \left( \sqrt{2m(\epsilon+kL)} - \sqrt{2m(\epsilon-kL)} \right) \\
= \frac{4\pi L}{h^2} \frac{\sqrt{2m}}{k}\left( \sqrt{\epsilon+kL} - \sqrt{\epsilon-kL} \right)
.
$$
