# Calculating the integral $\int_{0}^{\infty} \frac{\cos x}{1+x^2}\mathrm{d}x$ without using complex analysis

Suppose that we do not know anything about the complex analysis (numbers). In this case, how to calculate the following integral in closed form? $$\int_0^\infty\frac{\cos\;x}{1+x^2}\mathrm{d}x$$

This can be done by the useful technique of differentiating under the integral sign.

In fact, this is exercise 10.23 in the second edition of "Mathematical Analysis" by Tom Apostol.

Here is the brief sketch (as laid out in the exercise itself).

Let $$F(y) = \int\limits_{0}^{\infty} \frac{\sin xy}{x(1+x^2)} \ dx \ \ \text{for} \quad\quad y > 0$$

Show that

$\displaystyle F''(y) - F(y) + \pi/2 = 0$ and hence deduce that $\displaystyle F(y) = \frac{\pi(1-e^{-y})}{2}$.

Use this to deduce that for $y > 0$ and $a > 0$

$$\displaystyle \int_{0}^{\infty} \frac{\sin xy}{x(x^2 + a^2)} \ dx = \frac{\pi(1-e^{-ay})}{2a^2}$$

and

$$\int_{0}^{\infty} \frac{\cos xy}{x^2 + a^2} dx = \frac{\pi e^{-ay}}{2a}$$

• How does the $\cos$ integral follow from the $\sin$ integral? – AmadeusDrZaius May 2 '14 at 14:06
• @AmadeusDrZaius: Differentiate $F(y)$ (differentiate with respect to $y$ inside the integral). – Aryabhata May 7 '14 at 0:21

Since $$\frac{x}{1+x^2}=\int_{0}^{\infty}e^{-y}\sin (xy)dy,$$ we have that $$I=\int_{0}^{\infty}\frac{\cos bx}{1+x^2}dx=\int_{0}^{\infty}\frac{\cos bx}{x}dx\int_{0}^{\infty}e^{-y}\sin (xy)dy.$$ Changing the order of integration (which can be justified by the standard method) yields $$I=\int_{0}^{\infty}e^{-y}dy\int_{0}^{\infty}\frac{\sin xy}{x} \cos bx dx.$$ The calculation of the integral (a.k.a. the discontinuous Dirichlet factor) $$\int_{0}^{\infty}\frac{\sin xy}{x} \cos bx dx=\begin{cases}0, & 0 < y < b \\ \ \\ \pi/2, & 0 < b < y, \end{cases}$$ can be easily reduced to the calculation of the standard Dirichlet integral. Therefore, $$I=\frac{\pi}{2}\int_{b}^{\infty}e^{-y}dy=\frac{\pi}{2}e^{-b}.$$

• Very inspiring solution! I learned a lot. Thanks! – Martin Gales Nov 9 '10 at 6:10
• . . . "which can be justified by the standard method" - it can be justified here, but not as routinely as you seem to suggest: the double integral does not quite converge absolutely, so Fubini is not automatic. – Noam D. Elkies Jun 24 '16 at 6:55
• And how does one evaluate the Dirichlet integral without complex analysis? Feynman's Trick is one way forward. But why not simply use Feynman's Trick to begin and save yourself the unnecessary work herein? – Mark Viola Aug 22 '16 at 17:02

These are the methods I use to evaluate $$\int_0^{\infty}\frac{\cos2x}{x^2+4}\,dx$$ and post it on Brilliant.org as a solution of similar problem. You can use the similar technique to evaluate $$\int_0^{\infty}\frac{\cos x}{x^2+1}\,dx.$$

Method 1:

Consider the function $f(t)=e^{-a|t|}$, then the Fourier transform of $f(t)$ is given by \begin{align} F(\omega)=\mathcal{F}[f(t)]&=\int_{-\infty}^{\infty}f(t)e^{-i\omega t}\,dt\\ &=\int_{-\infty}^{\infty}e^{-a|t|}e^{-i\omega t}\,dt\\ &=\int_{-\infty}^{0}e^{at}e^{-i\omega t}\,dt+\int_{0}^{\infty}e^{-at}e^{-i\omega t}\,dt\\ &=\lim_{u\to-\infty}\left. \frac{e^{(a-i\omega)t}}{a-i\omega} \right|_{t=u}^0-\lim_{v\to\infty}\left. \frac{e^{-(a+i\omega)t}}{a+i\omega} \right|_{0}^{t=v}\\ &=\frac{1}{a-i\omega}+\frac{1}{a+i\omega}\\ &=\frac{2a}{\omega^2+a^2}. \end{align} Next, the inverse Fourier transform of $F(\omega)$ is \begin{align} f(t)=\mathcal{F}^{-1}[F(\omega)]&=\frac{1}{2\pi}\int_{-\infty}^{\infty}F(\omega)e^{i\omega t}\,d\omega\\ e^{-a|t|}&=\frac{1}{2\pi}\int_{-\infty}^{\infty}\frac{2a}{\omega^2+a^2}e^{i\omega t}\,d\omega\\ \frac{\pi e^{-a|t|}}{a}&=\int_{-\infty}^{\infty}\frac{e^{i\omega t}}{\omega^2+a^2}\,d\omega.\tag1 \end{align} Now, rewrite $$\int_0^{\infty}\frac{\cos2x}{x^2+4}\,dx=\frac{1}{2}\int_{-\infty}^{\infty}\frac{\mathbb{Re}\left(e^{2ix}\right)}{x^2+2^2}\,dx.\tag2$$ Comparing $(2)$ to $(1)$ yield $t=2$ and $a=2$. Thus, \begin{align} \int_0^{\infty}\frac{\cos2x}{x^2+4}\,dx &=\frac{1}{2}\frac{\pi e^{-2\cdot|2|}}{2}\\ &=\frac{\pi}{4e^4}\\ \end{align} and $$\Large\color{blue}{\int_0^{\infty}\frac{\cos x}{x^2+1}\,dx=\frac{\pi}{2e}}.$$

Method 2:

Note that: $$\int_{y=0}^\infty e^{-(x^2+4)y}\,dy=\frac{1}{x^2+4},$$ therefore $$\int_{x=0}^\infty\int_{y=0}^\infty e^{-(x^2+4)y}\cos2x\,dy\,dx=\int_0^{\infty}\frac{\cos2x}{x^2+4}\,dx$$ Rewrite $\cos2x=\Re\left(e^{-2ix}\right)$, then \begin{align} \int_0^{\infty}\frac{\cos2x}{x^2+4}\,dx&=\int_{x=0}^\infty\int_{y=0}^\infty e^{-(x^2+4)y}\cos2x\,dy\,dx\\ &=\int_{y=0}^\infty\int_{x=0}^\infty e^{-(yx^2+2ix+4y)}\,dx\,dy\\ &=\int_{y=0}^\infty e^{-4y} \int_{x=0}^\infty e^{-(yx^2+2ix)}\,dx\,dy. \end{align} In general \begin{align} \int_{x=0}^\infty e^{-(ax^2+bx)}\,dx&=\int_{x=0}^\infty \exp\left(-a\left(\left(x+\frac{b}{2a}\right)^2-\frac{b^2}{4a^2}\right)\right)\,dx\\ &=\exp\left(\frac{b^2}{4a}\right)\int_{x=0}^\infty \exp\left(-a\left(x+\frac{b}{2a}\right)^2\right)\,dx\\ \end{align} Let $u=x+\frac{b}{2a}\;\rightarrow\;du=dx$, then \begin{align} \int_{x=0}^\infty e^{-(ax^2+bx)}\,dx&=\exp\left(\frac{b^2}{4a}\right)\int_{x=0}^\infty \exp\left(-a\left(x+\frac{b}{2a}\right)^2\right)\,dx\\ &=\exp\left(\frac{b^2}{4a}\right)\int_{u=0}^\infty e^{-au^2}\,du.\\ \end{align} The last form integral is Gaussian integral that equals to $\dfrac{1}{2}\sqrt{\dfrac{\pi}{a}}$. Hence $$\int_{x=0}^\infty e^{-(ax^2+bx)}\,dx=\frac{1}{2}\sqrt{\frac{\pi}{a}}\exp\left(\frac{b^2}{4a}\right).$$ Thus $$\int_{x=0}^\infty e^{-(yx^2+2ix)}\,dx=\frac{1}{2}\sqrt{\frac{\pi}{y}}\exp\left(\frac{(2i)^2}{4y}\right)=\frac{1}{2}\sqrt{\frac{\pi}{y}}\exp\left(-\frac{1}{y}\right).$$ Next $$\int_0^{\infty}\frac{\cos2x}{x^2+4}\,dx=\frac{\sqrt{\pi}}{2}\int_{y=0}^\infty \frac{\exp\left(-4y-\frac{1}{y}\right)}{\sqrt{y}}\,dy.$$ In general \begin{align} \int_{y=0}^\infty \frac{\exp\left(-ay-\frac{b}{y}\right)}{\sqrt{y}}\,dy&=2\int_{v=0}^\infty \exp\left(-av^2-\frac{b}{v^2}\right)\,dv\\ &=2\int_{v=0}^\infty \exp\left(-a\left(v^2+\frac{b}{av^2}\right)\right)\,dv\\ &=2\int_{v=0}^\infty \exp\left(-a\left(v^2-2\sqrt{\frac{b}{a}}+\frac{b}{av^2}+2\sqrt{\frac{b}{a}}\right)\right)\,dv\\ &=2\int_{v=0}^\infty \exp\left(-a\left(v-\frac{1}{v}\sqrt{\frac{b}{a}}\right)^2-2\sqrt{ab}\right)\,dv\\ &=2\exp(-2\sqrt{ab})\int_{v=0}^\infty \exp\left(-a\left(v-\frac{1}{v}\sqrt{\frac{b}{a}}\right)^2\right)\,dv\\ \end{align} The trick to solve the last integral is by setting $$I=\int_{v=0}^\infty \exp\left(-a\left(v-\frac{1}{v}\sqrt{\frac{b}{a}}\right)^2\right)\,dv.$$ Let $t=-\frac{1}{v}\sqrt{\frac{b}{a}}\;\rightarrow\;v=-\frac{1}{t}\sqrt{\frac{b}{a}}\;\rightarrow\;dv=\frac{1}{t^2}\sqrt{\frac{b}{a}}\,dt$, then $$I_t=\sqrt{\frac{b}{a}}\int_{t=0}^\infty \frac{\exp\left(-a\left(-\frac{1}{t}\sqrt{\frac{b}{a}}+t\right)^2\right)}{t^2}\,dt.$$ Let $t=v\;\rightarrow\;dt=dv$, then $$I_t=\int_{t=0}^\infty \exp\left(-a\left(t-\frac{1}{t}\sqrt{\frac{b}{a}}\right)^2\right)\,dt.$$ Adding the two $I_t$s yields $$2I=I_t+I_t=\int_{t=0}^\infty\left(1+\frac{1}{t^2}\sqrt{\frac{b}{a}}\right)\exp\left(-a\left(t-\frac{1}{t}\sqrt{\frac{b}{a}}\right)^2\right)\,dt.$$ Let $s=t-\frac{1}{t}\sqrt{\frac{b}{a}}\;\rightarrow\;ds=\left(1+\frac{1}{t^2}\sqrt{\frac{b}{a}}\right)dt$ and for $0<t<\infty$ is corresponding to $-\infty<s<\infty$, then $$I=\frac{1}{2}\int_{s=-\infty}^\infty e^{-as^2}\,ds=\frac{1}{2}\sqrt{\frac{\pi}{a}}.$$ Thus \begin{align} \int_{y=0}^\infty \frac{\exp\left(-ay-\frac{b}{y}\right)}{\sqrt{y}}\,dy&=2\exp(-2\sqrt{ab})\int_{v=0}^\infty \exp\left(-a\left(v-\frac{1}{v}\sqrt{\frac{b}{a}}\right)^2\right)\,dv\\ &=\sqrt{\frac{\pi}{a}}e^{-2\sqrt{ab}}\\ \end{align} and \begin{align} \int_0^{\infty}\frac{\cos2x}{x^2+4}\,dx&=\frac{\sqrt{\pi}}{2}\int_{y=0}^\infty \frac{\exp\left(-4y-\frac{1}{y}\right)}{\sqrt{y}}\,dy\\ &=\frac{\sqrt{\pi}}{2}\cdot\sqrt{\frac{\pi}{4}}e^{-2\sqrt{4\cdot1}}\\ &=\frac{\pi}{4e^4}. \end{align} Hence $$\Large\color{blue}{\int_0^{\infty}\frac{\cos x}{x^2+1}\,dx=\frac{\pi}{2e}}.$$

$\newcommand{\+}{^{\dagger}} \newcommand{\angles}[1]{\left\langle\, #1 \,\right\rangle} \newcommand{\braces}[1]{\left\lbrace\, #1 \,\right\rbrace} \newcommand{\bracks}[1]{\left\lbrack\, #1 \,\right\rbrack} \newcommand{\ceil}[1]{\,\left\lceil\, #1 \,\right\rceil\,} \newcommand{\dd}{{\rm d}} \newcommand{\down}{\downarrow} \newcommand{\ds}[1]{\displaystyle{#1}} \newcommand{\expo}[1]{\,{\rm e}^{#1}\,} \newcommand{\fermi}{\,{\rm f}} \newcommand{\floor}[1]{\,\left\lfloor #1 \right\rfloor\,} \newcommand{\half}{{1 \over 2}} \newcommand{\ic}{{\rm i}} \newcommand{\iff}{\Longleftrightarrow} \newcommand{\imp}{\Longrightarrow} \newcommand{\isdiv}{\,\left.\right\vert\,} \newcommand{\ket}[1]{\left\vert #1\right\rangle} \newcommand{\ol}[1]{\overline{#1}} \newcommand{\pars}[1]{\left(\, #1 \,\right)} \newcommand{\partiald}[3][]{\frac{\partial^{#1} #2}{\partial #3^{#1}}} \newcommand{\pp}{{\cal P}} \newcommand{\root}[2][]{\,\sqrt[#1]{\vphantom{\large A}\,#2\,}\,} \newcommand{\sech}{\,{\rm sech}} \newcommand{\sgn}{\,{\rm sgn}} \newcommand{\totald}[3][]{\frac{{\rm d}^{#1} #2}{{\rm d} #3^{#1}}} \newcommand{\ul}[1]{\underline{#1}} \newcommand{\verts}[1]{\left\vert\, #1 \,\right\vert} \newcommand{\wt}[1]{\widetilde{#1}}$ $\ds{\int_{0}^{\infty}{\cos\pars{x} \over 1 + x^{2}}\dd x:\ {\large ?}}$

$$\mbox{Lets}\quad\fermi\pars{\mu}\equiv \half\int_{-\infty}^{\infty}{\cos\pars{\mu x} \over 1 + x^{2}}\dd x \quad\mbox{such that}\quad \left\lbrace\begin{array}{rcl} \int_{0}^{\infty}{\cos\pars{x} \over 1 + x^{2}}\dd x & = & \fermi\pars{1} \\[1mm] \fermi\pars{0} & = & {\pi \over 2} \end{array}\right.$$ \begin{align} \fermi''\pars{\mu}& =\half\int_{-\infty}^{\infty}{-x^{2}\cos\pars{\mu x} \over 1 + x^{2}}\dd x =-\pi\,\Re\int_{-\infty}^{\infty}\expo{\ic\mu x}\,{\dd x \over 2\pi} +\fermi\pars{\mu} \\[3mm]&\imp\quad\fermi''\pars{\mu} - \fermi\pars{\mu} = -\pi\,\delta\pars{\mu} \end{align}

The differential equation is equivalent to: $$\left\lbrace \begin{array}{rcl} \fermi''\pars{\mu} - \fermi\pars{\mu} = 0 & \mbox{if} & \mu \not= 0 \\[2mm] \fermi'\pars{0^{+}} - \fermi'\pars{0^{-}} & = & -\pi \end{array}\right.$$

When $\ds{\mu \not= 0}$, the solutions are linear combinations of $\ds{\expo{\pm\mu}}$. Since $\ds{\fermi\pars{0} = {\pi \over 2}}$and the solution is continuos at $\ds{\mu = 0}$ and finite, we'll get: $$\fermi\pars{\mu} = {\pi \over 2}\,\expo{-\verts{\mu}}$$ It satisfies $\ds{\fermi'\pars{0^{+}} - \fermi'\pars{0^{-}} = \pars{-\,{\pi \over 2}} - \pars{{\pi \over 2}} = -\pi}$

$$\color{#44f}{\large \int_{0}^{\infty}{\cos\pars{x} \over 1 + x^{2}}\dd x} =\fermi\pars{1} = {\pi \over 2}\,\expo{-\verts{1}}= \color{#44f}{\large{\pi \over 2\expo{}}}$$

The previous answer is not correct. If you use the Taylor expansion of cosine and integrate termwise you consider integrals of the following form: \begin{eqnarray} \int_{0}^{\infty} \frac{x^{a} \ dx}{1 + x^{2}} = \tfrac{\pi}{2} \sec (\tfrac{\pi a}{2}) \end{eqnarray} which is only well-defined if $-1 < a < 1$.

Another way forward is to use Feynman's Trick. To that end, let $I(a)$ be the integral

$$I(a,b)=\int_0^\infty e^{-ax}\frac{\cos(bx)}{1+x^2}\,dx \tag 1$$

for $a\ge 0$. Then, for $a>0$ we have

\begin{align} \frac{\partial^2 I(a,b)}{\partial b^2}&=-\int_0^\infty e^{-ax}\frac{x^2\cos(bx)}{1+x^2}\,dx\\\\ &=I(a,b)-\frac{a}{a^2+b^2} \end{align}

Therefore, using $\lim_{b\to \infty}I(a,b)=0$ (apply the Riemann-Lebesgue Lemma), we find that for $a>0$

$$I(a,b)=C(a)e^{-|b|}+\frac12\int_0^\infty e^{-|b-x|}\frac{a}{a^2+x^2}\,dx \tag 2$$

for some function $C(a)$.

When $b=0$ and $a\to 0^+$, $I(a,b)$ as given by $(2)$ is $I(0^+,0)=C(0^+)+\frac{\pi }{4}$, where $I(0^+,0)$ as given by $(1)$ is $I(0^+,0)=\frac{\pi}{2}$. Therefore, we find that $C(0^+)=\frac{\pi}{4}$.

Finally, when $b=1$ we have from $(1)$,

$$\lim_{a\to 0^+}I(a,1)=I(0,1) \tag 3$$

whereas we have from $(2)$, we have

$$\lim_{a\to 0^+}I(a,1)=\frac{\pi}{2e}\tag 4$$

Comparing $(3)$ and $(4)$ yields

$$I(0,1)=\frac{\pi}{2e}$$

as expected!

The method of brackets, which is an extension of Ramanujan's master theorem, can be used to evaluate this classic integral.

The term bracket refers to the assignment of the symbol $\langle a \rangle$ to the divergent integral $\int_{0}^{\infty} x^{a -1} \, \mathrm{d}x$.

Evaluation of entries in Gradshteyn and Ryzhik employing the method of brackets

The hypergeometric representation of the cosine function is $$\, _0F_{1} \left(; \frac{1}{2}; - \frac{x^{2}}{4} \right) = \sum_{n=0}^{\infty} \frac{(-1)^{n}}{n!} \, \frac{\Gamma \left( \frac{1}{2} \right)}{\Gamma \left(n+\frac{1}{2} \right)} \left(\frac{x^{2}}{4} \right)^{n} = \sum_{n=0}^{\infty} \phi_{n} \, \frac{\Gamma \left( \frac{1}{2} \right)}{\Gamma \left(n+\frac{1}{2} \right)} \left(\frac{x^{2}}{4} \right)^{n}.$$

(This representation can be derived from the Maclaurin series of $\cos (x)$ by using the duplication formula for the gamma function).

And according to Rule 3.1 on page 8 of the first paper, the function $\frac{1}{1+x^{2}}$ is assigned the bracket series $$\sum_{k=0}^{\infty} \sum_{m=0}^{\infty} \phi_{k,m} \, x^{2m} \langle k+m+1 \rangle.$$

(We can't simply expand $\frac{1}{1+x^{2}}$ in a Maclaurin series since the Maclaurin series of $\frac{1}{1+x^{2}}$ is only valid for $|x| <1$.)

Thus according to Definition 3.1 in the first paper, the integral $\int_{0}^{\infty} \frac{\cos x}{1+x^{2}} \, \mathrm{d}x$ is assigned the bracket series $$\sum_{k=0}^{\infty} \sum_{m=0}^{\infty} \sum_{n=0}^{\infty} \phi_{k,m,n} \, \frac{\Gamma \left(\frac{1}{2} \right)}{\Gamma \left(n+\frac{1}{2}\right)} \frac{1}{4^{n}} \langle k+m+1\rangle \langle 2m+2n+1 \rangle. \tag{1}$$

To evaluate $(1)$, first let $k$ be a free parameter.

The brackets then vanish if $m=-k-1$ and $n= k + \frac{1}{2}$.

So according to Rule 3.3 in the first paper, the contribution to the integral is

\begin{align}\frac{1}{2} \sum_{k=0}^{\infty} \frac{(-1)^{k}}{k!} \frac{\Gamma \left(\frac{1}{2} \right)}{\Gamma (k+1 )} \, \frac{\Gamma (k+1) \Gamma \left(-k-\frac{1}{2} \right)}{4^{k+ 1/2}} &= \frac{\sqrt{\pi}}{4} \sum_{k=0}^{\infty} \frac{(-1)^{k}}{k!} \frac{1}{4^{k}} \frac{\pi (-1)^{k-1} }{\Gamma \left(k + \frac{3}{2} \right)} \\ &= - \frac{\pi \sqrt{\pi} }{4} \sum_{k=0}^{\infty} \frac{1}{k!} \frac{1}{4^{k}} \frac{2^{2(k+1)-1} \Gamma(k+1)}{ \sqrt{\pi} \, \Gamma(2k+2)} \\ &= -\frac{\pi}{2} \sum_{k=0}^{\infty} \frac{1}{(2k+1)!} \\ &= -\frac{\pi}{2} \, \sinh (1). \end{align}

(I used the reflection formula for the gamma function on the first line, and then I used the duplication formula for the gamma function on the second line.)

Now let $m$ be a free parameter.

The brackets then vanish if $k = -m-1$ and $n=-m -\frac{1}{2}$.

So according to Rule 3.3, the contribution to the integral is $$\frac{1}{2} \sum_{m=0}^{\infty} \frac{(-1)^{m}}{m!} \frac{\Gamma \left(\frac{1}{2} \right)}{{\color{red}{\Gamma (-m)}}} \frac{\Gamma(m+1) \Gamma \left(m+ \frac{1}{2} \right)}{4^{-m-1/2}} =0.$$

Finally let $n$ be a free parameter.

The brackets then vanish if $k = - n - \frac{1}{2}$and $m= n - \frac{1}{2}$.

So according to Rule 3.3, the contribution to the integral is

\begin{align}\frac{1}{2} \sum_{n=0}^{\infty} \frac{(-1)^{n}}{n!} \frac{\Gamma \left(\frac{1}{2} \right)}{\Gamma (n + \frac{1}{2} )} \, \frac{\Gamma \left(n + \frac{1}{2} \right) \Gamma \left(\frac{1}{2}-n \right) }{4^{n}} &= \frac{\sqrt{\pi}}{2} \sum_{n=0}^{\infty} \frac{(-1)^{n}}{n!} \frac{1}{4^{n}} \frac{\pi (-1)^{n}}{\Gamma \left(n+ \frac{1}{2} \right)} \\ &= \frac{\pi \sqrt{\pi}}{2} \sum_{n=0}^{\infty} \frac{1}{n!} \frac{1}{4^{n}} \frac{2^{2(n+1/2)-1} \Gamma(n+1)}{\sqrt{\pi} \, \Gamma(2n+1)} \\ &= \frac{\pi}{2} \sum_{n=0}^{\infty} \frac{1}{(2n)!} \\ &= \frac{\pi}{2} \, \cosh (1). \end{align}

Rule 3.4 in the first paper says that we should add these three contributions.

Therefore, $$\int_{0}^{\infty} \frac{\cos(x)}{1+x^{2}} \, \mathrm{d}x = - \frac{\pi}{2} \sinh(1) + 0 + \frac{\pi}{2} \cosh(1) = \frac{\pi}{2e}.$$

• A nicely written solution. +1 – Mark Viola Aug 22 '16 at 16:55

Let $\lambda\in\mathbb{R}$, set $$I(\lambda)=\int_{-\infty}^{\infty}{\cos(\lambda x)\over x^2+1}dx$$ we use integrate by parts, writing
$$u=\frac{1}{{{x}^{2}}+1}\quad,\quad dv=\cos (\lambda x)$$ we have $$I(\lambda )=\frac{\sin (\lambda x)}{\lambda ({{x}^{2}}+1)}\left| \begin{matrix} \infty \\ -\infty \\ \end{matrix} \right.+\frac{2}{\lambda }\int_{-\infty }^{+\infty }{\frac{\sin (\lambda x)}{{{({{x}^{2}}+1)}^{2}}}}\,dx$$ as a result $$\lambda I(\lambda )=2\int_{-\infty }^{\infty }{\frac{x\sin \lambda x}{{{({{x}^{2}}+1)}^{2}}}\,}dx \,.\quad(1)$$ By differentiate with respect $\lambda$ to get $$\lambda \frac{dI}{d\lambda }+I(\lambda )=2\int_{-\infty }^{\infty }{\frac{{{x}^{2}}\cos \lambda x}{{{({{x}^{2}}+1)}^{2}}}\,}dx=\underbrace{2\int_{-\infty }^{\infty }{\frac{\cos \lambda x}{{{x}^{2}}+1}\,}dx}_{2I(\lambda )}-2\int_{-\infty }^{\infty }{\frac{\cos \lambda x}{{{({{x}^{2}}+1)}^{2}}}\,}dx$$ therefore $$\lambda \frac{dI}{d\lambda }-I(\lambda )=-2\int_{-\infty }^{\infty }{\frac{\cos \lambda x}{{{({{x}^{2}}+1)}^{2}}}\,}dx$$
and $$\lambda \frac{{{d}^{2}}I}{d{{\lambda }^{2}}}=2\int_{-\infty }^{\infty }{\frac{x\sin \lambda x}{{{({{x}^{2}}+1)}^{2}}}\,}dx.\quad(2)$$ $(1)$ and $(2)$ $$\frac{{{d}^{2}}I(\lambda)}{d{{\lambda }^{2}}}- I(\lambda )=0$$ thus $$I(\lambda)=c_1e^{\lambda}+c_2e^{-\lambda}$$ on the other hand \begin{align} & I(0)={{c}_{1}}+{{c}_{2}}=\int_{-\infty }^{+\infty }{\frac{1}{{{x}^{2}}+1}}\,dx=\pi \,\,\,\,\Rightarrow \,\,{{c}_{1}}+{{c}_{2}}=\pi \, \\ & I(\lambda )=\frac{2}{\lambda }\int_{-\infty }^{+\infty }{\frac{x\sin \lambda x}{{{({{x}^{2}}+1)}^{2}}}\,\,}dx\,\,\,\Rightarrow \,\,\underset{\lambda \to \infty }{\mathop{\lim }}\,I(\lambda )=0\,\,\,\Rightarrow \,{{c}_{1}}=0 \\ \end{align} then $$I(\lambda )=\pi {{e}^{-\lambda }}$$ set $\lambda=1$, we have $$I(1)=\int_{-\infty}^{\infty}{\cos( x)\over x^2+1}dx=\frac{\pi}{e}$$ so $$\int_{0}^{\infty}{\cos( x)\over x^2+1}dx=\frac{\pi}{2e}$$

• Nice solution. +1 – Mark Viola Aug 22 '16 at 16:57
• So thanks Mark ;) – Behrouz Maleki Aug 23 '16 at 7:47
• Very nice! I've been trying to do that for a couple of hours, but it didn't occur to me to use 2nd order equations instead of 1st order. – Yuriy S Apr 13 '18 at 12:01

Glaisher's theorem, which is a special case of Ramanujan's master theorem, can also be used to compute this integral. If a function has a series expansion of the form:

$$f(x) = \sum_{k=0}^{\infty}(-1)^k c_{k}x^{2k}$$

then:

$$\int_0^{\infty}f(x) dx = \frac{\pi}{2}c_{-\frac{1}{2}}$$

Here $c_{-\frac{1}{2}}$ is obtained by analytically continuing $c_k$, e.g. by writing $c_k$ in terms of gamma functions (the rigorous way to do this is to apply the rigorous version of Ramanujan's master theorem). The above expression is only valid if the integral converges. For $f(x)=\frac{\cos(x)}{1+x^2}$, we have:

$$c_k = \sum_{j=0}^{k}\frac{1}{(2j)!}$$

We can obtain the analytic continuation of $c_k$ by considering the limiting value at infinity:

$$\lim_{k\to\infty}c_{k} = \cosh(1)$$

and by imposing the recursion relation

$$c_{k+1} = c_{k} + \frac{1}{(2k+2)!}$$

for general $k$. This means that for general $k$ we have:

$$c_k + \sum_{j=k+1}^{\infty}\frac{1}{(2j)!} = \cosh(1)$$

To compute $c_{-\frac{1}{2}}$, we thus need to evaluate the summation:

$$\sum_{j=\frac{1}{2}}^{\infty}\frac{1}{(2j)!} = \sum_{j=0}^{\infty}\frac{1}{(2(j+\frac{1}{2}))!} = \sum_{j=0}^{\infty}\frac{1}{(2j+1)!} = \sinh(1)$$

Therefore:

$$c_{-\frac{1}{2}} = \exp(-1)$$

and the integral is given by $\frac{\pi}{2} \exp(-1)$.

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|}$$

Considering

$$\int_{0}^{\infty}e^{-t}\sin (xt)dt=\frac{1}{1+x^2},$$

And $$\int_{0}^{\infty}\frac{\cos{mx}}{1+x^2}dx=\int_{0}^{\infty}dx\int_{0}^{\infty}dt\text{ }\big(e^{-t}\cos{(mx)}\cos{(xt)}\big),$$

$$=\int_{0}^{\infty}dx\int_{0}^{\infty}dt\text{ }\big(e^{-t}\frac{\cos{(m+t)x}+\cos(m-t)x}{2} \big)$$

where $$\int_{0}^{\infty}\cos{Qa da=\pi\delta(Q)}$$, and $$\delta$$ is Dirac-Delta function.

$$=\int_{0}^{\infty}dt\text{ }\frac{e^{-t}}{2}\big((\pi\delta(m+t)+\pi\delta(m-t) \big)$$

hence: $$\int_{0}^{\infty}\frac{\cos{mx}}{1+x^2}dx=\frac{\pi}{2}e^{-|m|},$$

plug in $$m=1$$:

$$\int_{0}^{\infty}\frac{\cos{x}}{1+x^2}dx=\frac{\pi}{2}e^{-1}$$

Reference: Feynman's Lectures on Mathematical Methods (lecture notes) Lec 3,4 and 5.