What is the mistake in the calculation of $$\int_0^\infty {\cos(ax)\over(x^2+1)^2}dx$$ where $0<a\in\mathbb{R}$?
I know that the question itself has already an answered in here but when I comment about questions I rarely get answers so I opned a new question, I hope that ok, sorry in advence if it's not.
My worng attempt: $$ I:= \int_0^\infty {\cos(ax)\over(x^2+1)^2}={1\over2}\int_{-\infty}^\infty{\cos(ax)\over(x^2+1)^2}= \\ \int_{C_R}{\cos(ax)\over(x^2+1)^2} $$ where $C_R$ is the half semicircle centered at the origin with radii $R$ joint with $[-R,R]$.
The above equality holds because $\int_{-R}^R=0$. $$I= {1\over2}\cdot 2\pi i\text{Res}({\cos(ax)\over(x^2+1)^2},i)=\\ \pi i({\cos(ax)\over(x^2+i)^2})'|_{z=i}=\\ \pi i\cdot({-a\sin(az)(z+i)^2-2(z+i)\cos(az)\over (z+i)^4})|_{z=i} =\\ {\pi i\over 16}(a\sin(ai)\cdot 4-4i\cos(ia)=\\ {\pi\over 4}(\cos(ai)+ia\sin(ai))={\pi\over 8}(e^{ai}+e^{-ai}+a(e^{ai}-e^{-ai}))={\pi\over8}(e^{ai}(1+a)+e^{-ai}(1-a)) $$ But the answer should be ${\pi\over 2e}$.