Fourier cosine series for $\cos x$ I was trying to find the Fourier cosine series of the function $\cos x$ in $[0, \pi]$. But I am getting all $a_n$ zero. How to proceed? 
 A: $\cos\left(x\right)$ is itself a basis vector, so without any calculation you already know there is exactly one non-zero coefficient and its value is $1$... You can find that coefficient with a glance at the basis (and its numbering).
A: This question seems to have been answered in effect in comments, but here the answer is fleshed out in the "answer" section.
Under what seems to be the usual interpretation of a "Fourier cosine series",
you treat the region of integration $[0,\pi]$ as just one half of the period of a periodic function, with the other half defined by the assumption that the function is even.
When you have an even function with period $2\pi$ such as $\cos x,$ its Fourier cosine series on $[0,\pi]$ is identical to the Fourier series of the function on $[-\pi,\pi],$ which in turn can be computed by integrating over just the interval $[0,\pi].$ At least that's how I look at it.
The formula for the coefficients of the series (as shown in Wolfram Mathworld, for example), is
$$
  a_n = \frac2\pi \int_0^\pi f(x)\cos(n x) dx,
$$
and setting $f(x) = \cos x,$ this formula gives $a_1 = 1.$
A: Don't forget the sine terms:
\begin{align*}
  f(x+2L) &= f(x) \\
  f(x) &=\frac{a_{0}}{2}+
         \sum_{n=1}^{\infty}
           \left(
             a_{n}\cos \frac{n\pi x}{L}+
             b_{n}\sin \frac{n\pi x}{L}
           \right) \\
  a_{n} &= \frac{1}{L}\int_{0}^{2L} f(t)\cos \frac{n\pi t}{L} dt \\
        &= \frac{2}{\pi}\int_{0}^{\pi} \cos t \cos (2nt) dt \\
        &= 0 \\
  b_{n} &= \frac{1}{L}\int_{0}^{2L} f(t)\sin \frac{n\pi t}{L} dt \\
        &= \frac{2}{\pi}\int_{0}^{\pi} \cos t \sin (2nt) dt \\
        &= \frac{8n}{(4n^{2}-1)\pi}
\end{align*}
