Evaluate the integral $\int_0^{\pi/2} \sin (2n x) \tan x\, dx$ Is there a elementary evaluation of the integral
$
\int_0^{\pi/2}  \sin (2n x) \tan x\, dx,
$
where $n$ is the natural number? This number is related to the Fourier sine coefficient for $\tan (x/2)$.
 A: Hint. Here is an approach.


*

*Step 1. Observe that, for $x \in (-\pi/2,\pi/2)$, we have $$ \begin{align}
   \log (\cos x)&=\log \left(\frac{e^{ix}+e^{-ix}}{2}\right)\\\\ &=-\log
   2+\Re\log \left(1+e^{2ix}\right)\\\\ &=-\log 2+\Re
   \sum_{n=1}^{\infty}\frac{(-1)^{n-1}}{n} e^{2inx}\\\\ &=-\log
   2+\sum_{n=1}^{\infty}\frac{(-1)^{n-1}}{n}\cos(2nx) \tag1 \end{align} $$

*Step 2. Performing an integration by parts  $$ \int_0^{\pi/2}  \sin (2n
   x) \tan x \: dx=\left.-\sin (2n x) \log (\cos x)
   \right|_0^{\pi/2}+2n\int_0^{\pi/2}  \cos (2n x) \log (\cos x) \: dx
   $$ giving $$ \int_0^{\pi/2}  \sin (2n x) \tan x \:
   dx=2n\int_0^{\pi/2} \!\! \cos (2n x) \log (\cos x) \: dx \tag2 $$

*Step 3. By uniqueness of the Fourier coefficients, using $(1)$ and $(2)$, you just get

$$
\int_0^{\pi/2}  \sin (2n x) \tan x \:   dx=(-1)^{n-1}\frac{\pi}{2}, \qquad n=1,2,3,\ldots \tag3
$$

A: $\newcommand{\angles}[1]{\left\langle\, #1 \,\right\rangle}
 \newcommand{\braces}[1]{\left\lbrace\, #1 \,\right\rbrace}
 \newcommand{\bracks}[1]{\left\lbrack\, #1 \,\right\rbrack}
 \newcommand{\ceil}[1]{\,\left\lceil\, #1 \,\right\rceil\,}
 \newcommand{\dd}{{\rm d}}
 \newcommand{\ds}[1]{\displaystyle{#1}}
 \newcommand{\dsc}[1]{\displaystyle{\color{red}{#1}}}
 \newcommand{\expo}[1]{\,{\rm e}^{#1}\,}
 \newcommand{\fermi}{\,{\rm f}}
 \newcommand{\floor}[1]{\,\left\lfloor #1 \right\rfloor\,}
 \newcommand{\half}{{1 \over 2}}
 \newcommand{\ic}{{\rm i}}
 \newcommand{\iff}{\Longleftrightarrow}
 \newcommand{\imp}{\Longrightarrow}
 \newcommand{\Li}[1]{\,{\rm Li}_{#1}}
 \newcommand{\norm}[1]{\left\vert\left\vert\, #1\,\right\vert\right\vert}
 \newcommand{\pars}[1]{\left(\, #1 \,\right)}
 \newcommand{\partiald}[3][]{\frac{\partial^{#1} #2}{\partial #3^{#1}}}
 \newcommand{\pp}{{\cal P}}
 \newcommand{\root}[2][]{\,\sqrt[#1]{\vphantom{\large A}\,#2\,}\,}
 \newcommand{\sech}{\,{\rm sech}}
 \newcommand{\sgn}{\,{\rm sgn}}
 \newcommand{\totald}[3][]{\frac{{\rm d}^{#1} #2}{{\rm d} #3^{#1}}}
 \newcommand{\ul}[1]{\underline{#1}}
 \newcommand{\verts}[1]{\left\vert\, #1 \,\right\vert}$
\begin{align}&\color{#66f}{\large\int_{0}^{\pi/2}\sin\pars{2nx}\tan\pars{x}\,\dd x}
=\sgn\pars{n}\,\Im\int_{0}^{\pi/2}\bracks{\expo{2\verts{n}x\ic} - \pars{-1}^{\verts{n}}}\tan\pars{x}\,\dd x
\\[5mm]&=\sgn\pars{n}\,\Im
\int_{\verts{z}\ =\ 1\atop{\vphantom{\Huge A}0\ <\ \,{\rm Arg}\pars{z}\ <\ \pi/2}}
\bracks{z^{2\verts{n}} - \pars{-1}^{\verts{n}}}
{\pars{z^{2} - 1}/\pars{2\ic z} \over \pars{z^{2} + 1}/\pars{2z}}
\,{\dd z \over \ic z}
\\[5mm]&=\sgn\pars{n}\,\Im
\int_{\verts{z}\ =\ 1\atop{\vphantom{\Huge A}0\ <\ \,{\rm Arg}\pars{z}\ <\ \pi/2}}
\bracks{z^{2\verts{n}} - \pars{-1}^{\verts{n}}}
{1 - z^{2} \over 1 + z^{2}}\,{\dd z \over z}
\\[5mm]&=-\sgn\pars{n}\left.\lim_{\epsilon\ \to\ 0^{+}}\ \int_{\pi/2}^{0}
\bracks{z^{2\verts{n}} - \pars{-1}^{\verts{n}}}
{1 - z^{2} \over 1 + z^{2}}\,{\dd z \over z}
\right\vert_{\, z\ \equiv\ \epsilon\expo{\ic\theta}}
=\sgn\pars{n}\pars{-1}^{\verts{n}}\,\Im\int_{\pi/2}^{0}\ic\,\dd\theta
\\[5mm]&=\sgn\pars{n}\pars{-1}^{\verts{n} + 1}\,\,{\pi \over 2}
=\color{#66f}{\large\sgn\pars{n}\pars{-1}^{n + 1}\,{\pi \over 2}}\,,\qquad
n \in {\mathbb Z}.
\end{align}

There are two integrals $\ds{\pars{~\mbox{from}\ y=1\ \mbox{to}\ y=\epsilon\
\mbox{and from}\ x=\epsilon\ \mbox{to}\ 1~}}$ which don't yield any contribution because they are reals. 

The integration was performed by 'closing' a contour in the first quadrant.
'Real' Method:
With
$\ds{\left.I_{n}\,\right\vert_{\, n\ \geq\ 1} \equiv \half\int_{-\pi/2}^{\pi/2}\sin\pars{2nx}\tan\pars{x}\,\dd x}$
we'll have:
\begin{align}
I_{n + 1} - I_{n - 1}&=
\int_{-\pi/2}^{\pi/2}\cos\pars{2nx}\sin\pars{2x}\tan\pars{x}\,\dd x
=2\int_{-\pi/2}^{\pi/2}\cos\pars{2nx}\sin^{2}\pars{x}\,\dd x
\\[5mm]&=\int_{-\pi/2}^{\pi/2}\bracks{\cos\pars{2nx} - \cos\pars{2nx}\cos\pars{2x}}\,\dd x
=0
\end{align}
Then $\ds{I_{2n\ \geq\ 2}\,\,\, =\ I_{2}}$ and
$\ds{I_{2n + 1\ \geq\ 1}\,\,\,=\ I_{1}}$
A: Using the trigonometric identities 
$$
\sin(x)+\sin(y)=2\sin\left(\frac{x+y}2\right)\cos\left(\frac{x-y\vphantom{+}}2\right)\tag{1}
$$
and 
$$
2\sin(x)\sin(y)=\cos(x-y)-\cos(x+y)\tag{2}
$$
we get
$$
\begin{align}
[\sin(2(n+1)x)+\sin(2nx)]\tan(x)
&=2\sin((2n+1)x)\cos(x)\tan(x)\\
&=2\sin((2n+1)x)\sin(x)\\
&=\cos(2nx)-\cos(2(n+1)x)\tag{3}
\end{align}
$$
For $n\ge1$, we have
$$
\int_0^{\pi/2}\cos(2nx)\,\mathrm{d}x=0\tag{4}
$$
Therefore, integrating $(3)$ and applying $(4)$ yields
$$
\int_0^{\pi/2}\sin(2(n+1)x)\tan(x)\,\mathrm{d}x
=-\int_0^{\pi/2}\sin(2nx)\tan(x)\,\mathrm{d}x\tag{5}
$$
then noting
$$
\begin{align}
\int_0^{\pi/2}\sin(2x)\tan(x)\,\mathrm{d}x
&=2\int_0^{\pi/2}\sin(x)\cos(x)\tan(x)\,\mathrm{d}x\\
&=2\int_0^{\pi/2}\sin^2(x)\,\mathrm{d}x\\
&=\int_0^{\pi/2}(1-\cos(2x))\,\mathrm{d}x\\[4pt]
&=\frac\pi2\tag{6}
\end{align}
$$
gives that for $n\ge1$,
$$
\int_0^{\pi/2}\sin(2nx)\tan(x)\,\mathrm{d}x=(-1)^{n-1}\frac\pi2\tag{7}
$$
