# $\int_{0}^{\pi} \frac{\cos\theta (\cos\theta - \cos\theta_0)}{(1-\cos\theta_0\cos\theta)^2-\sin^2\theta_0\sin^2\varphi_0\sin^2\theta} d\theta$

Does anyone know how to integrate the following function?

$$\int_{0}^{\pi} \frac{\cos\theta (\cos\theta - \cos\theta_0)}{(1-\cos\theta_0\cos\theta)^2-\sin^2\theta_0\sin^2\varphi_0\sin^2\theta} d\theta$$

The answer that I hope to get is:

$$\frac{\pi(1-\sin\theta_0\cos\varphi_0)}{\sin^2\theta_0\sin^2\varphi_0+\cos^2\theta_0}$$

However I couldn't find a way to simplify the integral and what confuses me is that there is a $\pi$ in the final answer so I doubt that perhaps the indefinite integral of this function has something like $\arctan$. I tried to find the right substitution, but in vain.

I solved it finally. To prove that the integral is exactly the one mentioned above, one should use tangent half-angle substitution and will get $$\int_{-\infty}^{+\infty}\frac{(1-t^2)(-(a+1)t^2+(1-a))}{(1+t^2)(((1+a)t^2+(1-a))^2-4b^2t^2)} dt$$ with $a = \cos\theta_0$ and $b = \sin\theta_0\sin\varphi_0$.
Let $P,Q$ two polynomials with complex coefficients, $\forall x \thinspace Q(x)\neq0$, and $deg(P)\le deg(Q)+2$ . Then
$$\int_{-\infty}^{+\infty}\frac{P(x)}{Q(x)}dx=\sum_{\alpha} i\pi\varepsilon(\alpha)\varphi(\alpha)$$ where $\alpha$ are the roots of $Q$, $\varepsilon(\alpha)$ is the sign of $Im(\alpha)$ and $\varphi(\alpha)$ is the coefficient of $\frac{1}{x-\alpha}$ of the partial fraction decomposition of $\frac{P(x)}{Q(x)}$ (which means that $\frac{P(x)}{Q(x)}=\sum_{\alpha}\frac{\varphi(\alpha)}{x-\alpha}$).