Definite integral which does not evaluate How can I solve the following integral?
$$\int_{0}^{2\pi }\frac{\cos\phi \cdot \sin(\theta -\phi )}{1-\cos(\theta -\phi )}\text d\phi 
$$
I have evaluated this integral on Maple without the limits. It gives an exact answer, but with the limits there's a problem.
this is part of a problem of finding harmonic function inside a circle 
I get to this step $$2\pi (a*cos(\theta )+b*sin(\theta ))=\int_{0}^{2\pi }{\frac{\partial }{\partial n}V(\phi )}[\frac{sin(\theta -\phi )}{1-cos(\theta -\phi )}]d\phi $$
this is a Fredholm integral equation of first kind .
Who solved this problem suggest that we may put $$\frac{\partial }{\partial n}V(\phi )=A*cos\phi + B*sin(\phi )$$ and then inserting this trial solution into the integral equation and then he claimed that $$\int_{0}^{2\pi }(A*cos(\phi )+B*sin(\phi ))[\frac{sin(\theta -\phi )}{1-cos(\theta -\phi )}]d\phi = 2\pi A*sin(\theta )+2\pi B*cos(\theta )$$
 A: $$\int_{0}^{2\pi }\frac{\cos\theta \cdot \sin(\theta -\phi )}{1-\cos(\theta -\phi )}\text d\phi 
=\cos\theta \int_{0}^{2\pi }\frac{\sin(\theta -\phi )}{1-\cos(\theta -\phi )}\text d\phi 
$$
and by periodicity of the integrand one can evaluate as if $\theta=0$ and get
$$-\cos\theta\int_{0}^{2\pi }\frac{\sin(\phi )}{1-\cos(\phi )}\text d\phi=-\cos\theta\int_{0}^{2\pi }\cot\left(\frac\phi2\right)d\phi.$$ 
The integral is improper, but by symmetry of the function, its Cauchy value is zero.
A: Note that for some $n$,  $2n\pi\le \theta<2(n+1)\pi$.  Then, interpreting the integral in the sense of a Cauchy Principal Value, we can write
$$\begin{align}
\int_0^{2\pi}\frac{\cos(\phi)\sin(\theta-\phi)}{1-\cos(\theta-\phi)}\,d\phi&=\lim_{\epsilon \to 0^+}\left(\int_{\theta-2\pi}^{2n\pi-\epsilon}\frac{\cos(\theta-\phi)\sin(\phi)}{1-\cos(\phi)}\,d\phi+\int_{2n\pi+\epsilon}^{\theta}\frac{\cos(\theta-\phi)\sin(\phi)}{1-\cos(\phi)}\,d\phi\right)\\\\
&=\lim_{\epsilon \to 0^+}\left(\int_{-\pi}^{-\epsilon}\frac{\cos(\theta-\phi)\sin(\phi)}{1-\cos(\phi)}\,d\phi+\int_{\epsilon}^{\pi}\frac{\cos(\theta-\phi)\sin(\phi)}{1-\cos(\phi)}\,d\phi\right)\\\\
&=\cos(\theta)\lim_{\epsilon \to 0^+}\left(\int_{-\pi}^{-\epsilon}\frac{\cos(\phi)\sin(\phi)}{1-\cos(\phi)}\,d\phi+\int_{\epsilon}^{\pi}\frac{\cos(\phi)\sin(\phi)}{1-\cos(\phi)}\,d\phi\right)\\\\
&+\sin(\theta)\int_{-\pi}^{\pi}\frac{\sin(\phi)\sin(\phi)}{1-\cos(\phi)}\,d\phi\\\\
&=2\sin(\theta)\int_0^\pi\frac{\sin^2(\phi)}{1-\cos(\phi)}\,d\phi\\\\
&=2\sin(\theta)\int_0^\pi (1+\cos(\phi))\,d\phi\\\\
&=2\pi\sin(\theta)
\end{align}$$
And we are done!
A: The graph below shows the integrand $f(\phi)$ for case $\theta=0$. We have $f(-\phi)=-f(\phi)$, so we can claim it is reasonable to take the integral over the range as 0. The same is true for any value of $\theta$ because $f(\phi)$ has period $2\pi$ and we are integrating over a complete period.
The snag is that near 0 the function is approx $\frac{2}{\phi}$ so that $\int_{-\pi}^0=+\infty$ and $\int_0^\pi=-\infty$.
That is the reason that software like Maple balks at giving a value for the definite integral. You can argue that if you exclude symmetric intervals about $\theta$ and shrink them to 0, the integral remains 0 (technically known as the Cauchy principal value). But that is rather more of a stretch than the normal limiting procedure.
It is really a matter of taste whether you regard the integral as 0 or undefined.

A: $$
\begin{align}
\int_0^{2\pi}\frac{\cos(\theta)\sin(\theta-\phi)}{1-\cos(\theta-\phi)}\,\mathrm{d}\phi
&=\cos(\theta)\int_0^{2\pi}\frac{\sin(\theta-\phi)}{1-\cos(\theta-\phi)}\,\mathrm{d}\phi\tag{1}\\
&=\cos(\theta)\int_{\theta-2\pi}^\theta\frac{\sin(\phi)}{1-\cos(\phi)}\,\mathrm{d}\phi\tag{2}\\
&=\cos(\theta)\int_0^{2\pi}\frac{\sin(\phi)}{1-\cos(\phi)}\,\mathrm{d}\phi\tag{3}\\
&=\cos(\theta)\int_0^{2\pi}\cot\left(\frac\phi2\right)\,\mathrm{d}\phi\tag{4}\\
&=2\cos(\theta)\int_0^\pi\cot(\phi)\,\mathrm{d}\phi\tag{5}
\end{align}
$$
Explanation:
$(1)$: pull the constant out front
$(2)$: substitute $\phi\mapsto\theta-\phi$
$(3)$: substitute $\phi\mapsto\phi-2\pi$ on $\phi\in[\theta-2\pi,0]$ to get $\phi\in[\theta,2\pi]$
$(4)$: trig identity
$(5)$: substitute $\phi\mapsto2\phi$
$(5)$ says that the integral diverges since $\cot(x)\sim\frac1x$ near $x=0$. However, if we take the principal value, we get
$$
\begin{align}
2\cos(\theta)\,\mathrm{PV}\!\!\int_0^\pi\cot(\phi)\,\mathrm{d}\phi
&=2\cos(\theta)\lim_{\epsilon\to0^+}\int_\epsilon^{\pi-\epsilon}\cot(\phi)\,\mathrm{d}\phi\\
&=0\tag{6}
\end{align}
$$
since $\cot(\pi-x)=-\cot(x)$.
