I want to compute this integral $$\int_{-\frac{\pi}{2}}^\frac{\pi}{2} \cos(x)\,e^{-inx} dx $$ to determine the fourier coefficients of $$y(x)=\max(\cos(x),0)$$ In order to calculate the sum of $$ \sum_{1}^\infty \frac{(-1)^n}{4n^{2}-1} $$
When I calculate the coefficients, I rewrite $\cos(x)$ in terms of exponentials: $$ \int_{-\frac{\pi}{2}}^\frac{\pi}{2} \frac{e^{ix}+e^{-ix}}{2}e^{-inx}\,dx $$
I'm able to integrate this integral, but I get something really messy in the end with several cases..not able to solve it in order to get something useful to compute the sum.
The integral is
$$\frac{e^{-inx}}2\left(\left.\frac{e^{ix}}{i(1-n)}+\frac{e^{-ix}}{i(-1-n)}\right)\right|_{-\pi/2}^{\pi/2}\\ =\frac{e^{-in\pi/2}}2\left(\frac1{1-n}+\frac1{1+n}\right)-\frac{e^{in\pi/2}}2\left(-\frac1{1-n}-\frac1{1+n}\right)\\ =\frac{\cos\left(n\frac\pi2\right)}{1-n^2}.$$