I was reviewing the Fourier series for an exam and one of the practice exercises was to find the cosine and sine series of $f(x)=cos(x)$ in the interval $[0,\pi]$. When I calculate the cosine series of course the result is $a_0=0$ and $a_n=0$ for $n\neq 1$, so the final result is only $f(x)=cos(x)$.
Nevertheless, when I try to calculate the sine series, as $cos(x)$ is an even function I suppose the result should be $b_n=0$, but instead I get $b_n=\frac{4n}{\pi(n^2-1)}$ for $n$ even. Is there something wrong here? or the result is just this one and there's a mistake in my understanding of the Fourier series?
The calculations I made were: $$b_n=\frac{2}{\pi}\int_0^\pi cosx\space sin(nx) \space dx=\frac{1}{\pi}\int_0^\pi sin[(1+n)x]-sin[(1-n)x]\space dx=\frac{1}{\pi}\left[-\frac{cos[(1+n)x]}{1+n}-\frac{cos[(1-n)x]}{n-1}\right]_0^\pi=\frac{1}{\pi}\left[\frac{1}{n+1}+\frac{1}{n-1}+\frac{(-1)^n}{n+1}+\frac{(-1)^n}{n-1}\right]$$ For $n$ odd $b_n=0$.But for $n$ even: $$ b_n=\frac{1}{\pi}\left(\frac{4n}{n^2-1}\right) $$
Does this make sense? Thank you very much.