This question already has an answer here:

How to prove that $$\int_0^\infty \frac{x\sin x}{x^2+1}dx=\frac{\pi}{2e}$$

I've tried several basic approaches like substitution and IBP but can't move forward.


marked as duplicate by Guy Fsone, José Carlos Santos, Arnaud D., Dando18, Nosrati Nov 7 '17 at 16:35

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


Suppose we are interested in $$J = \int_0^\infty \frac{x\sin(x)}{1+x^2} dx$$

In view of the ML bound that we will be using later it proves convenient to write this as $$\left[ -\frac{x\cos(x)}{1+x^2} \right]_0^\infty + \int_0^\infty \frac{1-x^2}{(1+x^2)^2} \cos(x) dx = \frac{1}{2} \int_{-\infty}^\infty \frac{1-x^2}{(1+x^2)^2} \cos(x) dx.$$

Observe that this is $$\frac{1}{2} \Re \int_{-\infty}^\infty \frac{1-x^2}{(1+x^2)^2} \exp(ix) dx.$$

Therefore we integrate $$f(z) = \frac{1-z^2}{(1+z^2)^2} \exp(iz)$$

around a semicircular contour of radius $R$ in the upper half plane, which consists of a horizontal segment $\Gamma_1$ on the real axis and a semicircle $\Gamma_2$ in the upper half plane. Now the integral along $\Gamma_1$ is the integral we seek to evaluate in the limit and the integral along $\Gamma_2$ vanishes. This is because we have from the ML bound (parameterize $\Gamma_2$ by $R\exp(i\theta)$ with $0\le\theta\le\pi$)

$$\lim_{R\rightarrow\infty} \pi R \times \frac{(R^2+1) |\exp(iR\exp(i\theta))|}{(R^2-1)^2} \\ = \lim_{R\rightarrow\infty} \pi R \times \frac{(R^2+1) |\exp(iR\cos(\theta)+i^2R\sin(\theta))|}{(R^2-1)^2} \\ = \lim_{R\rightarrow\infty} \pi R \times \frac{(R^2+1) |\exp(-R\sin(\theta))|}{(R^2-1)^2}.$$

Now we have $|\exp(-R\sin(\theta))|\le 1$ because $0\le\theta\le\pi$ so we get two terms, the first of which is $O(1/R)$ and the second $O(1/R^3)$ so they both vanish in the limit and the contribution from the circular segment $\Gamma_2$ is zero.

This yields $$J = \frac{1}{2} \times \Re(2\pi i \; \mathrm{Res}_{z=i} f(z)).$$

We require the second term in the Taylor series of $$\frac{1-z^2}{(z+i)^2} \exp(iz)$$ at $z=i$ which is $$\left.\left(\frac{-2z\exp(iz)+(1-z^2)i\exp(iz)}{(z+i)^2} - 2 \frac{1-z^2}{(z+i)^3} \exp(iz)\right)\right|_{z=i}.$$

The first term here is zero and the second is $$-2\frac{2}{(2i)^3} \exp(-1) = \frac{1}{2} \frac{1}{i} \exp(-1).$$

Substitute this into the formula for $J$ to finally obtain

$$J=\frac{1}{2} \Re(2\pi i \exp(-1)/2/i) = \frac{\pi}{2e}.$$


I am going to post this as a means of posting alternate solutions.

We know that $$\int_0^\infty \frac{\cos ax}{x^2+1}\text{ d}x=\frac{\pi e^{-|a|}}{2}$$

Taking the partial derivative on the variable a

$$\frac{\partial}{\partial a}\int_0^\infty \frac{\cos ax}{x^2+1}\text{ d}x=\frac{d}{da}\frac{\pi}{2e^{|a|}}=\frac{\pi}{2e^{|a|}}$$

And now plug in $a=1$

  • $\begingroup$ These up-votes feel a bit unfair, as this is a general method $\endgroup$ – user311151 Apr 3 '16 at 6:26
  • $\begingroup$ nice but, Do "we" really know that $\int_0^\infty \frac{\cos ax}{x^2\pm1}\text{ d}x=\frac{\pi}{2e^{-|a|}}$ ? $\endgroup$ – Anonymous Apr 3 '16 at 6:46
  • $\begingroup$ So, the negative sign is actually a typo, but the positive sign has been proven in the past. In fact I have made many typos which I will edit now $\endgroup$ – user311151 Apr 3 '16 at 16:57
  • 1
    $\begingroup$ @Anonymous Please check the link here for a solution to that problem math.stackexchange.com/questions/272622/… $\endgroup$ – user311151 Apr 3 '16 at 17:01

Here is a much simple solution. Since it is even function, we evaluate $$ \int_{-\infty }^\infty \frac{x\sin x}{x^2+1}dx $$ We consider the analytic function $$ F(z)=\frac{ze^{iz}}{z^2+1} $$ on the contour of $C=[-R,R]\cup C_R$, where $C_R$ is the upper half circle with radius of $R$. By Cauchy's residue theorem, we have $$ \int_{-R}^RF(x)dx+\int_{C_R}F(z)dz=2\pi iRes(F,i) $$ Note that only pole in the $C_R$ is $z=i$. Since $$ Res(F,i)=\lim_{z\to i}(z-i)F(z)=\lim_{z\to i}\frac{ze^{iz}}{z+i}=\frac{e^{-1}}{2} $$ We have $$ \int_{-R}^RF(x)dx+\int_{C_R}F(z)dz=\frac{\pi i}{e}\tag1 $$ By Jordan lemma $$ \int_{C_R}|e^{iz}||dz|=2R\int_0^{\pi/2}e^{-R\sin t}\:dt<\pi $$ Hence $$ \left|\int_{C_R}F(z)dz\right|\leqslant \frac{R}{R^2-1}\int_{C_R}|e^{iz}||dz|<\frac{\pi R}{R^2-1}\to0 $$ as $R\to\infty$. So from $(1)$ $$ \int_{-\infty}^{\infty}F(x)dx=\frac{\pi i}{e} $$ And $$ \int_{-\infty }^\infty \frac{x\sin x}{x^2+1}dx=\Im{\int_{-\infty}^{\infty}F(x)dx}=\frac{\pi }{e} $$ So $$ \int_{0}^\infty \frac{x\sin x}{x^2+1}dx=\frac{\pi }{2e} $$


Here is a real method. We will use Feynman's trick by differentiating under the integral sign.

Let $$I(a) = \int^\infty_0 \frac{x \sin (ax)}{1 + x^2} \, dx, \quad a > 0.$$ As this improper integral converges conditionally, we will rewrite it so that it converges absolutely. \begin{align*} I(a) &= \int^\infty_0 \frac{x^2 \sin (ax)}{x(1 + x^2)} \, dx = \int^\infty_0 \frac{[(1 + x^2) - 1] \sin (ax)}{x(1 + x^2)} \, dx\\ &= \int^\infty_0 \frac{\sin (ax)}{x} \, dx - \int^\infty_0 \frac{\sin (ax)}{x(1 + x^2)} \, dx. \end{align*} The first of these integrals, on making a substitution of $u = ax$, corresponds to the Dirichlet integral. Its value is well known, namely $$\int^\infty_0 \frac{\sin (ax)}{x} \, dx = \int^\infty_0 \frac{\sin u}{u} \, du = \frac{\pi}{2}.$$ Thus $$I(a) = \frac{\pi}{2} - \int^\infty_0 \frac{\sin (ax)}{x(1 + x^2)} \, dx.$$ Note that as $a \to 0^+$, $I(a) \to \frac{\pi}{2}$.

Now differentiating $I(a)$ with respect to $a$ we have $$I'(a) = -\partial_a \int^\infty_0 \frac{\sin (ax)}{x(1 + x^2)} \, dx = -\int^\infty_0 \frac{\cos (ax)}{1 + x^2} \, dx.$$ Note that as $a \to 0^+$, $$I'(a) \to -\int^\infty_0 \frac{dx}{1 + x^2} = -\frac{\pi}{2}.$$

Differentiating again gives $$I''(a) = -\partial_a \int^\infty_0 \frac{\cos (ax)}{1 + x^2} \, dx = \int^\infty_0 \frac{x \sin (ax)}{1 + x^2} \, dx = I(a),$$ or $I''(a) - I(a) = 0$. On solving this second-order linear differential equation we have $$I(a) = C_1 e^a + C_2 e^{-a},$$ where $C_1$ and $C_2$ are two constants to be found. As $a \to 0^+$, using $I(0^+) = \pi/2$ and $I'(0^+) = -\pi/2$ we find $C_1 = 0$ and $C_2 = \pi/2$. Thus $$I(a) = \int^\infty_0 \frac{x \sin (ax)}{1 + x^2} \, dx = \frac{\pi}{2e^a},$$ while our integral is recovered on setting $a = 1$, namely $$I(1) = \int^\infty_0 \frac{x \sin x}{1 + x^2} \, dx = \frac{\pi}{2e}.$$


Not the answer you're looking for? Browse other questions tagged or ask your own question.