The question I have been given states;
Consider the function $f:(0,\pi) \rightarrow \mathbb{R}$ defined by $x\longmapsto \sin x$
Show that the Fourier cosine series (i.e. the Fourier series of the even extension of $f$) is given by
$$\sin x\sim \frac{2}{\pi}-\sum_{n=2}^{\infty}\frac{2(1+(-1)^n)}{\pi(n^2-1)}\cos nx$$
Now I know that $f(x)\sim\frac{a_0}{2}+\sum_{n\in\mathbb{N}}a_n\cos nx$
So far I have gotten $a_0=\frac{4}{\pi}$ and I know the equation I must solve for $a_n$ is
$$a_n=\frac{2}{\pi}\int_0^\pi \! \sin x \cos nx \, \mathrm{d}x$$
My next step is to use integration by parts to get
$$=\frac{2}{\pi}((-1)^{n+1}-1)-n\int_0^\pi \cos x \sin nx$$
However, I am stuck from here.
Best Answer
You can also use the trigonometric identity:
$\sin x \cos nx = (1/2)[\sin[(n + 1)x] − \sin[(n − 1)x]] $
to avoid integration by parts.