How to find the Fourier series of a periodic function 
Find the Fourier series of the function $f(t)=3t^2$, $-1\le t\le 1$.

How do I solve this problem? 
What is the general formula and the way to solve this?
 A: The Fourier series of a periodic function on $(-1,1)$ is defined as
$$S[f](t) = \sum_{n\in\mathbb{Z}} \hat{f}(n) e^{\pi i n t}$$
where the Fourier coefficients $\hat{f}(n)$ are defined by
$$\hat{f}(n)=\frac{1}{2}\int_{-1}^1 f(t) e^{-\pi i n t} dt$$
That is, you have to compute the integral
$$I=\int_{-1}^1 3t^2 e^{-\pi i n t} dt$$
To do that, use integration by parts twice, each time differentiating the $3t^2$ factor:
First assume $n\not=0$.
$$I=\int_{-1}^1 3t^2 e^{-\pi i n t} dt=\left[\frac{-3t^2}{\pi i n} e^{-\pi i n t}\right|_{-1}^1+\frac{6}{\pi i n}\int_{-1}^1te^{-\pi i n t} dt\tag{1}$$
Now note that for:
$$e^{\pm\pi i n} = \cos(\pm \pi n) + i\sin(\pm \pi n)= (-1)^n$$
Therefore the boundary term on the right hand side of $(1)$ equals $0$.
$$I=\frac{6}{\pi i n} \int_{-1}^1 t e^{-\pi i n t}=\left[\frac{6t}{\pi^2 n^2}e^{-\pi i n}\right|_{-1}^1-\frac{6}{\pi^2 n^2}\int_{-1}^1 e^{-\pi i n t} dt$$
Note that (here we use $n\not=0$):
$$\int_{-1}^1 e^{-\pi i nt} dt=0$$
because $e^{\pi i n}=e^{-\pi i n}=(-1)^n$. Thus
$$I=\left[\frac{6t}{\pi^2 n^2}e^{-\pi i n}\right|_{-1}^1=\frac{12}{\pi^2 n^2} (-1)^n$$
The Fourier coefficients are therefore
$$\hat{f}(n)=\frac{1}{2}I=\frac{6}{\pi^2 n^2}(-1)^n$$
if $n\not=0$. We still have to compute the Fourier coefficient for $n=0$ (we assumed $n\not=0$):
$$\hat{f}(0)=\frac{1}{2}\int_{-1}^1 3t^2 dt= \int_0^1 3t^2 dt = 1$$
Now we are done. The Fourier series of $f$ is given by
$$
\boxed{\displaystyle S[f](t) = 1+\frac{6}{\pi^2} \sum_{n\in\mathbb{Z},n\not=0}^\infty \frac{(-1)^n}{n^2} e^{\pi i nt}}
$$
We can also write it using $\cos$ instead of $\exp$:
$$S[f](t) = 1+\frac{6}{\pi^2} \sum_{n=1}^\infty \frac{(-1)^n}{n^2} (e^{\pi i n t} + e^{-\pi i n t})=1+\frac{12}{\pi^2} \sum_{n=1}^\infty \frac{(-1)^n}{n^2} \cos(\pi n t)$$
Addendum:
To give you a reason why Fourier series are cool:
If we now use Parseval's formula, we have the chance get the sum $\sum_{n=1}^\infty \frac{1}{n^4}$ for free (at the same time this serves as a sanity check to see whether our calculation was correct at all):
On the one hand,
$$\sum_{n\in\mathbb{Z}} |\hat{f}(n)|^2=1+\frac{36}{\pi^4}\sum_{n\in\mathbb{Z}} \frac{1}{n^4}=1+\frac{72}{\pi^4} \sum_{n=1}^\infty \frac{1}{n^4}$$
On the other hand,
$$\frac{1}{2}\int_{-1}^1 |f(t)|^2 dt = \frac{9}{2}\int_{-1}^1 t^4 dt = 9 \int_0^1 t^4 dt=\frac{9}{5}$$
Therefore, by Parseval:
$$\frac{9}{5} = \frac{1}{2}\int_{-1}^1 |f(t)|^2 dt  = \sum_{n\in\mathbb{Z}} |\hat{f}(n)|^2 = 1+\frac{72}{\pi^4} \sum_{n=1}^\infty \frac{1}{n^4}$$
That is,
$$\boxed{\displaystyle \sum_{n=1}^\infty \frac{1}{n^4} = \frac{\pi^4}{90}}$$
