I have the given function
\begin{equation} f(t)=\begin{cases} 2, \ \ \ \ -2\le t<-1 \\ 1, \ \ \ \ -1\le t<0 \\ 2, \ \ \ \ 0\le t<1 \\ 3, \ \ \ \ 1\le t\le2 \end{cases} \end{equation}
and I want to generate the Fourier coefficients of it. I consider each indicator function at a time and get:
First indicator function, $A_1: f_1(t)= 2 \ \ \ \ \ -2\le x\le -1$: $$ \alpha_0=\int_{-2}^{-1}2dt=2\big[t\big]_{-2}^{-1}=2\\ \alpha_k=2\int_{-2}^{-1}2\cos{\omega k t}dt=\frac{8}{\pi k}\left[\sin\frac{\pi}{2} k t\right]_{-2}^{-1}=-\frac{8}{\pi k}\left[\sin \frac{\pi}{2} k\right]\\ \beta_k=2\int_{-2}^{-1}2\sin\omega kt dt=-\frac{8}{\pi k}\left[\cos\frac{\pi}{2} k t\right]_{-2}^{-1}=\frac{8}{\pi k}\left[(-1)^k -\cos \frac{\pi}{2} k \right] $$
Then I insert these in the Fourier series formula and get ie. for the first indicator function:
$$f_1(t)= 2+\sum_{k=1}^n\left(-\frac{8}{\pi k}\left[\sin \frac{\pi}{2} k\right]\right)\cos\frac{k\pi}{2}t +\left(\frac{8}{\pi k}\left[(-1)^k -\cos \frac{\pi}{2} k \right]\right)\sin\frac{k\pi}{2}t$$
and then I repeat this for the other indicator functions on each interval
$f_2(t)= 1 \ \ \ \ \ -1\le x\le 0 \\$ $$\alpha_0=\int_{-1}^{0}\text{d}t=1\\ \alpha_k=2\int_{-1}^{0}\cos{\omega k t}dt=\frac{4}{\pi k}\left[\sin\frac{\pi}{2} k t\right]_{-1}^{0}=-\frac{4}{\pi k}\left[\sin \frac{\pi}{2} k\right]\\ \beta_k=2\int_{-1}^{0}\sin\omega kt dt=-\frac{4}{\pi k}\left[\cos\frac{\pi}{2} k t\right]_{-1}^{0}=\frac{4}{\pi k}\left[\cos \frac{\pi}{2} k -1\right] $$
Then on $ f_3(t)= 2 \ \ \ \ \ 0\le x\le 1$
$$\alpha_0=\int_{0}^{1}2\text{d}t=2\\ \alpha_k=2\int_{0}^{1}2\cos{\omega k t}dt=\frac{8}{\pi k}\left[\sin\frac{\pi}{2} k t\right]_{0}^{1}=\frac{8}{\pi k}\left[\sin \frac{\pi}{2} k\right]\\ \beta_k=2\int_{0}^{1}2\sin\omega kt \text{d}t=-\frac{8}{\pi k}\left[\cos\frac{\pi}{2} k t\right]_{0}^{1}=\frac{8}{\pi k}\left[1-\cos \frac{\pi}{2} k\right]$$
and so on...
Then at the end, I sum these all up together, and get the total Fourier series for $f(t)$.
But it turns out not to be correct, I have checked and it should be correct. My question is : Is the PROCEDURE correct?
Or is there a problem with the $\omega$ or $L$ in the Fourier series formula?
According to the Fourier series literature, this should be correct procedure: you take each interval and generate the coefficients of it, then you generate the series using the Fourier series formula, and finally you add all the indicator function Fourier series together.