Here's my integral $\int_0^{2\pi} \frac{cos(n\theta)}{cosha+acos\theta}d\theta$ where $|a|<1$
I tried $\int_0^{2\pi} \frac{e^{in\theta}}{cosha+acos\theta}d\theta$ but stuck here because of denominator.
Then i used $cos\theta=\frac{1}{2}(z+\frac{1}{z})=\frac{1}{2}(e^{i\theta}+e^{-i\theta})$ and $cos(n\theta)=\frac{1}{2}(e^{in\theta}+e^{-in\theta})$
So my integral turns into $\oint \frac{1/2(e^{in\theta}+e^{-in\theta})}{cosha+\frac{a}{2}(e^{i\theta}+e^{-i\theta})}\frac{dz}{iz}$ But nothing useful comes from here since $cosh (a)$ is so restrictive.
How can I calculate this?
HINTS.
First of all rewrite the integral in a more "pleasing" way:
$$\int_0^{2\pi} \frac{\cos(n\theta)}{A + B\cos(\theta)}\ \text{d}\theta$$
Where of course $A = \cosh(a)$, $B = a$.
Then apply the Complex Step as you "almost" did:
$$z = e^{i\theta} ~~~~~~~~~~~\text{d}\theta = \frac{\text{d}z}{iz} ~~~~~~~~~~~ \cos(\theta) = \frac{1}{2}\left(z^2 + 1\over z\right) ~~~~~~~~~~~ \cos(n\theta) = \Re\left(z^n\right)$$
This leads to
$$-2i\int_{|z| = 1} \frac{\Re(z^n)\ \text{d}z}{ z^2 + bz + 1}$$
Where $b = B/A$.
Now it's all about to understand what $b^2 - 4$ is to get the hypothetical poles.
Poles are at
$$z_{1,\ 2} = \frac{-b \pm\sqrt{b^2-4}}{2}$$
It's not easy to determine which one lies inside the unit circle due to the unknown parameter $a$, but suppose we "know" that only
$$z = \frac{-b + \sqrt{b^2-4}}{2}$$
lies inside the unit circle (remember that $b = B/A = \cosh(a)/a$, so it would be immediate with numbers).
Then by residues theorem we have
$$\text{Integral} = -2i\left(2\pi i \times \sum_k \text{Residues}[f(z), z_k]\right)$$
In our case
$$f(z) = \frac{\Re(z^n)}{\left(z - \frac{-b + \sqrt{b^2-4}}{2}\right)\left(z - \frac{-b-\sqrt{b^2-4}}{2}\right)}$$
Whence
$$\text{Residue} = \lim_\left\{z\to \frac{-b + \sqrt{b^2-4}}{2}\right\} \ \frac{-b + \sqrt{b^2-4}}{2}\cdot f(z) = \dfrac{(\sqrt{b^2-4}-b)^n}{2^n \sqrt{b^2-4}}$$
And finally:
$$\text{Integral} = -2i\left(2\pi i \times \text{Res}\right) = 4\pi \dfrac{(\sqrt{b^2-4}-b)^n}{2^n \sqrt{b^2-4}}$$
Where again $b = \left(\dfrac{\cosh(a)}{a}\right)^{-1}$