Trig function integral I'm trying to solve
$$\int_{0}^{\pi}\frac{dx}{cos^2(x)-a^2}, \hspace{5mm} 0<a<1$$
There are numerous examples of similar integrals but non with the condiction that $0<a<1$, say $a = 0.5$. Since the function is even one can expand the domain of integration to $2\pi$ and use the residuum theorem, but zeros lie on the unit circle making that method useless. Numerical integration in Mathematica or Fortran is also problematic and filled with errors.
So, does anyone have a clue how to solve this? I encountered this integral while calculating renormalization of energy dispersion in graphene due to electron-phonon interaction.
 A: This integral can be done by looking really hard at the graph. I'll work through how to do it for a=1/2 and let you generalize it from there. So, let a=1/2. The graph looks like, 
Notice how it's symmetric about pi/2. So let's do the integral from 0 to pi/2 then just double our result. This is what it looks like on the restriction,

What we'd like to happen is for the negative and positive parts of that asymptote to cancel. So lets make that happen. But first, one more restriction. there are no issues with the function from 0 to pi/6 so lets integrate normally up to there and use tricks for the remaining pi/6 to pi. Clearly the function is strictly negative from pi/3 to pi. So the contribution to the integral is entirely negative area. So lets flip the part from pi/3 to pi over the x-axis and over the line x=pi/3. Then we can just subtract our new flipped function from the original function and hopefully, if the singularities cancel we should see a bounded graph. This is what that looks like, (blue=original, yellow=flipped, green=difference).

Exactly what we wanted. Now we can add up the area of the function from 0  to pi/6 and the area bounded by the green line from pi/6 to pi/3, and then double our result.
$\int\limits_{0}^{\pi /6}{\frac{dx}{{{\cos }^{2}}(x)-1/4}=\left[ \frac{4}{\sqrt{3}}{{\tanh }^{-1}}\left( \frac{\tan (x)}{\sqrt{3}} \right) \right]}_{0}^{\pi /6}\approx 0.800377$
and
$\int\limits_{\pi /6}^{\pi /3}{\frac{1}{{{\cos }^{2}}(x)-1/4}-}\frac{1}{1/4-{{\cos }^{2}}(x+\pi /3)}\approx -0.800377$
So it looks like for a=1/2, the answer is 0. It's not unlikely I've made a horrible mistake here, but in the event that I haven't it shouldn't be hard to generalize this method for an arbitrary $0<a<1$.
A: The Cauchy principal value of the integral is $0$.

We have
$$F(a) = 2\int_0^{\pi/2} \dfrac{dx}{\cos^2(x)-a^2} = 2 \int_0^{\pi/2} \dfrac{\sec^2(x)dx}{1-a^2\sec^2(x)}$$
Setting $\tan(x) = t$, we obtain
\begin{align}
F(a) & = 2 \int_0^{\infty} \dfrac{dt}{1-a^2-a^2t^2} = \dfrac2{a^2} \int_0^{\infty} \dfrac{dt}{\left(\dfrac{1-a^2}{a^2}\right)-t^2}
\end{align}
Note that since $a^2 < 1$, we set $b^2 = \dfrac{1-a^2}{a^2}$, where $b \in \mathbb{R}^+$. We have
\begin{align}
F(a) & = \dfrac2{a^2} \int_0^{\infty} \dfrac{dt}{b^2-t^2}
\end{align}
We will interpret $F(a)$ as the Cauchy principal value of the integral, i.e.,
\begin{align}
\dfrac{a^2F(a)}2 & = \lim_{\delta \to 0^+} \left(\int_0^{b-\delta} \dfrac{dt}{b^2-t^2} + \int_{b+\delta}^{\infty} \dfrac{dt}{b^2-t^2} \right)
\end{align}
We have
\begin{align}
\int_0^{b-\delta} \dfrac{dt}{b^2-t^2} + \int_{b+\delta}^{\infty} \dfrac{dt}{b^2-t^2} & = \dfrac1{2b}\ln\left(\dfrac{b+t}{b-t}\right)_0^{b-\delta} + \left.\dfrac1{2b}\ln\left(\dfrac{t+b}{t-b}\right) \right \vert_{b+\delta}^{\infty}\\
& = \dfrac1{2b}\left(\ln\left(\dfrac{2b-\delta}{\delta}\right)-\ln(1) + \ln(1) - \ln\left(\dfrac{2b+\delta}{\delta}\right)\right)\\
& = \dfrac1{2b}\ln\left(\dfrac{2b-\delta}{2b+\delta}\right)
\end{align}
Hence, we obtain
$$\dfrac{a^2F(a)}2 = \lim_{\delta \to 0^+} \dfrac1{2b}\ln\left(\dfrac{2b-\delta}{2b+\delta}\right)=0$$
