Show that the Fourier series of $f(x)=\cos\left(\frac{x}{2}\right)$ for $-\pi\lt x \lt \pi$ is given by $$f(x)=\frac{2}{\pi}+\frac{4}{\pi}\sum_{n=1}^{\infty}\frac{(-1)^{n+1}\cos(nx)}{4n^2 - 1}$$
Where the trigonometric Fourier series is given by
$$f(x)=\frac{a_0}{2}+\sum\limits_{n=1}^{\infty}\left[a_n\cos(nx)+b_n\sin(nx)\right]$$
Using $$a_0 = \frac{1}{\pi}\int_{-\pi}^{\pi}\cos(x/2)dx \\ a_n = \frac{1}{\pi}\int_{-\pi}^{\pi}\cos(x/2)\cos(n x)dx,\;\; n \ge 1 \\ b_n = \frac{1}{\pi}\int_{-\pi}^{\pi}\cos(x/2)\sin(n x)dx=0,\;\; n \ge 1.$$
$b_n=0\,\forall \,n$ and $a_n$ is found via the trigonometic identity $$\cos(x/2)\cos(n x)=\frac{1}{2}\{\cos(x/2+n x)+\cos(x/2-n x)\} \\ $$
Using the fact that $\int_{-\pi}^{\pi}e(x)dx=2\int_{0}^{\pi}e(x)$ for an even function $e(x)$ about a symmetric interval over the origin.
$$a_0=\frac{1}{\pi}\int_{-\pi}^{\pi}\cos(x/2)dx=\frac{2}{\pi}\int_{0}^{\pi}\cos(x/2)dx=\frac{4}{\pi}\sin\left(\frac{x}{2}\right)\bigg\lvert_0^\pi=\frac{4}{\pi}$$
So $\dfrac{a_0}{2}$ is indeed $\dfrac{2}{\pi}$ as required.
Applying similar logic to get the $a_n$
$$\begin{align}a_n &=\frac{1}{2\pi}\int_{-\pi}^{\pi}\{\cos(x/2+n x)+\cos(x/2-n x)\}dx\\&=\frac{2}{2\pi}\int_0^{\pi}\cos(x/2+n x)dx+\frac{2}{2\pi}\int_0^{\pi}\cos(x/2-n x)dx\tag{1}\\&=\frac{1}{\pi}\left.\left\{\frac{\sin(x/2+nx)}{1/2+n}+\frac{\sin(x/2-nx)}{1/2-n}\right\}\right|_{x=0}^{\pi}\\&=\frac{1}{\pi}\left.\left\{\frac{\sin(\pi/2+n \pi )}{1/2+n}+\frac{\sin(\pi/2-n \pi)}{1/2-n}\right\}\right.\\&=\frac{2}{\pi}\left.\left\{\frac{\sin(\pi/2+n \pi )}{2n+1}+\frac{\sin(n \pi-\pi/2)}{2n-1}\right\}\right.\tag{2}\end{align}$$
In the last line I used the fact that $\sin(n \pi-\pi/2)=-\sin(\pi/2-n \pi)$
I'm struggling at this point to continue the calculation but thinking about the sine graph I note that $\sin(\pi/2+n \pi )=(-1)^{n+1}$ and that $\sin(n \pi-\pi/2 )=(-1)^{n+2}$ for integer $n\ge 1$.
Substituting these into $(2)$
$$\begin{align}\frac{2}{\pi}\left.\left\{\frac{(-1)^{n+1}}{2n+1}+\frac{(-1)^{n+2}}{2n-1}\right\}\right.&=\frac{2}{\pi}\left.\left\{\frac{(-1)^{n+1}}{2n+1}-\frac{(-1)^{n+1}}{2n-1}\right\}\right.\\&=\frac{4}{\pi}(-1)^{n+1}\frac{1}{4n^2-1}\end{align}$$
This will lead to the correct answer but I don't want to achieve the right answer by accident so I am posting it here to verify.
So my questions about this proof are:
In $(1)$ I made use of $\int_{-\pi}^{\pi}e(x)dx=2\int_{0}^{\pi}e(x)$ and I assumed that the integrand is even for all $n$. Is this assumption correct?
From that same equation in $(1)$, I could have written $\frac{2}{2\pi}\int_0^{\pi}\cos(nx-x/2)dx$ instead of $\frac{2}{2\pi}\int_0^{\pi}\cos(x/2-n x)dx$ since cosine is an even function. But it is not even on the interval for which I am integrating over, $[0,\pi]$. So is it still correct to assume $\cos(x)=\cos(-x)$ even if the function is not even over that interval?
Lastly, is there anything else wrong with this proof?
Many thanks.
I would assume "$\int_{-\pi}^{\pi}e(x)dx=\int_{0}^{\pi}e(x)$" is a typo. The correct expression is $$ \int_{-\pi}^{\pi}e(x)dx=\color{red}2\int_{0}^{\pi}e(x)dx, $$ which was also obviously used in calculations. Everything else was ok. It concerns also your questions: yes, it is correct to use function properties (such as $f(-x)=f(x)$) independent of the integration interval.