# How to evaluate $\int_0^\infty\frac{ \sin{x}}{x^2+1}dx$?

For some reason I couldn’t find an answer to this online even though it seems very basic. I am trying to evaluate the following improper integral.

$$\int_0^{\infty} \frac{ \sin{x}}{x^2+1}dx$$.

I consider the following function on nonnegative reals. $$I(a) = \int_0^{\infty} \frac{ \sin{ax}}{x^2+1}dx$$.

Differentiating under the integral sign I get $$I'(a) = a\int_0^{\infty} \frac{ \cos{ax}}{x^2+1}dx$$.

The rhs I evaluate with a contour integral to get $$I'(a) = \frac{\pi}{2}ae^{-a}$$.

With the boundary condition $$I(0)=0$$, I get $$I(a) = \frac{\pi}{2}(1-e^{-a} -ae^{-a} )$$. $$a=1$$ corresponds to the integral I want to evaluate, which is equal to

$$\frac{\pi}{2} - \frac{\pi}{e}$$

This doesn’t quite match the answer I am getting on [Wolfram Alpha]. Can someone please help me find out where I am going wrong? Thanks.

• if you differentiate you get $\int_{0}^{\infty}\frac{x\cos(ax)}{x^2+1} dx$? Feb 5, 2022 at 17:05
• @psl2Z Silly me!! Thanks a lot! Feb 5, 2022 at 17:06
• Feb 5, 2022 at 17:32
• Table of integrals series and products by I.S. Gradshteyn and I.M. Ryzhik (2007) 3.723. Ei function is used. Feb 5, 2022 at 17:55
• math.stackexchange.com/questions/2611074/… Jan 17 at 18:49

This question is answered in some of the questions listed in comments. However, I've given a slightly different approach to a slightly generalized question. This question is the case $$a=1$$ covered by this answer. \begin{align}\newcommand{\Ei}{\operatorname{Ei}}\newcommand{\PV}{\operatorname{PV}} \int_0^\infty\frac{a\sin(x)}{a^2+x^2}\,\mathrm{d}x &=\frac1{2i}\int_0^\infty\frac{ae^{ix}-ae^{-ix}}{a^2+x^2}\,\mathrm{d}x\tag{1a}\\ &=\frac12\int_0^{-i\infty}\frac{ae^{-x}}{a^2-x^2}\,\mathrm{d}x+\frac{a}2\int_0^{i\infty}\frac{ae^{-x}}{a^2-x^2}\,\mathrm{d}x\tag{1b}\\ &=\PV\int_0^\infty\frac{ae^{-x}}{a^2-x^2}\,\mathrm{d}x\tag{1c}\\ &=\frac12\PV\int_0^\infty\frac{e^{-x}}{a+x}\mathrm{d}x+\frac12\PV\int_0^\infty\frac{e^{-x}}{a-x}\mathrm{d}x\tag{1d}\\ &=\frac{e^a}2\PV\int_a^\infty\frac{e^{-x}}{x}\mathrm{d}x-\frac{e^{-a}}2\PV\int_{-a}^\infty\frac{e^{-x}}{x}\mathrm{d}x\tag{1e}\\ &=-\frac{e^a}2\Ei(-a)+\frac{e^{-a}}2\Ei(a)\tag{1f} \end{align} $$\text{(1a):}$$ $$\sin(x)=\frac{e^{ix}-e^{-ix}}{2i}$$
$$\text{(1b):}$$ substitute $$x\mapsto ix$$ on the left and $$x\mapsto-ix$$ on the right
$$\text{(1c):}$$ bring $$[0,i\infty]$$ to the top of the positive real axis, and $$[0,-i\infty]$$ to the bottom
$$\phantom{\text{(1c):}}$$ being in opposite orientations, the bumps around $$z=a$$ cancel, leaving the
$$\phantom{\text{(1c):}}$$ principal value
$$\text{(1d):}$$ partial fractions
$$\text{(1e):}$$ substitute $$x\mapsto x-a$$ on the left and $$x\mapsto x+a$$ on the right
$$\text{(1f):}$$ apply the special function $$\Ei(z)=-\PV\int_{-z}^\infty\frac{e^{-t}}{t}\,\mathrm{d}t$$

Explanation of $$\pmb{(1c)}$$ Moving from $$\text{(1b)}$$ to $$\text{(1c)}$$ crosses no singularities and the integrals along the dashed curves vanish as the radius increases. The solid green arc contributes $$-\pi i$$ times the residue at $$a$$, while the solid red arc contributes $$\pi i$$ times the residue at $$a$$. That is, they cancel each other, leaving twice the Principal Value.

$$\def\Ci{\operatorname{Ci}}\def\Si{\operatorname{Si}} \def\Chi{\operatorname{Chi}}\def\Shi{\operatorname{Shi}}$$

Alternatively, we use $$\Ci(z),\Si(z),\Chi(z),\Shi(z)$$ functions:

$$\int_0^\infty \frac{\sin(x)}{x^2+1}dx=\frac i2\int_0^\infty\frac{\sin(x)}{x+i}dx-\frac i2\int_0^\infty \frac{\sin(x)}{x-i}dx= \frac i2\int_i^{i+\infty}\frac{\sin(x-i)}xdx-\frac i2\int_{-i}^{\infty-i} \frac{\sin(x+i)}xdx$$

Then expand $$\sin(x\pm i)$$:

$$\frac12\int_i^{i+\infty} \frac{\sinh(1)\cos(x)}{x}+\frac{i\cosh(1)\sin(x)}xdx+\frac12\int_{-i}^{\infty-i}\frac{\sinh(1)\cos(x)}x-\frac{i\cosh(1)\sin(x)}xdx$$

Plugging in gives:

$$\frac12(\sinh(1)\Ci(x)+i\cosh(1)\Si(x))|_i^{\infty+i}+\frac12(\sinh(1)\Ci(x)-i\cosh(1)\Si(x))|_{-i}^{\infty-i}=\frac12(\Shi(1)\cosh(1)-\Ci(-i)\sinh(1))+\frac12(\Shi(1)\cosh(1)-\Ci(i)\sinh(1))=\boxed{\Shi(1)\cosh(1)-\Chi(1)\sinh(1)= 0.64676112277913\dots}$$