An integral relating to $\delta$-function How can we prove that
$$
\int_0^{2\pi}\delta(a+b\cos x)dx=2\frac{\theta\big(b^2-a^2\big)}{\sqrt{b^2-a^2}}
$$
where $\delta$ and $\theta$ are Dirac $\delta$ function and Heaviside $\theta$ function respectively.
 A: The Heaviside $\theta$ can be better understood if we think of the function inside the $\delta$-function. 

Integrating a $\delta$-function only sees the points where the argument of the $\delta$-function is $0$. The above plot is a picture of the argument of the $\delta$-function in the case of your integral. It is easy to see that this splits into three cases.
Case 1: $(a+b)(a-b) <0$. In this case, we have that either $(a+b)$ or $(a-b)$ is a negative quantity with the other one positive. It is clear that we are in the case depicted above; the cosine curve crosses the axis. In this case, there are two places where the function crosses $0$, so the integral only sees those two crossing points. Now, let $c$ and $d$ be the two zeros and let $f(x) = a + b\cos(x)$. We have that
$$
   \int_0^{2\pi} \delta(a+b\cos x) \,dx = \int_{c-\epsilon}^{c+\epsilon} \delta(f(x))\,dx + \int_{d-\epsilon}^{d+\epsilon} \delta(f(x))\,dx.
$$
Here, we truncate the integral to be around just the zeros, since these points are the only ones that matter for this $\delta$ function. Now, by zooming in really close (i.e. making $\epsilon$ small), we can replace $f(x)$ by its linear approximation. Since $f(c) = 0$, this means we can replace $f(x)$ with $f'(c)(x-c)$ in the first integral:
$$
   \int_{c-\epsilon}^{c+\epsilon} \delta(f(x)) \,dx = \int_{c-\epsilon}^{c+\epsilon} \delta(f'(c) (x-c))\,dx = \frac{1}{|f'(c)|} \int_{-\epsilon}^\epsilon \delta(u) \,du = \frac{1}{|f'(c)|}.
$$
Here, we did the substitution $u = |f'(c)| (x-c)$. 
Now, 
$$
  f'(c) = -b\sin(c) = -b \sqrt{1-\cos^2(c)} = -b\sqrt{1 - \frac{a^2}{b^2}} = - \sqrt{b^2-a^2},
$$
since $\cos(c) = -b/a$ as $c$ was a zero of $f$. So, the first integral gives a factor of $\displaystyle \frac{1}{\sqrt{b^2-a^2}}$. The integral over the second zero gives the exact same factor by symmetry. So, we get
$$ \int_0^{2\pi} \delta(a+b\cos x) \,dx = 2 \frac{1}{\sqrt{b^2-a^2}}.$$
When $(a-b)(a+b) >0$, there are no zeros, so the integral is 0.
The first case is $b^2-a^2 > 0$, and the second case is $b^2-a^2 <0$. Thus, by definition of the heaviside $\theta$, we get the desired result when $b^2-a^2 \neq 0$:
$$
   \int_0^{2\pi} \delta(a+\cos(x))\,dx = 2\frac{\theta(b^2-a^2)}{\sqrt{b^2-a^2}}.
$$
Lastly, we must consider the case when $b^2-a^2=0$. By examining the formula, we see that if $b^2-a^2 =0$, we will get division by $0$ in the expression on the right. So, we expect to get that the integral diverges. Indeed, when $b^2-a^2=0$, we get either $a=b$ or $a=-b$. If $a=b$, the same argument above gives
$$
   \int_0^2\pi \delta(a+b\cos(x))\,dx = \int_0^{2\pi} \delta(f'(\pi) (x-\pi))\,dx = \int_0^{2\pi} \delta(0) \,dx = \infty
$$ 
as $f'(\pi) = 0$ and so we are integrating $\infty$ over an interval of finite length. Similarly, if $a=-b$, then $f(x) = a - a\cos(x)$, which will have two zeros at $x=0$ and $x=2\pi$. In this case, we can extend the interval of integration to be $(-\epsilon, 2\pi + \epsilon)$ and use the same trick as before; both $f'(0)$ and $f'(\pi)$ are zero, so both integrals around the two zeros will be infinite. 
(Note: this is a little bit unrigorous, as there is nothing saying we have to push the interval out; we could just as well push the interval in and get 0 for the interval. I don't have a good reason for this, but maybe someone else can shed some light on this.)
A: Here below is my solution.
Splitting the integral interval to $0\rightarrow \pi$ and $\pi\rightarrow 2\pi$, and making use of the substitution $x\rightarrow y=\cos x$, we arrive at
$$
I=\int_0^{2\pi}\delta(a+b\cos x)dx=\int_{-1}^1\frac{\delta(a+by)}{\sqrt{1-y^2}}dy+\int_{-1}^1\frac{\delta(a-by)}{\sqrt{1-y^2}}dy
$$
If $\vert a/b\vert \leq1$, there must exist a unique zero of $a\pm by=0$ in the interval $-1\rightarrow 1$. Therefore
$$
I=\int_{-1}^1\frac{\delta(y+y_0)}{\vert b\vert\sqrt{1-y^2}}dy+\int_{-1}^1\frac{\delta(y-y_0)}{\vert b\vert\sqrt{1-y^2}}dy=\frac{2}{\vert b\vert\sqrt{1-y_0^2}}=\frac{2}{\sqrt{b^2-a^2}}
$$
where $y_0=a/b$. However, if $\vert a/b\vert>1$, the integral is nothing but zero.
In all, the integral can be writen as
$$
\int_0^{2\pi}\delta(a+b\cos x)dx=2\frac{\theta\big(b^2-a^2\big)}{\sqrt{b^2-a^2}}
$$
