Fourier series of $\sin(x)$ I know that this series has been calculated here for more then one time but I need help with a specific thing.
We define $f$ as an even function with period $2 \pi$ by $f(x)=\sin (x) $ where $0 \leq x\leq \pi$.
Find $S^f$ of $f$:
the function is even, so $b_n=0$.
so we need to find $$a_n=\int_{-\pi}^{\pi}(1/\pi)\sin(x)\cos(nx)dx$$
or $$a_n={2\over\pi}\int_0^\pi f(x)\cos(2n x)\ dx={2\over\pi}\int_0^\pi \sin x\cos(2n x)\ dx\ .$$
I found that $a_n$ is simply
$$a_n=\left\{\begin{matrix}
0, n \text{ is odd} \\ 
-\frac{4}{\pi(n^2-1)}, & n \text{ is even}
\end{matrix}\right.$$
How from here do I get to this answer:
$$S^f =2/\pi+\sum_{m=1}^{\infty}\frac{-4}{\pi(4m^2-1)}\cos(2mx)$$
Why it changed to $m$'s and what is procedure that should be taken when working with odd and even $n$s?
Thanks a lot!
 A: The change to $m$s is meant to reflect the fact that the $a_n$ are nonzero only for even $n$, so we let $n = 2m$. In general, if one wants to create a new index to represent all of the odd integers, we use $m = 2n + 1$, and, for the even integers, we use $m = 2n$. Instead of using the piecewise definition of $a_n$, we now have that $$a_{2m} = - \frac{4}{\pi((2m)^2 -1)} = - \frac{4}{\pi(4m^2 -1)} $$ and $a_{(2m+1)} = 0$ for every positive integer $m$. 
It should also be noted that $a_0 = \frac{4}{\pi}$ rather than $0$, as $$a_0 = \frac{2}{\pi} \displaystyle\int_0^{\pi} \sin(x) \cos(2(0)(x)) dx = \frac{2}{\pi} \displaystyle\int_0^{\pi} \sin(x) dx = \frac{2}{\pi} \left( - \cos(x) |_0^{\pi} \right) \Longrightarrow a_0 = \frac{4}{\pi}$$ which agrees with what is obtained by plugging $0$ into the general formula for $a_n$.
Combining all this, we get that the Fourier cosine series of $\sin(x)$ is \begin{align*} \sin(x) &= \frac{4}{\pi} + \displaystyle\sum_{n=0}^{\infty} a_n \cos(nx) dx \\ &= \frac{4}{\pi} + \displaystyle\sum_{m=1}^{\infty} a_{(2m+1)} \cos((2m+1)x) + \displaystyle\sum_{m=1}^{\infty} a_{2m} \cos(2mx) \end{align*}
Plugging in the values of $a_{2m}$ and $a_{(2m+1)}$ written above, we see that $$\displaystyle\sum_{m=1}^{\infty} a_{(2m+1)} \cos((2m+1)x) = 0$$ and we are able to conclude that $$\sin(x) = \frac{4}{\pi} + \displaystyle\sum_{m=1}^{\infty} \frac{-4}{\pi(4m^2 -1)} \cos(2mx)$$
