Complex Fourier Series of $ cos(x) $ I calculated the complex Fourier Series of 

$$c_n= \frac{1}{2\pi}\cdot\int_{-\pi/2}^{\pi/2}cos(x)\cdot e^{-jnx}$$ 
$$c_0 = \frac{1}{2\pi}\cdot\int_{-\pi/2}^{\pi/2}cos(x)\cdot e^{-j0x} = \frac{1}{2\pi}\cdot\int_{-\pi/2}^{\pi/2}cos(x) = \frac{1}{2\pi}\cdot \Bigg[ sin(x)\Bigg]_{-\pi/2}^{\pi/2} =\frac{1}{\pi}$$
$$c_n= \frac{1}{2\pi}\cdot\int_{-\pi/2}^{\pi/2}cos(x)\cdot e^{-jnx} = \frac{1}{\pi}\cdot\frac{cos(\frac{\pi}{2}n)}{-n^2+1}$$
for $n=2k-1$ $c_n = 0$
for $n = 2k$ 
$$c_{2k} = \frac{1}{\pi}\cdot\frac{(-1)^k}{-4k^2+1} $$
$$ f(x)= \frac{1}{\pi} + \sum_{k=1}^\infty \frac{1}{\pi}\cdot \frac{(-1)^k}{-(2k)^2+1}\cdot e^{-j2kx} + \sum_{k=1}^\infty \frac{1}{\pi}\cdot\frac{(-1)^k}{-(2k)^2+1}\cdot e^{j2kx} $$
This should be correct. What bothers me is that Mathematica shows this when I expand the sum to the second grade: 
$$ \frac{e^{jx}}{4} + \frac{e^{-jx}}{4} + \frac{1}{\pi} + \frac{e^{j2x}}{3\pi} + \frac{e^{-j2x}}{3\pi} $$
I don't know how to get the first two summands because the first two summands (k=1) should be $\frac{e^{j2x}}{3\pi} + \frac{e^{-j2x}}{3\pi}$
Edit: 
Finally I tried to calculate $c_1$ in the same way as $c_0$ 
$$ c_1 = \frac{1}{2\pi}\cdot\int_{-\pi/2}^{\pi/2}cos(x)\cdot e^{-jx} = \frac{1}{4} $$
The question is why? I didn't expect any odd coefficients and for $n>1$ it's true. When do I only have to extract $c_0$ and when I need to extract more summands? 
 A: Notice that the first odd coefficient is strictly positive, since 
$$ \int_{-\pi/2}^{\pi/2} \cos(x) e^{\pm ix} dx =  \int_{-\pi/2}^{\pi/2} \cos(x)^2 dx > 0 $$
contrary to the claim that the coefficients are $0$ for odd $n$.
A suggestion, since $$f(x) = cos(x) R(x)$$
where $R$ is the rectangle function $R(x) =\mathbb 1_{[-\pi/2,\pi/2]}(x)$, a potentially less error-prone way to compute the fourier coefficients if you know $\hat R$ is to use the convolution result
$$\hat f (n) = (\widehat \cos *\hat R)(n)$$
and $\widehat \cos(n) = \begin{cases} 1/2 & n=\pm 1 \\ 0 &\text{otherwise} \end{cases}$ is pretty simple.
A: Your formula
$$c_n=-{1\over\pi}\,{\cos{n\pi\over2}\over n^2-1}\qquad(n\in{\mathbb Z})\tag{1}$$
is true, but some exception handling is necessary: If $n=\pm1$ the expression $(1)$ is undefined. One then can do a special computation for these values of $n$. Another way out is the following: Looking at the defining integral we can see that $c_n$ is actually a continuous function of the real variable $n$. Therefore we can be sure that
$$c_1=-{1\over\pi}\>\lim_{n\to 1}\,{\cos{n\pi\over2}\over n^2-1}={1\over\pi}\lim_{n\to1}{{\pi\over2}\sin{n\pi\over2}\over 2n}={1\over4}\ ,$$
by Hôpital's rule; furthermore $c_{-1}=\overline{c_1}={1\over4}$ as well.
A: We have $|u|+u=2u$ for $u>0$, $|u|+u=0$ otherwise.  So, render your given function as $(1/2)(|\cos x|+\cos x)$ where:
•  The absolute value term has no odd degree components because its fundamental period is $\pi$ rather than $2\pi$.
• That leaves only the "pure" cosine term which, of course, gives one pair of conjugate odd-degree terms at $n=\pm 1$.  The existence of the second component explains why $n=\pm 1$ departs from the general formula for odd $n$.
