<s>[INST] How find this integral $\int_{0}^{\pi}\frac{2t+2\cos{x}}{t^2+2t\cos{x}+1}dx$? Find this follow integral 
$$F(t)=\int_{0}^{\pi}\dfrac{2t+2\cos{x}}{t^2+2t\cos{x}+1}dx$$
where $t\in R$
my try: 
$$F(t)=\int_{0}^{\frac{\pi}{2}}\dfrac{2t+2\cos{x}}{t^2+2t\cos{x}+1}dx+\int_{\frac{\pi}{2}}^{\pi}\dfrac{2t+2\cos{x}}{t^2+2t\cos{x}+1}dx=I_{1}+I_{2}$$
where
$$I_{2}=\int_{0}^{\frac{\pi}{2}}\dfrac{2t-2\cos{x}}{t^2-2t\cos{x}+1}dx$$
then 
\begin{align*}I_{1}+I_{2}&=2\int_{0}^{\frac{\pi}{2}}\dfrac{(t+\cos{x})(t^2-2t\cos{x}+1)+(t-\cos{x})(t^2+2t\cos{x}+1)}{(t^2+1)^2-(2t\cos{x})^2}dx\\
&=4t\int_{0}^{\frac{\pi}{2}}\dfrac{t^2-2\cos^2{x}+1}{-4t^2\cos^2{x}+(t^2+1)^2}dt
\end{align*}
then I fell very ugly, have other methods? Thank you 
 [/INST] Any integral of a function that is rational in $\sin(x)$ and $\cos(x)$ can be transfored to an integral of a rational function using Weierstrass substitution. You might try that and see what happens.
$$\begin{align}
\int_0^\pi\frac{2t+2\cos x}{t^2+2t\cos(x)+1}\,dx
&=\int_0^\infty\frac{2t+2\frac{1-u^2}{1+u^2}}{t^2+2t\frac{1-u^2}{1+u^2}+1}\,\frac{1}{1+u^2}\,du\\
&=\int_0^\infty\frac{2t(1+u^2)+2(1-u^2)}{(t^2+1)(1+u^2)^2+2t(1-u^4)}\,du\\
&=\int_0^\infty\frac{(2t+2)+(2t-2)u^2}{(t^2+1)(1+u^2)^2+2t(1-u^4)}\,du\\
&=\int_0^\infty\frac{(2t+2)+(2t-2)u^2}{u^4(t^2-2t+1)+u^2(2t^2+2)+(t^2+2t+1)}\,du\end{align}$$
Since the denominator is quadratic in $u^2$, it's possible to factor it into linear factors in terms of $t$ and then use partial fraction decomposition to get an antiderivative.
</s>