<s>[INST] Coefficient calculation on Fourier series !? in a Fourier series for function
$$f(x)=\begin{cases}-1&\text{for }-\pi<x<0\\\sin x&\text{for }0<x<\pi\end{cases}$$
with $f(x)=f(x+ 2 \pi)$, is $f(x)= \dfrac{a_0}{2}+ \sum\limits_{n=1}^{ \infty}(a_n \cos nx+b_n \sin nx)  $. we have:

$a_n=0, n=2k+1; b_n=0, n=2k$

I get stuck in this problem. How this coefficient was calculated?‌ a bit more explanation was highly appreciated.
 [/INST] The function is defined on the interval $(- \pi, 0) \cup (0,\pi)$, which means that the length of the interval (which happens to be the period) is $\boxed{L = 2\pi}$.
We know that:
$$\displaystyle a_n= \dfrac 2L \cdot \int_{-\pi}^{\pi} f(x)\cdot \cos\left(\dfrac{2n\pi x} L\right) \,dx.$$

However, 
$$\displaystyle \int_{-\pi}^0 -1\cdot  \cos (nx)\,dx = -\dfrac{\sin(n\pi)}\pi=0, \quad \text{since $n$ is an integer}.$$
How to compute 
$$\displaystyle \int_0^\pi \sin x \cdot  \cos (nx)\, dx.$$
Integrals of the form $$\displaystyle \int \sin (\alpha x)\cdot \cos (\beta x)\,dx$$ are evaluated using the formula:
$$\boxed{2 \sin\alpha \cos \beta = \sin(\alpha+\beta) +\sin(\alpha - \beta)}.$$
Thus, we have:
$\displaystyle \int_0^\pi \sin x \cos(nx)\,dx = 
\dfrac 12 \int_0^\pi 2 \sin x \cos (nx)\,dx 
=\displaystyle\dfrac 12 \int_0^\pi \sin(x+nx) + \sin(x-nx) \, dx\\
=\displaystyle\dfrac 12 \int_0^\pi \sin[(n+1) x]\, dx + \dfrac 12 \int_0^\pi \sin[(1-n)x]\, dx\\
=-\displaystyle\dfrac 12 \cdot \left[\dfrac {\cos[(n+1)x]}{n+1}\right]_0^\pi -\dfrac 12 \cdot \left[\dfrac{\cos[(1-n)x]}{1-n}\right]_0^\pi\\
= \cdots\\
= \dfrac 12 \cdot \left(\dfrac{n-1}{n^2 -1} - \dfrac{(n-1) \cos[(n+1) \pi]}{n^2-1} - \dfrac{(n+1)\cos[(1-n)\pi]}{1-n^2} + \dfrac{n+1}{1-n^2}\right)\\
= \dfrac 12 \cdot \dfrac{2 + (n-1) \cos[(n+1)\pi] - (n+1) \cos[(n-1)\pi]}{1-n^2}\\
=\dfrac 12 \cdot \dfrac {2 - 2\cos[(n+1)\pi]}{1-n^2}, \quad\text{because $\cos[(n+1)\pi] = \cos[(n-1)\pi]$, for $n\geqslant 1$}\\
= \dfrac 12 \cdot \dfrac{1 - \cos[(n+1) \pi]} {1-n^2}\\
= \dfrac {1+\cos(n\pi)}{1-n^2}, \quad \text{because $\cos[(n+1)\pi] = -\cos(n\pi)$}.
$
Also, I used the fact that $\cos[(n-1) \pi ] =  \cos [(1-n)\pi]$.
Thus, $$a_n = \dfrac 2 {2\pi} \cdot \dfrac{1+\cos(n\pi)}{1-n^2}.$$
For $b_n$ you will need to  evaluate  $\displaystyle \int \sin x \sin(nx)\, dx$.
Thus, you will need to use the identity 
$$\boxed{2 \sin\alpha \sin \beta = \cos(\alpha - \beta) - \cos(\alpha +\beta)}.$$
P.S. I cannot do all the math, since the answer is going to be too long!
</s>