# Fourier series for $\cos( \frac x2)$

I am trying to get the Fourier series for $\cos( \frac x2)$ from $[- \pi, \pi]$.

I know the general equation for a Fourier series. Since this is an even function, I know that the coefficients for $\sin(nx)$ are zero.

But I'm having difficulty solving for the coefficients for $\cos(nx)$. I know that I can't just say that the coefficient is $1$ when $n = \frac 12$, because $n$ is only integers.

We just need to evaluate the integral $$\int_{-\pi}^{\pi}\cos(x/2)\cos(nx) dx$$ for integer values of $n$. Since the integrand is even, the integral is equal to $$2\int_0^{\pi}\cos(x/2)\cos(nx) dx$$ We can now apply the trigonometric formula $$\cos(a)\cos(b) = \frac{1}{2}(\cos(a+b) + \cos(a-b))$$ to obtain $$\int_0^{\pi}\cos((n+1/2)x)dx + \int_0^{\pi}\cos((n-1/2)x) dx$$ which is simply \begin{aligned} \left.\frac{1}{n + 1/2}\sin((n+1/2)x)\right|_{0}^{\pi} + \left.\frac{1}{n - 1/2}\sin((n-1/2)x)\right|_{0}^{\pi} &= \frac{\sin((n+1/2)\pi)}{n+1/2} + \frac{\sin((n-1/2)\pi)}{n-1/2} \\ \end{aligned} If $n$ is even, then $\sin((n+1/2)\pi) = \sin(\pi/2) = 1$ and $\sin((n-1/2)\pi) = \sin(-\pi/2) = -1$.
If $n$ is odd, then $\sin((n+1/2)\pi) = \sin(-\pi/2) = -1$ and $\sin((n-1/2)\pi) = \sin(\pi/2) = 1$. So we can cleverly rewrite the above as $$\frac{(-1)^n}{n+1/2} + \frac{(-1)^{n+1}}{n-1/2}$$ which you can further simplify as desired.