TITLE: general form sin and arctan integral
QUESTION [5 upvotes]: Show that:
$$\int_{0}^{\pi}\sin(nx)\tan^{-1}\left(\frac{\tan(x/2)}{\tan(a/2)}\right)dx=\frac{\pi}{2n}\left[(-1)^{n+1}+\left(\sec(a)-\tan(a)\right)^{n}\right]$$

REPLY [5 votes]: Whenever you see an arctangent in an integral...integrate by parts!  The integral is then
$$\frac1{n}\left [-\cos{n x} \arctan{\left (\frac{\tan{\frac{x}{2}}}{\tan{\frac{a}{2}}} \right )}  \right ]_0^{\pi} +\frac{\tan{\frac{a}{2}}}{2 n} \int_0^{\pi} dx \, \cos{n x} \frac{\sec^2{\frac{x}{2}}}{\tan^2{\frac{a}{2}}+\tan^2{\frac{x}{2}}}$$
The integral on the right may be simplified to
$$\cos^2{\frac{a}{2}} \int_0^{2 \pi} dx \frac{\cos{n x}}{1-\cos{a} \cos{x}}$$
We may use the residue theorem here by making the sub $z=e^{i x}$; consider the real part of the integral
$$i 2 \cos^2{\frac{a}{2}} \oint_{|z|=1} dz \frac{z^n}{(\cos{a})\, z^2-2 z+\cos{a}}$$
We assume $a\in [0,\pi]$.  The only pole inside the unit circle is $z_- = (1-\sin{a})/\cos{a}$.  The integral is simply $i 2 \pi$ times the residue at that pole, or
$$(i 2 \pi) i \cos^2{\frac{a}{2}} \frac{(1-\sin{a})^n/\cos^n{a}}{-\sin{a}}  = \frac{\pi}{\tan{\frac{a}{2}}} (\sec{a}-\tan{a})^n$$
Therefore I get, for the integral,
$$\frac{\pi}{2 n} \left [(-1)^{n+1}+(\sec{a}-\tan{a})^n \right ]$$