# how to integrate $\displaystyle \int_{0}^{\pi/2}\frac{ dx}{1+\cos(\theta)\cos(x)}$

$\displaystyle \int_{0}^{\pi/2} \frac{ dx}{1+\cos(\theta)\cos(x)}$ where theta is in $]-\pi,\pi[$

this took me hours and i could not do it

I tried using $x= \pi/2 - t$ , using the fact that $f(-x)=f(x)$ etc but no result , putting it in wolframalpha gave a very complicated anti derivative

Let we compute $$I(A)=\int_{0}^{\pi/2}\frac{dt}{1+A\cos t}$$ for $A\in(-1,1)$. By using the Weierstrass substitution as suggested by Venus, we have: $$I(A) = 2\int_{0}^{1}\frac{du}{(1+A)+(1-A)u^2} = \frac{2}{1+A}\int_{0}^{1}\frac{du}{1+\frac{1-A}{1+A}\,u^2}\tag{1}$$ and by setting $u=\sqrt{\frac{1+A}{1-A}}v$ we get: $$I(A) = \frac{2}{\sqrt{1-A^2}}\int_{0}^{\sqrt{\frac{1-A}{1+A}}}\frac{dv}{1+v^2}=\frac{2}{\sqrt{1-A^2}}\,\arctan\sqrt{\frac{1-A}{1+A}}\tag{2}$$ so: $$I(\cos\theta) = \frac{2}{|\sin\theta\,|}\arctan\left|\tan\frac{\theta}{2}\right|=\color{red}{\frac{\theta}{\sin\theta}}\tag{3}$$ for any $\theta\in(-\pi,\pi).$