I'm trying to find the Fourier series for $f(\theta) = |\sin\theta|$. The function is even, so $b_n = 0 \space\forall n$. Doing the integration for $a_n$ yields
$$a_n = \frac{2}{\pi}\left(\frac{1+(-1)^n}{1-n^2}\right)$$
Then, calculating $a_0$ to be $\frac{4}{\pi}$ and plugging into the Fourier series formula gives
$$f(\theta) = \frac{2}{\pi} + \frac{2}{\pi} \sum_{n=1}^\infty \frac{1+(-1)^n}{1-n^2} \cos(n\theta)$$
I then tried graphing this function to check my answer, and realised that the first term of the series is undefined as it involves a division by $0$. I then tried starting the series from $n=2$ instead of $n=1$, and the graph looked correct. How do we deal with Fourier terms that are undefined? Can we always just ignore them?
EDIT: Formula for $a_n$:
$$a_n = \frac{1}{\pi} \int_{-\pi}^\pi f(\theta) \cos(n\theta)d\theta = \frac{2}{\pi} \int_{0}^\pi \sin\theta \cos(n\theta)d\theta$$
Solving:
Let $$I = \int_{0}^\pi \sin\theta \cos(n\theta)d\theta$$
By parts:
$$I = \Bigl[-\cos\theta \cos(n\theta)\Bigr]_0^{\pi}-n\int_0^\pi\cos\theta \sin(n\theta)d\theta$$ $$=(1+(-1)^n)-n\Bigl(\Bigl[\sin\theta\sin(n\theta)\Bigr]_0^\pi-n\int_0^{\pi}\sin\theta\cos(n\theta)d\theta\Bigr)$$ $$=1+(-1)^n+n^2I$$ $$\implies I = \frac{1+(-1)^n}{1-n^2}$$ $$\therefore a_n = \frac{2}{\pi}\left(\frac{1+(-1)^n}{1-n^2}\right)$$