How this answer came by solving "$a_n$" of Fourier series.
$$a_n=\int_{-1}^1 t^2 \cos (n\pi t) dt = 4(-1)^n / (\pi n)^2$$
?
How can I mathematically derive this answer? My answers comes to
$$2 \sin n\pi (t^2/n\pi - 2/(n\pi)^2) $$
How can I derive the above mentioned answer
$$a_n=\int_{-1}^1 t^2 \cos (n\pi t) dt = 2\,{\frac {-2\,\sin \left( n\pi \right) +{n}^{2}{\pi }^{2}\sin\left( n\pi \right) +2\,n\pi \,\cos \left( n\pi \right) }{{\pi }^{3 }{n}^{3}}}\,.$$
Now, since $n$ is a positive integer, then you can see that $\sin(n\pi)=0$ and $\cos(n\pi)=(-1)^n$. So, the above answer reduces to
$$ a_n = 4(-1)^n / (\pi n)^2\,.$$