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?
$$ \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 it is 0 for odd $n$
– Calvin Khor Sep 11 '18 at 07:56