Evaluating the integral $\int_{0}^{\infty} \frac{\cos ax}{1+x^2}dx$ I encountered this problem while calculating the Fourier Cosine Integral for the function $f(x) = \frac{1}{1+x^2}$. I know that $\int \frac{1}{1+x^2} = \arctan x + c$. I just can't figure out what to do with $cosax$ term combined. If I do integration by parts, I get:
$$\left [ \cos ax \times \tan^{-1}x \right ]_{0}^{\infty} +\int_{0}^{\infty}a \sin ax \times \tan^{-1}xdx$$
I don't know how to proceed after that. Perhaps a hint could help.
 A: Your idea of using integration by parts can be used to evaluate the integral; you'll just have to couple that with Feynman's Trick. Making the substitution $u=1/(1+x^2)$ and $dv=\cos ax\, dx$ gives$$\begin{align*}I(a)=\int\limits_0^{\infty}\frac {\cos ax}{1+x^2}\, dx & =\frac {\sin ax}{a(1+x^2)}\,\Biggr\rvert_{0}^{\infty}+\frac 2a\int\limits_{0}^{\infty}\frac {x\sin ax}{(1+x^2)^2}\, dx\\ & =\frac 2a\int\limits_0^{\infty}\frac {x\sin ax}{\left(1+x^2\right)^2}\, dx\end{align*}$$
Multiplying both sides by $a$ and differentiating with respect to $a$, we see that$$\begin{align*}a\cdot I'(a)+I(a) & =2\int\limits_0^{\infty}\frac {x^2\cos ax}{(1+x^2)^2}\, dx\\ & =2I(a)-2\int\limits_0^{\infty}\frac {\cos ax}{\left(1+x^2\right)^2}\, dx\end{align*}$$So$$a\cdot I'(a)-I(a)=-2\int\limits_0^{\infty}\frac {\cos ax}{\left(1+x^2\right)^2}\, dx$$Differentiating a second time and solving the little differential equation that follows gives$$I(a)=C_1e^a+C_2e^{-a}$$To find the constants, set $a=0$ and $a\to\infty$. Evaluating, we find that$$(C_1,C_2)=\left(0,\tfrac {\pi}2\right)$$Hence$$\int\limits_{0}^{\infty}\frac {\cos ax}{1+x^2}\, dx=\color{blue}{\frac {\pi}{2e^{|a|}}}$$With the absolute value there because $I(a)=I(-a)$ from the cosine function.
A: I'll give a purely probabilistic solution. 
Let $X%$ be a random variable that takes the value of $a$ and $-a$ each with probability $1/2$. The characteristic function of $X$ is then $\phi_X(t)=E[e^{itX}]=\frac{1}{2}(e^{iatx}+e^{-iatx})=cos(at)$. Now let $Y$ be a random variable with standard cauchy distribution.
$\int_{-\infty}^{\infty}\frac{cos(at)}{1+t^2} dt=\pi\int_{-\infty}^{\infty}\phi_X(t)f_y(t) dt$
Using Parseval's relation you have that 
$\pi\int_{-\infty}^{\infty}\phi_X(t)f_y(t) dt=\pi\int_{-\infty}^{\infty}\phi_Y(t)dFx(t) dt$
Where $\phi_Y(t)$ is the characteristic function of the standard cauchy distribution, $\phi_Y(t)=e^{-|t|}$. Now, you should note that the distribution of $X$ takes only two values $a$ and $-a$ with probability $\frac{1}{2}$ hence:
$\pi\int_{-\infty}^{\infty}e^{-|t|}dFx(t) dt=\frac{\pi}{2}(e^{ -|a|}+e^{ -|-a|})=\frac{\pi}{e^{|a|}}$.
Now this is the value for the full integral from $(-\infty, \infty)$ in your case you have $(0,\infty)$ but since $cos(x)$ is an even function and the denominator $(1+t^2)$ is the same for negative and positive numbers, you have:
$\int_{-\infty}^{\infty}\frac{cos(at)}{1+t^2} dt=2\int_{0}^{\infty}\frac{cos(at)}{1+t^2} dt$
A: 
Recall that, if we consider the Fourier transform 
  $$\mathcal Ff (a) =\int_\Bbb R e^{-ia x}f(x)dx$$
  then its Fourier inverse  is defined as 
  $$\mathcal F^{-1}f (x) =\frac{1}{2\pi}\int_\Bbb R e^{it x}f(t)dt.$$

But we have, 
\begin{split}
\mathcal F(e^{-|t|})(x) = \int_{-\infty}^{\infty}e^{-|t|}e^{-ix t}\,dt
&=&\int_{-\infty}^{0}e^{t}e^{-ix t}\,dt+\int_{0}^{\infty}e^{-t}e^{-ix t}\,dt\\
 &=&\left[ \frac{e^{(1-ix)t}}{1-ix} \right]_{-\infty}^0-\left[\frac{e^{-(1+ix)t}}{1+ix} \right]_{0}^{\infty}\\
&=&\frac{1}{1-ix}+\frac{1}{1+ix}\\
&=&\frac{2}{x^2+1}.
\end{split}
Then,
$$
\begin{align}
e^{-|a|}=\mathcal F^{-1}\left( \frac{2}{x^2+1}\right)(a) &=\frac{1}{2\pi}\int_\Bbb R \frac{2}{x^2+1}e^{ix a}\,dx =
\frac{1}{\pi}\int_\Bbb R\frac{e^{ix a}}{x^2+1}\,dx \\&=\frac{1}{\pi}\int_\Bbb R\frac{\cos a x}{x^2+1}\,dx = \frac{2}{\pi}\int_0^\infty\frac{\cos ax}{x^2+1}\,dx
\end{align}
$$
 Given that, as $x\mapsto\sin ax $ is an old function we have,
 $$\int_\Bbb R \frac{\sin{a x}}{x^2+1}dx= 0.$$
Thus we have,
$$
\int_0^\infty\frac{\cos ax}{x^2+1}\,dx =\frac{\pi}{2}e^{-|a|} 
$$
