Compute $\int_0^{2 \pi} \frac{ \cos(2nx) }{ a^2 + \cos^2 x} dx$ Compute the integral
$$I_n=\int_0^{2 \pi} \frac{ \cos(2nx) }{ a^2 + \cos^2 x} dx$$
where $n$ is any integer.
Using trig identities to evaluate special cases I found answers for $n=0$ and $n=1$.
For $n=0$
$$I_0=\frac{2\pi}{ a \sqrt{a^2 +1}}$$
For $n=1$
$$I_1=2\pi\frac{ 2a( \sqrt{a^2 +1} - a ) -1 }{ a \sqrt{a^2 +1}}$$
How do I find a generic answer for any integer n?

Assume $n\ge0$, $ a>0$ (wlog) and let $t=2x$. Then
$$I_n=\int_0^{2 \pi} \frac{ \cos(2nx) }{ a^2 + \cos^2 x } dx
=2\int_0^{2\pi} \frac{\cos(nt )}{{2a^2+1+\cos t}}dt
$$
Apply the Fourier series below and observe that only the term of $k=n$ survives the integration due to $\cos(nt ) $ in the numerator (the constant term does in the case of $n=0$)
$$\frac{1}{{2a^2+1+\cos t}}=
\frac1{2a\sqrt{1+a^2}}\left(1+2\sum_{k=1}^\infty (-1)^k (\sqrt{1+a^2}-a)^{2k}\cos (kx)\right)
$$
As a result, the integral yields
$$I_n= 2\pi (-1)^n \frac{(\sqrt{1+a^2}-a)^{2n}}{a\sqrt{1+a^2}}
$$
