Fourier Series of $f$ on the given interval my goal is to find the Fourier series of f on the given interval:
$$f(x) = \begin{cases} 0, & \text{if } -\pi < x < 0 \\ \sin(x), & \text{if } 0 \le x < \pi \end{cases}$$
I know there aren't any $\sin(nx)$ in the series but i'm having trouble with the $\cos(nx)$.
this is my integral:
$$\frac1\pi\int_0^\pi \sin(x)\cos(nx)=\frac{\cos(nx)+1}{\pi(1-n^2)}=\frac{(-1)^n+1}{\pi(1-n^2)}$$
normaly i simply take the result and put it in the formula yet  i don't know how to bring the result to this form:
$$\sum_{i=2}^\infty (\text{something}) \cos(nx)$$
please not it starts from 2 (i never encountered a task which it starts from 2).... any ideas what shall i do next?
 A: If:
$$f(x)=\begin{cases} 0, & \text{if } -\pi < x < 0 \\ \sin(x), & \text{if } 0 \le x < \pi \end{cases}$$
then we find the coefficients as follows
\begin{aligned}
a_n&=\frac{1}{\pi}\int_{-\pi}^{\pi}\left(\begin{cases} 0, & \text{if } -\pi < x < 0 \\ \sin(x), & \text{if } 0 \le x < \pi \end{cases}\right)\cos(nx){dx},\\
&=\frac{1}{\pi}\int_{0}^{\pi}\sin(x)\cos(nx){dx},\\
&=-{\frac {\cos \left( \pi \,n \right) +1}{\pi \, \left( {n}^{2}-1
 \right) }}=-{\frac {(-1)^n +1}{\pi \, \left( {n}^{2}-1
 \right) }},\\
=&\begin{cases} 0,& \text{if } n \text{ is odd} \\ {-\frac {2}{\pi \, \left( n^2-1\right) }}, & \text{if } n \text{ is even}  \end{cases}
\end{aligned}
if $n=1$ in the second from last line we would take the limit and see that it is zero; alternatively we could plug $n=1$ in the integral and see that that is zero, but either way we don't need any odd $n$ they are all zero.
Now we check the $b_n$:
\begin{aligned}
b_n&=\frac{1}{\pi}\int_{-\pi}^{\pi}\left(\begin{cases} 0, & \text{if } -\pi < x < 0 \\ \sin(x), & \text{if } 0 \le x < \pi \end{cases}\right)\sin(nx){dx},\\
&=\frac{1}{\pi}\int_{0}^{\pi}\sin(x)\sin(nx){dx},\\
&=-{\frac {\sin \left( \pi \,n \right) }{\pi \, \left( {n}^{2}-1
 \right) }},\\
=&\begin{cases} 0,& \text{if } n\ne 1 \\ -1/2 & \text{if }  n=1 \end{cases}
\end{aligned}
so we have to be careful there, we either take the limit when $n\rightarrow1$ or put $n=1$ in the integral but we do need one of the $sin$ terms. We then have:
\begin{aligned}
f(x)&=\frac{a_0}{2}+\sum_{n=1}^{\infty}a_n \cos(nx)+b_n\sin(nx),\\
&=\frac{1}{\pi}+\frac{\sin(x)}{2}-\sum_{n=1}^{\infty}{\frac {2}{\pi \, \left( 4n^2-1\right) }} \cos(2nx).
\end{aligned}

