Find the Fourier Trigonometric series for:
$$f(x)= \begin{cases} \sin(x) & 0\leq x \leq \pi \\ 0 & \pi\leq x \leq 2\pi, \\ \end{cases}\quad f(x+2\pi)=f(x).$$
I tried to find the series of this function, but when I plot up to 50 terms with Wolfram, it doesn't resemble the function so I guess I made a mistake finding the Fourier series.
This is what I did:
The length of the interval is $\boxed{L= 2\pi}$.
I calculated the coefficients as follows
$$ \begin{align*} a_0&=\displaystyle \dfrac 1 L \int_{0}^ {2\pi} f(x) \, dx=\dfrac 1 L \left(\int_{0}^ {\pi} \sin(x) \, dx +\int_{\pi}^ {2\pi} 0 \, dx\right)\\ \\ a_n&= \dfrac 2 L \int_{0}^ {2\pi} f(x) \cos\left(\dfrac {2n\pi x} {L}\right) \, dx\\ &=\dfrac 2 L \left(\int_{0}^ {\pi} \sin(x) \cos\left(\dfrac {2n\pi x} {L}\right) \, dx +\int_{\pi}^ {2\pi} 0 \, dx\right)\\ &=\dfrac 1 \pi \cdot \dfrac {\cos(n \pi)+1} {(1-n^2)}\\ \\ b_n&= \frac 2 L \int_{0}^ {2\pi} f(x) \sin\left(\frac {2n\pi x} {L}\right) \, dx\\ &=\frac{2}{L} \left(\int_{0}^ {\pi} \sin(x) \sin\left(\frac {2n\pi x} {L}\right) \, dx +\int_{\pi}^ {2\pi} 0 \, dx\right)\\ &=\dfrac 1 \pi \cdot \dfrac {- \sin(n \pi)} {(n^2-1)}\\ &=0 \end{align*} $$
I computed the series using
$$ \displaystyle a_0+\sum_{n=1}^\infty \Big[a_n\cdot \cos\left(\dfrac {2n\pi x} {L}\right)+b_n \cdot \sin\left(\dfrac {2n\pi x} {L}\right)\Big]$$
Finally, the wrong Fourier series of $f(x)$ that I found is:
$$ \displaystyle \dfrac {1} {\pi} +\sum_{n=2}^\infty \Big[\displaystyle \dfrac 1 \pi \cdot \dfrac {\cos(n \pi)+1} {(1-n^2)}\cdot \cos\left( n x\right)+0 \Big]$$
*I took initial $n=2$ to avoid an undetermined series at $n=1$
Any ideas on where my mistakes are?
