Evaluate $\int\limits_0^{\frac{\pi}{2}} \frac{\sin(2nx)\sin(x)}{\cos(x)}\, dx$

Method 1. Let $I(n)$ denote the integral. Then by addition formula for sine and cosine,

$$\begin{align*} I(n+1) + I(n) &= \int_{0}^{\frac{\pi}{2}} \frac{[\sin((2n+2)x) + \sin(2nx)]\sin x}{\cos x} \; dx \\ &= \int_{0}^{\frac{\pi}{2}} 2\sin((2n+1)x) \sin x \; dx \\ &= \int_{0}^{\frac{\pi}{2}} [\cos(2nx) - \cos((2n+2)x)] \; dx \\ &= 0, \end{align*}$$

if $n \geq 1$. Thus we have $I(n+1) = -I(n)$ and by double angle formula for sine,

$$I(1) = \int_{0}^{\frac{\pi}{2}} \frac{\sin (2x) \sin x}{\cos x} \; dx = \int_{0}^{\frac{\pi}{2}} 2 \sin^2 x \; dx = \frac{\pi}{2}.$$

Therefore we have

$$I(n) = (-1)^{n-1} \frac{\pi}{2}.$$


Method 2. By the substitution $x \mapsto \pi - x$ and $x \mapsto -x$, we find that

$$\int_{0}^{\frac{\pi}{2}} \frac{\sin (2nx) \sin x}{\cos x} \; dx = \int_{\frac{\pi}{2}}^{\pi} \frac{\sin (2nx) \sin x}{\cos x} \; dx = \int_{-\frac{\pi}{2}}^{0} \frac{\sin (2nx) \sin x}{\cos x} \; dx.$$

Thus we have

$$\begin{align*} I(n) & = \frac{1}{4} \int_{-\pi}^{\pi} \frac{\sin (2nx) \sin x}{\cos x} \; dx \\ & = \frac{1}{4} \int_{|z|=1} \frac{\left( \frac{z^{2n} - z^{-2n}}{2i} \right) \left( \frac{z - z^{-1}}{2i} \right)}{\left( \frac{z + z^{-1}}{2} \right)} \; \frac{dz}{iz} \\ & = \frac{i}{8} \int_{|z|=1} \frac{(z^{4n} - 1) (z^2 - 1)}{z^{2n+1}(z^2 + 1)} \; dz. \end{align*}$$

The last integrad has poles only at $z = 0$. (Note that singularities at $z = \pm i$ is cancelled since numerator also contains those factors.) Expanding partially,

$$ \begin{align*} \frac{(z^{4n} - 1) (z^2 - 1)}{z^{2n+1}(z^2 + 1)} & = \frac{z^{2n-1} (z^2 - 1)}{z^2 + 1} - \frac{z^2 - 1}{z^{2n+1}(z^2 + 1)} \\ & = \frac{z^{2n-1} (z^2 - 1)}{z^2 + 1} - \frac{1}{z^{2n+1}} + \frac{2}{z^{2n+1}(z^2 + 1)} \\ & = \frac{z^{2n-1} (z^2 - 1)}{z^2 + 1} - \frac{1}{z^{2n+1}} + 2 \sum_{k=0}^{\infty} (-1)^{k} z^{2k-2n-1}. \end{align*}$$

Thus the residue of the integrand at $z = 0$ is $2 (-1)^n$, and therefore

$$I(n) = \frac{i}{8} \cdot 2\pi i \cdot 2 (-1)^{n} = (-1)^{n-1}\frac{\pi}{2}.$$


Method 3. (Advanced Calculus) This method is just a sledgehammer method, but it reveals an interesting fact that even a nice integral with nice value at each integer point can yield a very bizarre answer for non-integral argument.

By the substitution $x \mapsto \frac{\pi}{2} - x$, we have

$$I(n) = (-1)^{n-1} \int_{0}^{\frac{\pi}{2}} \frac{\sin 2nx}{\sin x} \cos x \; dx.$$

Now, from a lengthy calculation, we find that for all $w > 0$,

$$ \int_{0}^{\frac{\pi}{2}} \frac{\sin 2wx}{\sin x} \cos x \; dx = \frac{\pi}{2} + \left[ \log 2 - \psi_0 (1 + w) + \psi_0 \left( 1 + \frac{w}{2}\right) - \frac{1}{2w} \right] \sin \pi w.$$

Thus plugging a positive integer $n$, we obtain

$$ \int_{0}^{\frac{\pi}{2}} \frac{\sin 2nx}{\sin x} \cos x \; dx = \frac{\pi}{2},$$

which immediately yields the formula for $I(n)$.