I'm trying to evaluate $$\int_0^{2\pi} dx \int_0^{2\pi} dy \frac{1 - e^{iax} e^{iby} }{1 - \cos x \cos y}$$ I am assuming that $a$ and $b$ are nonnegative integers and that $a+b$ is even. (This problem is related to an alternate approach to the infamous infinite grid of resistors problem.)
The first contour integration is easy. Changing to $z=e^{iy}$, we have $$ \int_0^{2\pi} \frac{i dx}{2 \cos x} \oint dz \frac{1 - e^{iax} z^b}{(z - z_+)(z - z_-)} $$ where $$ z_\pm = \sec x \pm \tan x $$ The problem is that when $0 < x < \pi$, $z_-$ is inside the contour and $z_+$ outside, and for $\pi < x < 2\pi$ the opposite is true. This gives $$ \pi \int_0^\pi \frac{1 - e^{iax} (\sec x - \tan x)^b}{\sin x} dx - \pi \int_\pi^{2\pi} \frac{1 - e^{iax} (\sec x + \tan x)^b}{\sin x} dx$$
Main question:
If I had a complete contour, I could evaluate these using the residue theorem, but each integral is over a half-circle. Is there a well-known strategy for such cases, where the movement of poles for one integral results in an incomplete contour for the second integral?
Thoughts so far:
Any attempt to change variables in order to make the integration over a full circle results in square roots that make the problem (inability to apply the residue theorem) worse.
The two integrands are related, because $z_+ z_- = 1$, but they aren't equal, and I can't transform them in a way that allows me to just combine the two intervals into $[0,2\pi]$. Of course, if you look at the value of the integral, they are equal, since taking $x$ to $x-\pi$ in the second integral makes it equal to the first, since $(-1)^{a+b}=1$. So we can just focus on the first integral. The problem is that I can't use the residue theorem to evaluate it.
The only idea I have at this point is to try to find an analytic function $f(z)$ where I can argue that $$ \oint f(z) dz = \int_0^\pi \frac{1-e^{iax}(\sec x - \tan x)^b}{\sin x} dx$$ However, I haven't been able to find such an argument.
Any help will be appreciated! Although it isn't really an answer to this question, if anyone can solve this integral through elementary means rather than the residue theorem, that would be fantastic as well.