<s>[INST] Integrating $\int_{0}^{\infty}\frac{\cos(x)}{(1+x^2)^2}dx$ without the residue theorem? Consider the integral
$$\int_{0}^{\infty}\frac{\cos(x)}{(1+x^2)^2}dx$$
Are there any other ways to compute this integral besides using the residue theorem?
Edit: Thank you all, kind people, for the answers. I had this on an exam and solved it with the residue theorem and was just wondering what other ways are possible and which of those do not involve complex integration.
 [/INST] Let us define integral with parameter:
\begin{align}
I(t) = \int_0 ^\infty \frac{\cos(xt)}{(1+x^2)^2}dt.
\end{align}
Taking the derivative of I:
\begin{align}
\frac{dI}{dt} = \frac{d}{dt}  \int_0 ^\infty \frac{\cos(xt)}{(1+x^2)^2}dt
=\int_0 ^\infty \frac{\partial}{\partial t} \frac{\cos(xt)}{(1+x^2)^2}dt= - \int_0^\infty \frac{x\sin(xt)}{(1+x^2)^2}dt.
\end{align}
Taking the second derivative:
\begin{align}
\frac{d^2I}{dt^2} = -\int_0^\infty \frac{x^2\cos(xt)}{(1+x^2)^2}dt =
 -\int_0^\infty \frac{(1+x^2-1)\cos(xt)}{(1+x^2)^2}dt = 
 -\int_0^\infty \frac{\cos(xt)}{(1+x^2)}dt + \int_0^\infty \frac{\cos(xt)}{(1+x^2)^2}dt
\end{align}
From here we get:
\begin{align}
I’’(t) = -\int_0^\infty \frac{\cos(tx)}{1+x^2} dt + I(t)
\end{align}
It is well known that(you can derive it similar to this metdod):
\begin{equation}
\int_0^\infty \frac{\cos(tx)}{1+x^2} dt = \frac{\pi}{2} e^{-t}
\end{equation}
So we get differential equation:
\begin{align}
I’’(t) - I(t) = -\frac{\pi}{2} e^{-t}
\end{align}
Th general solution is of the form is:
\begin{equation}
I(t) = Ae^{-t} + Be^{t}
\end{equation}
And paticular solution will be of the form $I(t) = Cte^{-t}$ and the we calculate $I’’(t) - I(t)$ to get $C = \frac{\pi}{4}$.
So final form is :
\begin{align}
I(t) = Ae^{-t} + Be^t + \frac{\pi}{4}e^{-t} t
\end{align}
To get $A$ and $B$ we calculate $I(0)$ and $I’(0)$:
\begin{align}
I(0) = \int_0^\infty \frac{1}{(1+x^2)^2} dt
\end{align}
U-sub: $u=\tan{\theta}, du = \frac{1}{\cos^2{\theta}} d\theta$
We get:
\begin{equation}
\int_0^{\frac{\pi}{2}} \frac{1}{(1+\tan^2{\theta})^2} \frac{1}{\cos^2(\theta)} dt = \int_0^{\frac{\pi}{2}} \cos^2(\theta) d\theta = \frac{\pi}{4}
\end{equation}
It is obvious that $I’(0) = 0$. After pluging in $I(t)$ and calculating $A$ and $B$ we get:
\begin{equation}
I(t) = \frac{\pi}{4}(xe^{-x} + e^{-x}).
\end{equation}
Our answer is : $I(1) = \frac{\pi}{4}(2e^{-1}) = \frac{\pi}{2e}.$
</s>