fourier series of $|\sin x|$

I need to find the fourier series of $$|\sin x|$$.
Im not sure my way is right, would be happy if someone fix me. I found $$a_0=4/\pi$$, the function is even, so $$b_n=0$$ but how do I calculate: $$a_n=\int_{-\pi}^{\pi}(1/\pi)|\sin(x)|\cos(nx)dx$$

-
Please do pay attention to your typing before you post your question... –  DonAntonio Oct 21 '13 at 18:28
Hint: $|\sin x|\cos (nx)$ is even, so this is twice the integral over $[0,\pi]$.. –  1015 Oct 21 '13 at 18:33
Shouldn't it be $\frac{1}{2\pi}$? Also, I added $n$ to $\cos(nx)$ in the definition of $a_n$... –  Thomas Andrews Oct 21 '13 at 18:34
@julien if its even I can make it 2*integral [0,pi]? –  bar Oct 21 '13 at 18:37
$\sin a \cos b=$... –  1015 Oct 21 '13 at 18:41

The function $x\mapsto f(x):=|\sin x|$ is even and $\pi$-periodic; therefore $f$ has a Fourier series of the form $$f(x)={a_0\over2}+\sum_{k=1}^\infty a_k \cos(2kx)$$ with $$a_k={2\over\pi}\int_0^\pi f(x)\cos(2k x)\ dx={2\over\pi}\int_0^\pi \sin x\cos(2k x)\ dx\ .$$ It follows that \eqalign{a_k&={1\over\pi}\int_0^\pi\left(\sin\bigl((1+2k)x\bigr)+\sin\bigl((1-2k)x\bigr)\right)\ dx\cr &={1\over\pi}\left({\cos\bigl((2k-1)x\bigr)\over 2k-1}-{\cos\bigl((2k+1)x\bigr)\over 2k+1}\right)\Biggr|_0^\pi\cr &={2\over\pi}\left({1\over 2k+1}-{1\over 2k-1}\right)=-{4\over\pi(4k^2-1)}\cr}\ . Therefore we have $$|\sin x|={2\over\pi}-{4\over\pi}\sum_{k=1}^\infty{\cos(2k x)\over 4k^2-1}\qquad(-\infty < x<\infty)\ .$$