Fourier Series Representation for piecewise function I've been posed the following question:


$$
f(x)=
\begin{cases}
1-x^2, & 0 \leqslant|x|<1,\\
0, & 1\leqslant|x|<2\\
\end{cases}
$$

I'm trying to find the Fourier series representation but I am having trouble with $ a_n$ and $b_n$ coefficients.
For reference, I obtained $a_0 = \frac{4}{3}$ and I'm pretty sure this is correct.
For $a_n$, I have tried solving the following 
$$\frac{1}{2} \int_{-2}^{2} (1-x^2)\cos \left(\frac{\pi m x}{2} \right) dx$$
to obtain 
$$\frac{16}{\pi^2 m^2} \cos(2 \pi m) \cos \left(\frac{\pi n x}{2} \right)$$
but am fairly certain I did not obtain the correct answer.
For $b_n$, the function $1-x^2$ is even and hence $b_n = 0$. However, I'm not sure if this is right either.
Any help will be much appreciated!

As you said $a_0=\dfrac43$ and $b_n=0$. Also integrating by parts shows
$$a_n=\dfrac{1}{2}\int_{-2}^{2} (1-x^2)\cos\dfrac{m\pi x}{2}\ dx
= \dfrac{1}{2}
\left[
(1-x^2)\left(\dfrac{2}{m\pi}\right)\sin\dfrac{m\pi x}{2}
-2x\left(\dfrac{2}{m\pi}\right)^2\cos\dfrac{m\pi x}{2}
+2\left(\dfrac{2}{m\pi}\right)^3\sin\dfrac{m\pi x}{2}
\right]_{-1}^{1}
= \dfrac{1}{2}
\left[
-2\left(\dfrac{2}{m\pi}\right)^2\cos\dfrac{m\pi}{2}
-2\left(\dfrac{2}{m\pi}\right)^2\cos\dfrac{m\pi}{2}
+2\left(\dfrac{2}{m\pi}\right)^3\sin\dfrac{m\pi}{2}
+2\left(\dfrac{2}{m\pi}\right)^3\sin\dfrac{m\pi}{2}
\right]
= \color{blue}{
-2\left(\dfrac{2}{m\pi}\right)^2\cos\dfrac{m\pi}{2}
+2\left(\dfrac{2}{m\pi}\right)^3\sin\dfrac{m\pi}{2}
}
$$
