# A difficult trigonometric integral involving absolute value

$$\int_{0}^{2\pi}\lvert\sin(x)\rvert\cos(nx)\,dx= -\frac{4\cos^2\bigl(\frac{\pi n}{2}\bigr)\cos(\pi n)}{n^2-1}$$

I'm not actually trying to solve this myself. The answer appears in my lecture notes without any explanation whatsoever. Apparently it depends on whether or not $n$ is odd or even, since the answer is $0$ when $n$ is odd, but I really don't understand how they've gotten the answer at all. Please help me to figure out what the heck is going on!

It might help to divide the integral into two, $\int_0^{\pi}$ and $\int_{\pi}^{2\pi}$. In the first one, $|\sin x|=\sin x$ and in the second one $|\sin x|=-\sin x$. Then one integrate by parts two times, or better, uses the formula $$\sin x\cos nx=\frac{1}{2}(\sin(n+1)x-\sin(n-1)x).$$ It is a good exercise to do the calculations to see how it works (and what you get).
• Yes, I now see that including the $\sin{n \pi}$ factor brings about the stated equation. My apologies for not seeing that. – Ron Gordon Apr 6 '15 at 17:21
the graph of $y = |\sin(x)|\cos(nx)$ is $2\pi$-periodic, even and odd about $x = \pi/2$ when $n$ is odd. therefore $$\int_0^{2\pi} |\sin(x)|\cos(nx) = 0 \text{ for } n \text{ odd. }$$
in the case $n$ even, $y = |\sin(x)|\cos(nx)$ is $\pi$-periodic,and even about $x = \pi/2.$ therefore
\begin{align}\int_0^{2\pi} |\sin(x)|\cos(nx) &= 4 \int_0^{\pi/2} sin x \cos nx \, dx=2\int_0^{\pi/2} \left(\sin(nx + x)-\sin(nx-x)\right)\, dx\\ &= 2\left(\frac 1{n+1}\cos(n+1)x-\frac 1{n-1}\cos(n-1)x\right)\Big|_0^{\pi/2}\\ &=2\left(\frac 1{n+1}\cos(n+1)\pi/2-\frac 1{n-1}\cos(n-1)\pi/2\right) - 2\left(\frac 1{n+1}-\frac 1{n-1}\right)\\&=\frac 4{n^2 -1}\end{align}