<s>[INST] Fourier series of function $f(x)=0$ if $-\pi$$f(x) = \begin{cases}0 & \text{if }-\pi<x<0, \\
\sin(x) & \text{if }0<x<\pi.
\end{cases}$$
My attempt:
I went the route of expanding this function with a complex Fourier series.
$$f(x) = \sum_{n=-\infty}^{+\infty} C_{n}e^{inx}$$
$$C_{n} = \frac {1}{2\pi} \int_{0}^{\pi} \frac {e^{ix}-e^{-ix}}{2i} e^{-inx} \,\mathrm dx = \frac {1}{\pi}\left(\frac {1}{1-n^2}\right)$$
because only even $n$ terms survive, odd $n$ are 0
$$
C_0 = \frac {1}{2\pi} \int_{0}^{\pi} \sin(x)\, \mathrm dx = \frac {1}{\pi} 
$$
so
$$
f(x) = \frac{1}{\pi} + \frac {1}{\pi} \left(\frac {e^{i2x}}{1-2^2} + \frac {e^{i4x}}{1-4^2}+\frac {e^{i6x}}{1-6^2}+\cdots\right) + \frac {1}{\pi} \left(\frac {e^{-i2x}}{1-2^2} + \frac {e^{-i4x}}{1-4^2}+\frac {e^{-i6x}}{1-6^2}+\cdots\right)
$$
In sine and cosine terms,
$$
f(x) = \frac{1}{\pi} + \frac {2}{\pi} \left(\frac {\cos(2x)}{1-2^2} + \frac {\cos(4x)}{1-4^2}+\frac {\cos(6x)}{1-6^2}+\cdots\right)
$$
But the answer in my book is given as
$$
f(x) = \frac{1}{\pi} + \frac{1}{2} \sin(x)+ \frac {2}{\pi} \left(\frac {\cos(2x)}{2^2-1} + \frac {\cos(4x)}{4^2-1}+\frac {\cos(6x)}{6^2-1}+\dotsb\right)$$
I don't understand how there is a sine term and the denominator of the cosines has $-1$.
 [/INST] Note that, $C_1$ is a special case and you need to handle separately as   
$$ C_1 = \frac {1}{2\pi} \int_{0}^{\pi} \sin(x) e^{-ix} dx \neq 0. $$
</s>