<s>[INST] Fourier series for $f(x+4) = f(x)$, $f(x)=1$ for $x\in (0,2), f(x)=-1$ for $x \in (-2,0)$ Given that $f(x+4) = f(x)$ and
$f(x) = -1$ if $-2 < x < 0$, and
$f(x)=1$ if  $0 < x < 2$
Find the Fourier series.
I tried it out but I get all $0$ for $a_0$, $a_n$ and $b_n$. Can anyone help me out? I can attach the working if you need it.
 [/INST] Since $f(x)$ is odd, you should get $a_n =0$ for all $n \ge 0$. The $a_n$ coefficients correspond to the $\cos$ terms which represent the even part of $f(x)$. However, you should not get $b_n = 0$. We see that $$\int_{-2}^2 f(x) \sin\left(\frac{n\pi x}{2}\right)dx = 2 \int^2_0 \sin\left(\frac{n\pi x}{2}\right)dx = 2 \left[-\frac{2}{n\pi} \cos\left(\frac{n\pi x}{2}\right)\right]_{x=0}^{x=2} = -\frac{4}{n\pi}((-1)^n - 1),$$ which is non-zero when $n$ is odd. The coefficients $b_n$ are $\frac 1 2$ of this integral, so $$b_n = -\frac{4}{n\pi} \frac{((-1)^n- 1)}{2} = \left\{\begin{matrix}\tfrac{4}{n\pi}, & n \text{ odd}, \\ 0, & n \text{ even}. \end{matrix} \right.$$
In the integral, I used $$\int_{-2}^2 f(x) \sin\left(\frac{n\pi x}{2}\right)dx = 2 \int^2_0 f(x) \sin\left(\frac{n\pi x}{2}\right)dx$$ wihch holds since $f(x)$ is odd and thus $f(x) \sin(\alpha x)$ is even for any $\alpha \in \mathbb R$ and then we can plug in $f(x) = 1$ on the interval $0 \le x \le 2$.
</s>