I would like to compute the Fourier series for the following function:
$f:\left[-\pi,\pi\right]\to \mathbb{R}$, $f(t)=\cos(t)$.
So:
$$a_{0}=\frac{1}{2\pi}\int^{\pi}_{-\pi}{\cos(t)dt}=0$$
$$a_{n}=\int^{\pi}_{-\pi}{\cos(t)\cos(nt)}dt=-\frac{2n\sin(\pi n)}{n^2-1}=0$$
$$b_{n}=\int^{\pi}_{-\pi}{\cos(t)\sin(nt)}dt=0$$
It seems that everything is $0$. I'm sure that something is wrong.
Please, tell me where the mistake is.
$a_1$ should be non-zero (the rest are indeed 0). This is because $\cos(t)=\cos(t)$; it requires only one basis vector to be expressed. Check your work for $a_1$ (the formula you have is undefined for $n=1$).