Evaluating a trigonometric integral. 
Show That
$$\int_{0}^{\pi}\ln (\sin x) \cos(2nx) \, dx = -\dfrac{\pi}{2n}$$

I tried to use substitutions and taylor series of $\ln (\sin x)$, but to no avail.
Any help will be appreciated.
Thanks.
 A: $\newcommand{\bbx}[1]{\,\bbox[8px,border:1px groove navy]{\displaystyle{#1}}\,}
 \newcommand{\braces}[1]{\left\lbrace\,{#1}\,\right\rbrace}
 \newcommand{\bracks}[1]{\left\lbrack\,{#1}\,\right\rbrack}
 \newcommand{\dd}{\mathrm{d}}
 \newcommand{\ds}[1]{\displaystyle{#1}}
 \newcommand{\expo}[1]{\,\mathrm{e}^{#1}\,}
 \newcommand{\ic}{\mathrm{i}}
 \newcommand{\mc}[1]{\mathcal{#1}}
 \newcommand{\mrm}[1]{\mathrm{#1}}
 \newcommand{\pars}[1]{\left(\,{#1}\,\right)}
 \newcommand{\partiald}[3][]{\frac{\partial^{#1} #2}{\partial #3^{#1}}}
 \newcommand{\root}[2][]{\,\sqrt[#1]{\,{#2}\,}\,}
 \newcommand{\totald}[3][]{\frac{\mathrm{d}^{#1} #2}{\mathrm{d} #3^{#1}}}
 \newcommand{\verts}[1]{\left\vert\,{#1}\,\right\vert}$

$\ds{\int_{0}^{\pi}\ln\pars{\sin\pars{x}}\cos\pars{2nx}\,\dd x =
-\,{\pi \over2n}:\ {\large ?}\,,\qquad n \in \mathbb{Z}\setminus\braces{0}}$.

\begin{align}
&\int_{0}^{\pi}\ln\pars{\sin\pars{x}}\cos\pars{2nx}\,\dd x =
2\,\Re\int_{0}^{\pi/2}\ln\pars{\sin\pars{x}}\expo{2\verts{n}x\ic}\,\dd x
\\[5mm] = &\
\left.2\,\Re\int_{\theta\ =\ 0}^{\theta\ =\ \pi/2}
\ln\pars{z - 1/z \over 2\ic}z^{2\verts{n}}
\,{\dd z \over \ic z}\,\right\vert_{\ z\ =\ \exp\pars{\ic\theta}}
\\[5mm] = &\
\left.2\,\Im\int_{\theta\ =\ 0}^{\theta\ =\ \pi/2}
\ln\pars{{1 - z^{2} \over 2z}\,\ic}z^{2\verts{n} - 1}\,\,\dd z\,
\right\vert_{\ z\ =\ \exp\pars{\ic\theta}}
\\[1cm] = &\
-2\,\ \overbrace{\Im\int_{1}^{\epsilon}\ln\pars{1 + y^{2} \over 2y}y^{2\verts{n} - 1}\exp\pars{\ic\,{\pi \over 2}\bracks{2\verts{n} - 1}}\ic\,\dd y}
^{\ds{=\ 0}}
\\[5mm] - &\
2\,\Im\int_{\pi}^{-\pi}\ln\pars{\ic\expo{-\ic\theta} \over 2\epsilon}
\epsilon^{2\verts{n} - 1}\exp\pars{\bracks{2\verts{n} - 1}\theta\,\ic}\epsilon\expo{\ic\theta}\ic\,\dd\theta
\\[5mm] - &\
2\,\Im\int_{0}^{1}\bracks{\ln\pars{1 - x^{2} \over 2x} + {\pi \over 2}\,\ic}x^{2\verts{n} - 1}\,\dd x
\end{align}

In the limit $\ds{\epsilon \to 0^{+}}$:
\begin{align}
&\int_{0}^{\pi}\ln\pars{\sin\pars{x}}\cos\pars{2nx}\,\dd x =
-\,\pi\int_{0}^{1}x^{2\verts{n} - 1}\,\dd x =
\bbx{\ds{-\,{\pi \over 2\verts{n}}\,,\quad n \in \mathbb{Z}\setminus\braces{0}}}
\end{align}
A: The first step in these cases is to get rid of nested transcendental functions, which we otherwise have no idea how to integrate. Integrate by parts:
$$u=\ln\sin x \Rightarrow du=\frac{\cos x}{\sin x}\,dx$$
$$dv = \cos (2nx)\,dx\Rightarrow v=\frac{1}{2n}\sin (2nx)$$
$$\int_0^\pi \ln(\sin x)\cos (2nx)\,dx = \ln\sin x\frac{1}{2n}\sin (2nx)|_0^\pi - \frac1{2n}\int_0^\pi \frac{\cos x}{\sin x}\sin (2nx)\,dx$$
The first term is 0, if you recall $\lim_{x \to 0}x\ln x=0$ and consider linear behaviour of $\sin x$ around $0$ and $\pi$. Notice also, that all the interesting dependence on $n$ is now a prefactor. The second term remains to compute (and should be independent on $n$, based on the expression we are trying to prove):
$$- \frac1{2n}\int_0^\pi \frac{\cos x}{\sin x}\sin (2nx)\,dx$$
This can be resolved in many ways. One way is by taking a shortcut through complex series (or recalling from physics the formula for finite diffraction grating):
$$2i\sin (2nx)=e^{2nxi}-e^{-2nxi}$$
$$2i\sin x=e^{xi}-e^{-xi}$$
For less writing, use $q=e^{xi}$.
$$\frac{\sin 2nx}{\sin x}=\frac{q^{2n}-q^{-2n}}{q-q^{-1}}=
\frac{q^{-2n+1}-q^{2n+1}}{1-q^2}=
q^{-2n+1}\frac{1-q^{4n}}{1-q^2}
$$
Recognize finite geometric sum:
$$=q^{-2n+1}\sum_{k=0}^{2n-1} q^{2k}=\sum_{k=0}^{2n-1} q^{2k-2n+1}=q^{-2n+1}+\cdots+q^{-1}+q+\cdots q^{2n-1}$$
which is a symmetric sum of every second power.
Recall also $\cos x = \frac12(q+q^{-1})$. This just makes two copies of the upper sum, shifted by two, symmetric again... the left and rightmost term are counted only once.
$$\frac{\cos x}{\sin x}\sin(2nx)=\frac12 q^{-2n}+\cdots+q^{-2}+1+q^2+\cdots \frac12q^{2n}$$
All terms come in pairs $q^{2k}+q^{-2k}=2\cos 2kx$ (for every $k\neq 0$), and when integrated on a whole number of periods (from $0$ to $\pi$), amount to zero. The only term to survive is:
$$\int_0^\pi\frac{\cos x}{\sin x}\sin(2nx)dx=\int_0^\pi 1\cdot dx=\pi$$
which means we are done.
Of course I'm sure I missed much more obvious ways of proving that integral equals $\pi$ regardless of $n$.
A: Hint. One may write, for $x \in (0,\pi)$,
$$
\begin{align}
\log\left(\sin x \right)&=\log\left(\frac{e^{ix}-e^{-ix}}{2i} \right)
\\&=\log\left(\frac{e^{ix}(1-e^{-2ix})}{2i} \right)
\\&=\log\left(\frac{e^{i(x-\pi/2)}(1-e^{-2ix})}{2} \right)
\\&=i(x-\pi/2)-\log 2+\log\left(1-e^{-2ix} \right)
\\&=i(x-\pi/2)-\log 2-\sum_{n=1}^\infty\frac{e^{-2nix}}{n}
\\&=-\log 2-\sum_{n=1}^\infty\frac{\cos(2nx)}{n}+i(x-\pi/2)+i\sum_{n=1}^\infty\frac{\sin(2nx)}{n}
\end{align}
$$ then by the uniqueness of Fourier coefficients one gets that

$$
\frac2\pi\int_{0}^{\pi}\ln (\sin x) \cos(2nx) \, dx=-\frac1n,\quad n\ge1,
$$ 

as wanted.
