I need your help double-checking my working for finding the Fourier Series representation of a "piecewise" function.
The function I was given is
$$f(t) = \begin{cases}t + 1 & ,-1 < t \le 1 \\ 0 & ,-3 < t \le -1\end{cases}$$
To find the fourier respresentation, I know I need to find the coefficients $a_0, a_n,\ and\ b_n$, and the period of the function is 4 units (-3 to 1).
So, for $a_0$:
$$a_0 = \frac 12 \int_{-1}^1 (t + 1) \ dt \ + \frac 12 \int_{-3}^{-1} 0 \ dt$$
$$=\frac 12 \left[\frac{t^2}2 \ | \ (1, -1)\right]\ + \ \frac 12 \left[t \ | \ (1, -1)\right] \ + \ 0$$
$$=1$$
$a_n$:
$$a_n = \frac 12 \int_{-1}^1 (t + 1) \cdot \cos(\frac{n\pi t}2) \ dt \ + \frac 12 \int_{-3}^{-1} 0 \cdot cos(\frac{n\pi t}2) \ dt$$
$$= \frac 12 \int_{-1}^1 t \cdot \cos(\frac{n\pi t}2) \ dt \ + \frac 12 \int_{-1}^1 \cos(\frac{n\pi t}2) \ dt \ + \ 0$$
$$= 0 +\frac 12 \left[\frac2{n\pi} \cdot \sin(u) \ | \ (\frac {n\pi}2, -\frac {n\pi}2)\right]$$
$$= \frac{2\sin(\frac{n\pi}2)}{n\pi}$$
$b_n$:
$$b_n = \frac 12 \int_{-1}^1 (t + 1) \cdot \sin(\frac{n\pi t}2) \ dt \ + \frac 12 \int_{-3}^{-1} 0 \cdot \sin(\frac{n\pi t}2) \ dt$$
$$= \frac 12 \int_{-1}^1 t \cdot \sin(\frac{n\pi t}2) \ dt \ + \frac 12 \int_{-1}^1 \sin(\frac{n\pi t}2) \ dt \ + \ 0$$
$$= \frac 12 \left[\frac{\sin(\frac{n\pi t}2)}{(\frac{n\pi}2)^2} - t \cdot \frac{\cos(\frac{n\pi t}2)}{(\frac{n\pi}2)} \ | \ (1, -1)\right] \ + \ 0$$
$$= \frac 12 \left[(\frac{\sin(\frac{n\pi }2)}{(\frac{n\pi}2)^2} - \frac{\cos(\frac{n\pi }2)}{(\frac{n\pi}2)}) - (\frac{-\sin(\frac{n\pi }2)}{(\frac{n\pi}2)^2} + \frac{\cos(\frac{n\pi }2)}{(\frac{n\pi}2)})\right]$$
$$= \frac{4\sin(\frac {n\pi }2) - 2n\pi \cos(\frac {n\pi}2)}{n^2\pi^2}$$
With all this, the fourier representation would be:
$$f(t) = \frac 12 + \sum_{n=1}^\infty \left[\left(\frac{2\sin(\frac{n\pi}2)}{n\pi} \cdot \cos(\frac{n\pi t}2)\right) + \left(\left(\frac{4\sin(\frac {n\pi }2) - 2n\pi \cos(\frac {n\pi}2)}{n^2\pi^2}\right) \cdot \sin(\frac {n\pi t}2)\right)\right]$$
Provided we define $f(t)$ as 1 at the points of discontinuity: $t = 1, -3, 5, -7, 9, ...$
And the first five non-zero terms of the series would be:
$$\frac 12 + \left[\frac2\pi \cdot \cos(\frac{\pi t}2)\right] + \left[\frac 4{\pi^2} \cdot \sin(\frac{\pi t}2)\right] + \left[\frac 1\pi \cdot \sin(\pi t)\right] - \left[\frac 2{3\pi} \cdot \cos(\frac{3\pi t}2)\right]$$
Right now, with how complicated all this looks, I'm fairly certain that I'm doing something wrong here, but for the life of me, even after going through my notes several times, I can't find anything obviously wrong.
Any help you guys can provide will be greatly appreciated. Thanks a lot in advance!