Closed-form of an integral 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.
 A: Using the tangent half-angle subsitution, the antiderivative to be computed is
$$\frac{4}{a^2+2 a x+x^2+y^2}\int \frac t {t^4+\alpha t^3+\beta t^2+\alpha t+\gamma} \,dt$$ with
$$\alpha=-\frac{4 b y}{a^2+2 a x+x^2+y^2}\qquad  \qquad \beta=   \frac{-2 a^2+4 b^2+2 x^2+2 y^2}{a^2+2 a x+x^2+y^2}$$
$$\gamma=\frac{a^2-2 a x+x^2+y^2}{a^2+2 a x+x^2+y^2}$$
Now, let $(p,q,r,s)$ be the roots of the quartic equation
$$J=\int \frac t {t^4+\alpha t^3+\beta t^2+\alpha t+\gamma} \,dt=\int \frac t {(t-p)(t-q)(t-r)(t-s)} \,dt$$ and use partial fraction decomposition and you will face
$$J=\int\frac P{t-p}\,dt+\int\frac Q{t-q}\,dt+\int\frac R{t-r}\,dt+\int\frac S{t-s}\,dt$$ which is simple.
By the way, split the interval of integration if you do not want to obtain $0$ as the result.
A: 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))}$.
