I have been given the following question.
"The function $f(x)$ is odd, has a period $2\pi$ and satisfies:
$$f(x)=\begin{cases} 1 & 0\lt x \lt \pi \\ -1 & \pi \lt x \lt 2\pi \end{cases}$$
Find its fourier series.
As it is an odd function I have put that $a_0=0$ and $a_n=0$.
I have worked out that $b_n=\frac{2}{n\pi}(-1)^{n+1}$
Thus the solution $f(x)$ would be $ \sum_{n=1}^{\infty}b_n \sin(nx)$
Is this correct? I cannot find the solution.
Thanks.
$b_n=\frac 1\pi \int_0^{2\pi}f(x)\sin nx dx$
$b_n=\frac 1\pi \int_0^{\pi}\sin nx dx-\frac 1\pi \int_0^{\pi}\sin nx dx$
$b_n=\frac 1\pi \left|-\frac{\cos nx}{n}\right|^{\pi}_{0}-\frac 1\pi \left|-\frac{\cos nx}{n}\right|^{2\pi}_{\pi}$
$b_n=\frac {-1}{n\pi} \left|\frac{\cos nx}{n}\right|^{\pi}_{0}+\frac {1}{n\pi} \left|\frac{\cos nx}{n}\right|^{2\pi}_{\pi}$
$b_n=\frac{-1}{n\pi}((-1)^ n-1)+\frac{1}{n\pi}(1-(-1)^n)$
$b_n=\frac{1}{n\pi}(1-(-1)^ n)+\frac{1}{n\pi}(1-(-1)^n)$