How to find the Fourier's coefficient $a_n$ of the Fourier's series of $\sin(x)$ on $(0,\pi]$, $0$on $(-\pi,0]$ Considering $g(x)$, periodical with a period of $2\pi$ defined by
\begin{equation*}
  g(x)=
     \begin{cases}
       0 & \text{for $x \in (-\pi;0]$} \\
        \sin(x)  & \text{for $x \in [0;\pi)$}
     \end{cases}
\end{equation*}
I want to find the Fourier's series $S(g)$ of $g$.
\begin{align*}
a_n&=\frac{1}{\pi}\int\limits_0^\pi \sin(x)\cos(x)d(x)\\
&=[sin^2(x)]-\int\limits_0^\pi \cos^2(x)d(x)\\
&=-\frac{1}{2}\int\limits_0^\pi (\cos(2x)+1)d(x)\\
&= \sin(2x)+\frac{x}{2}\\
\end{align*}
I've the feeling, seeing the solution of \begin{equation*}
  g(x)=
     \begin{cases}
       0 & \text{for $x \in (-\pi;0]$} \\
        x\sin(x)  & \text{for $x \in [0;\pi)$}
     \end{cases}
\end{equation*}
That I'm wrong...

For 
\begin{equation*}
  g(x)=
     \begin{cases}
       0 & \text{$x \in [-\pi,0)$} \\
        \sin(x)  & \text{$x \in [0,\pi)$}
     \end{cases}
\end{equation*}
Write
$$g(x) = \frac12 a_0 + \sum_{n=1}^{\infty} \left (a_n \cos{n x} + b_n \sin{n x} \right ) $$
$$a_0 = \frac1{\pi} \int_0^{\pi} dx \, \sin{x} = \frac{2}{\pi}$$
$$a_1 = \frac1{\pi} \int_0^{\pi} dx \, \sin{x} \cos{x} = 0$$
$$b_1 = \frac1{\pi} \int_0^{\pi} dx \, \sin^2{x} = \frac12$$
For $n \gt 1$:
$$\begin{align}a_n &= \frac1{\pi} \int_0^{\pi} dx \, \sin{x} \cos{n x}\\ &= \frac1{2 \pi}  \int_0^{\pi} dx \, \left [\sin{(n+1) x} - \sin{(n-1) x} \right ]\\ &= \frac1{2 \pi} \left [\frac{1-(-1)^{n+1}}{n+1} - \frac{1-(-1)^{n-1}}{n-1} \right ] \\ &= -\frac{1+(-1)^n}{\pi (n^2-1)} \end{align}$$
$$\begin{align}b_n &= \frac1{\pi} \int_0^{\pi} dx \, \sin{x} \sin{n x}\\ &= \frac1{2 \pi}  \int_0^{\pi} dx \, \left [\cos{(n-1) x} - \cos{(n+1) x} \right ]\\ &= 0 \end{align}$$
Thus,

$$g(x) = \frac1{\pi} + \frac12 \sin{x} - \frac{2}{\pi} \sum_{n=1}^{\infty} \frac{\cos{2 n x}}{4 n^2-1}$$

