How to prove$\int_{0}^{\pi}\frac{1}{\cos{\theta}-\cos{x}}dx=0$ where $0<\theta<\pi$? Question:
show that
$$I=\int_{0}^{\pi}\dfrac{1}{\cos{\theta}-\cos{x}}dx=0$$
where $0< \theta<\pi$
My try: since 
$$\cos{\theta}-\cos{x}=2\sin{\dfrac{\theta-x}{2}}\sin{\dfrac{\theta+x}{2}}$$
then
$$I=\int_{0}^{\frac{\pi}{2}}\dfrac{1}{\cos{\theta}-\cos{x}}dx+\int_{\frac{\pi}{2}}^{\pi}\dfrac{1}{\cos{\theta}-\cos{x}}dx=I_{1}+I_{2}$$
for $I_{2}$,let $u=\pi-x$
$$I_{2}=\int_{0}^{\frac{\pi}{2}}\dfrac{1}{\cos{\theta}+\cos{x}}dx$$
so
$$I=\int_{0}^{\frac{\pi}{2}}\dfrac{2\cos{\theta}}{\cos^2{\theta}-\cos^2{x}}dx$$
then I fell ugly,this reslut is zero,maybe have nice method?
Thank you very much!
 A: This integral does not converge due to the singularity near $x=\theta$. However, we can compute the Cauchy Principal Value of the integral.
$$
\int_0^\pi\frac{\mathrm{d}x}{\cos(\theta)-\cos(x)}
=\frac12\int_0^{2\pi}\frac{\mathrm{d}x}{\cos(\theta)-\cos(x)}
$$
Use $z=e^{ix}$ where $\frac{\mathrm{d}z}{z}=i\,\mathrm{d}x$ and $\cos(x)=\frac{z+1/z}2$ since $z$ is on the unit circle.
$$
\begin{align}
\frac12\int_0^{2\pi}\frac{\mathrm{d}x}{\cos(\theta)-\cos(x)}
&=\frac1{2}\int_\gamma\frac{-i\,\mathrm{d}z}{z\left(\cos(\theta)-\frac{z+1/z}{2}\right)}\\
&=\int_\gamma\frac{i\,\mathrm{d}z}{z^2-2z\cos(\theta)+1}\\
\end{align}
$$
The integrand has two singularities at $z=\cos(\theta)\pm i\sin(\theta)$. Consider the contour:
$\hspace{3.2cm}$
The principal value is the integral along the circle without the small semicircles. The integral along the whole contour is $0$ and the integral along each small semicircle is $-\pi i$ times the residue at the associated singularity.
The residue at $z$ is $\frac{i}{2z-2\cos(\theta)}$. Thus,
the residue at $z=\cos(\theta)+i\sin(\theta)$ is $+\frac1{2\sin(\theta)}$, and
the residue at $z=\cos(\theta)-i\sin(\theta)$ is $-\frac1{2\sin(\theta)}$
Therefore, the sum of the integrals along the small semicircles is $0$ and so
$$
\mathrm{PV}\int_0^\pi\frac{\mathrm{d}x}{\cos(\theta)-\cos(x)}=0
$$

We can also use the substitution $z=\tan(x/2)$, $\frac{2\,\mathrm{d}z}{1+z^2}=\mathrm{d}x$, and $\frac{1-z^2}{1+z^2}=\cos(x)$, then $w=z\cot(\theta/2)$
$$
\begin{align}
\mathrm{PV}\int_0^\pi\frac{\mathrm{d}x}{\cos(\theta)-\cos(x)}
&=\mathrm{PV}\int_0^\infty\frac{2\,\mathrm{d}z}{(1+z^2)\cos(\theta)-(1-z^2)}\\
&=\mathrm{PV}\int_0^\infty\frac{2\,\mathrm{d}z}{z^2(1+\cos(\theta))-(1-\cos(\theta))}\\
&=\frac2{\sin(\theta)}\mathrm{PV}\int_0^\infty\frac{\mathrm{d}w}{w^2-1}\\
&=\frac2{\sin(\theta)}\lim_{\epsilon\to0}\left(\int_0^{1-\epsilon}\frac{\mathrm{d}w}{w^2-1}+\int_{1+\epsilon}^\infty\frac{\mathrm{d}w}{w^2-1}\right)\\
&=\csc(\theta)\lim_{\epsilon\to0}\left(\left[\log\left|\frac{w-1}{w+1}\right|\right]_0^{1-\epsilon}+\left[\log\left|\frac{w-1}{w+1}\right|\right]_{1+\epsilon}^\infty\right)\\
&=\csc(\theta)\lim_{\epsilon\to0}\log\left|\frac{2+\epsilon}{2-\epsilon}\right|\\[9pt]
&=0
\end{align}
$$
A: Use $\cos^2(x)=\cos^2(x/2)-\sin^2(x/2)$ and then multiply and divide by $\sec^2(x/2)$. 
Try to bring every term in-terms of $\tan(x/2)$, then substitute $u=\tan(x/2)$ and proceed. 
A: Without loss of generality let $\theta\in(0,\pi/2)$, otherwise $\theta\to 2\pi-\theta$ would transform the integral into one with the same value (or minus its value for $\theta\to\pi-\theta$).
As there was stated earlier, the integral does not converge, so we are forced to compute only its principal value which is defined as :
$$\mathrm{PV}\int_0^\pi\frac{\mathrm{d}x}{\cos{\theta}-\cos{x}}=\lim_{\varepsilon\to0}
\left[\int_0^{\theta-\varepsilon}\frac{\mathrm{d}x}{\cos{\theta}-\cos{x}}+
\int_{\theta+\varepsilon}^\pi\frac{\mathrm{d}x}{\cos{\theta}-\cos{x}}\right]$$
Making the substitution $x\to\pi-x$ in the second integral (for the simplicity we will not write the limit sign in the next section) :
$$I=\int_0^{\theta-\varepsilon}\frac{\mathrm{d}x}{\cos{\theta}-\cos{x}}-
\int_0^{\pi-\theta-\varepsilon}\frac{\mathrm{d}x}{\cos{(\pi-\theta)}-\cos{x}}$$
So $I=\lim_{\varepsilon\to0}F(\theta-\varepsilon)-G(\pi-\theta-\varepsilon)$ where $F$ and $G$ are primitive function of the first (second) integrands.
Since
$$F(x)=\int\frac{\mathrm{d}x}{\cos{\theta}-\cos{x}}=\int\frac{\frac{2}{1+t^2}\;\mathrm{d}t}{\cos{\theta}-\frac{1-t^2}{1+t^2}}=2\int\frac{\;\mathrm{d}t}{\cos{\theta}(1+t^2)-(1-t^2)}=\\
\int\frac{\;\mathrm{d}t}{t^2\cos^2{\frac{\theta}{2}}-\sin^2{\frac{\theta}{2}}}=-\frac{2}{\sin\theta}\operatorname{arctanh}\frac{\tan\frac{x}{2}}{\tan\frac{\theta}{2}}$$
For $x\in(0,\theta)$. For $\theta\to\pi-\theta$ we get $G$ :
$$G(x)=-\frac{2}{\sin\theta}\operatorname{arctanh}\frac{\cot\frac{\pi-x}{2}}{\cot\frac{\theta}{2}}$$
Therefore
$$I = -\frac{2}{\sin\theta}\lim_{\varepsilon\to 0}\left[\operatorname{arctanh}\frac{\tan\frac{\theta-\varepsilon}{2}}{\tan\frac{\theta}{2}}-\operatorname{arctanh}\frac{\cot\frac{\theta+\varepsilon}{2}}{\cot\frac{\theta}{2}}\right]$$
Since $$\operatorname{arctanh}x=\frac{1}{2}\ln\frac{1+x}{1-x}$$
$$I=-\frac{1}{\sin\theta}\lim_{\varepsilon\to 0}\ln\left[
\frac{\tan\frac{\theta}{2}+\tan\frac{\theta-\varepsilon}{2}}{\tan\frac{\theta}{2}-\tan\frac{\theta-\varepsilon}{2}}
\frac{\cot\frac{\theta}{2}-\cot\frac{\theta+\varepsilon}{2}}{\cot\frac{\theta}{2}+\cot\frac{\theta+\varepsilon}{2}}\right]$$
Next we use sum formulas for $\tan$ and $\cot$ functions, so
$$I=-\frac{1}{\sin\theta}\lim_{\varepsilon\to 0}\ln\left[
\frac{\sin\left(\frac{\theta}{2}+\frac{\theta-\varepsilon}{2}\right)}{\sin\left(\frac{\theta}{2}-\frac{\theta-\varepsilon}{2}\right)}
\frac{\sin\left(\frac{\theta+\varepsilon}{2}-\frac{\theta}{2}\right)}{\sin\left(\frac{\theta+\varepsilon}{2}+\frac{\theta}{2}\right)}\right]$$
With the substitution $\varepsilon=2\delta$
$$I=-\frac{1}{\sin\theta}\lim_{\delta\to 0}\ln\left[
\frac{\sin\left(\theta-\delta\right)}{\sin\delta}
\frac{\sin\delta}{\sin\left(\theta+\delta\right)}\right]=-\frac{1}{\sin\theta}\lim_{\delta\to 0}\ln
\frac{\sin\left(\theta-\delta\right)}{\sin\left(\theta+\delta\right)}=0$$
