How can I expand $$f(x)=\begin{cases} 0 & -\pi \leq x<0\\ \sin x & 0 < x \leq \pi \end{cases} $$
as a Fourier series on the interval $[{-\pi}, \pi]$.
I know that: $$ \sin A \cos B = \frac{1}{2} [\sin(B + A) − \sin(B − A)] $$ $$ \sin A \sin B = \frac{1}{2} [\cos(B - A) − \cos(B + A)] $$ Will be beneficial for finding the answer. And that there will be invalid cases where division by zero occurs in the solution and therefore these cases would need to be recalculated.
Formula for the fourier series of a functuion $f(x)$ on the interval $[{-\pi}, \pi]$:
$$ f(x) = \frac{a_0}{2} + \sum\limits_{n=1}^\infty a_n \cos(\frac{n\pi x}{\pi})+ b_n \sin(\frac{n\pi x}{\pi}) $$
where
$$ a_n = \frac{1}{\pi} \int_{-\pi}^{\pi} f(x)\cos(\frac{n\pi x}{\pi}) \space dx, \space \space \space \space \space \space n =0,1,2,... $$ $$ b_n = \frac{1}{\pi} \int_{-\pi}^{\pi} f(x)\sin(\frac{n\pi x}{\pi}) \space dx, \space \space \space \space \space \space n =1,2,3,... $$
Just use the formulas you hace written. For instance $$ b_n=\frac1\pi\int_0^\pi\sin x\cos(n\,x)\,dx=\frac1{2\,\pi}\int_0^\pi\bigl(\sin(n+1)x-\sin(n-1)x\bigr)\,dx. $$