TITLE: Closed-form of an integral
QUESTION [5 upvotes]: I came across the following integral:
$$
\int_0^{2\pi} \frac{\sin \theta \ d \theta}{(x-a \cos \theta)^2+(y-b \sin \theta)^2}$$
where $x,y$ are real variables independent of $\theta$ and $0<b<a$. Now I was wondering if it could be written in a closed-form. I have been trying a number of different things but nothing seems to be working. Is there anyone how knows if this is even possible at all? And if so, would you be so kind to help me in the right direction? Any hint that gets me in the right direction is much appreciated.

REPLY [3 votes]: Claude expanded on the half-tangent case, so let me do the contour integral version.
Assuming $b^2x^2+a^2y^2\neq a^2b^2$ (and maybe $(x,y)\neq(\pm\sqrt{a^2-b^2},0)$ too, for simplicity).  The substitution $z=e^{i\theta}$ gives
\begin{align*}
\int_0^{2\pi}\frac{\sin\theta\,\mathrm{d}\theta}{(x-a\cos\theta)^2+(y-b\sin\theta)^2}
&=\int_{\mathbb{T}}\frac{\frac12(z^{-2}-1)\,\mathrm{d}z}{(x-\frac12a(z+z^{-1}))^2+(y-\frac1{2i}b(z-z^{-1}))^2}\\
&=\int_{\mathbb{T}}\frac{2(1-z^2)\,\mathrm{d}z}{(2xz-a(z^2+1))^2+(2yz+ib(z^2-1))^2}\\
&=\int_{\mathbb{T}}\frac{2(1-z^2)\,\mathrm{d}z}{((a+b)z^2-2(x+iy)z+(a-b))((a-b)z^2-2(x-iy)z+(a+b))}
\end{align*}
The poles are at
$$\require{color}
z_{{\color{red}\pm},{\color{blue}\pm}}=\frac{w_{\color{red}\pm}{\color{blue}\pm}\sqrt{w_{\color{red}\pm}^2-a^2+b^2}}{a{\color{red}\pm}b},\quad w_{\pm}=x\pm iy
$$
and you should be able to work out the residues and whether $z$ lies inside/on/outside the unit circle.  If you have assumed $(x,y)\neq(\pm\sqrt{a^2-b^2},0)$, we have four simple poles.  Hence
$$
\int_0^{2\pi}\frac{\sin\theta\,\mathrm{d}\theta}{(x-a\cos\theta)^2+(y-b\sin\theta)^2}=2\pi i\sum_{\epsilon_1,\epsilon_2\in\{\pm\}} \frac{1_{\lvert z_{\epsilon_1,\epsilon_2}\rvert\leq1}+1_{\lvert z_{\epsilon_1,\epsilon_2}\rvert<1}}{2}\operatorname*{res}_{z=z_{\epsilon_1,\epsilon_2}}f
$$
where $f(z)=\frac{2(1-z^2)}{((a+b)z^2-2(x+iy)z+(a-b))((a-b)z^2-2(x-iy)z+(a+b))}$.