I want to find the Fourier series of $f(x)$ defined by $f(x)=\begin{cases} 1 , -L\le x<0\\ 0, 0\le x<L. \end{cases} $
Well, to find $a_0$ I do this integral: $$a_0=1/L \int _{-L}^0 dx +1/L \int _0^L0 \, dx=1.$$
Calculating the others:
$a_n=0$.
$$b_n=1/L \int _{-L}^0 \sin\frac{\pi n x }L \, dx=-\frac{1}{\pi n}(1-\cos(\pi n))=-\frac{1}{\pi n}(1-(-1)^n)).$$
Now the answer in the book is this:
$$f(x)=\frac{1}{2}-\frac{2}{\pi}\sum_{n=0}^\infty \frac{\sin{[(2n-1)\frac{\pi n}{L}]}}{2n-1}$$
Why my $a_0$ is wrong? And what about the $\cos (\pi n)$ term? Thank you very much for your help!
Note that
$$a_0 = \frac{1}{2L}\int_{-L}^{L} \dots$$