Contour method to show that $\int_0^\infty\frac{x-\sin x}{x^3} \, dx=\frac\pi4$

METHODOLOGY $1$: Straightforward Approach

We begin by letting $I$ be the integral of interest given by

$$\begin{align} I&=\int_0^\infty \frac{x-\sin(x)}{x^3}\,dx\\\\ &=\frac12 \text{Re}\left(\lim_{\varepsilon\to 0^+,R\to \infty}\left(\int_{-R}^{-\varepsilon} \frac{x+ie^{ix}}{x^3}\,dx+\int_\varepsilon^R \frac{x+ie^{ix}}{x^3}\,dx\right)\right) \end{align}$$


Next, we analyze the contour integral $J_{\varepsilon,R}$

$$\begin{align} J_{\varepsilon,R}&=\oint_{C_{\varepsilon,R}}\frac{z+ie^{iz}}{z^3}\,dz\\\\ &=\int_{-R}^{-\varepsilon} \frac{x+ie^{ix}}{x^3}\,dx+\int_\varepsilon^R \frac{x+ie^{ix}}{x^3}\,dx\\\\ &+\int_\pi^0 \frac{\varepsilon e^{i\phi}+ie^{i\varepsilon e^{i\phi}}}{(\varepsilon e^{i\phi})^3}\,i\varepsilon e^{i\phi}\,d\phi+\int_0^\pi \frac{Re^{i\phi}+ie^{iR e^{i\phi}}}{(R e^{i\phi})^3}\,iR e^{i\phi}\,d\phi \end{align}$$


Expanding $e^{i\varepsilon e^{i\phi}}$ as

$$e^{i\varepsilon e^{i\phi}}=1+i\varepsilon e^{i\phi}-\frac12 \varepsilon^2e^{i2\phi}+O\left(\varepsilon^3\right)$$

reveals that the integration over the semicircle of radius $\epsilon$ is

$$\begin{align} \int_\pi^0 \frac{\varepsilon e^{i\phi}+ie^{i\varepsilon e^{i\phi}}}{(\varepsilon e^{i\phi})^3}\,i\varepsilon e^{i\phi}\,d\phi&=\frac1{\varepsilon^2}\underbrace{\int_0^\pi e^{-i2\phi}\,d\phi}_{=0}-\frac12 \int_0^\pi (1)\,d\phi +O(\varepsilon)\\\\ &=-\frac\pi2 +O(\varepsilon) \end{align}$$


Furthermore, it is easy to show that the integration over the semi-circle of radisu $R$ is

$$\begin{align} \int_0^\pi \frac{Re^{i\phi}+ie^{iR e^{i\phi}}}{(R e^{i\phi})^3}\,iR e^{i\phi}\,d\phi=O\left(\frac1R\right) \end{align}$$


Since $\frac{z+ie^{iz}}{z^3}$ is analytic in and on $C_{\varepsilon,R}$, Cauchy's integral theorem guarantees that $J_{\varepsilon,R}=0$. Putting everything together, we see that

$$\begin{align} 0&=J_{\varepsilon,R}\\\\ &=\int_{-R}^{-\varepsilon} \frac{x+ie^{ix}}{x^3}\,dx+\int_\varepsilon^R \frac{x+ie^{ix}}{x^3}\,dx\\\\ &-\frac\pi2+O\left(\varepsilon\right)+\left(\frac1R\right) \end{align}$$

whereupon taking the limit as $\varepsilon\to 0^+$ and $R\to \infty$ yields

$$I=\frac\pi4$$

And we are done!


METHODOLOGY $2$: Simplifying Using Integration by Parts

We can make our life much easier if we apply successive integration by parts. We now proceed accordingly.

Let $I$ be the integral given by

$$\begin{align} I&=\int_0^\infty \frac{x-\sin(x)}{x^3}\,dx\tag1 \end{align}$$

Integrating by parts the integral on the right-hand side of $(1)$ with $u=x-\sin(x)$ and $v=-\frac{1}{2x^2}$, we find that

$$I=\frac12\int_0^\infty \frac{1-\cos(x)}{x^2}\,dx \tag2$$

Integrating by parts the integral on the right-hand side of $(2)$ with $u=1-\cos(x)$ and $v=-\frac1x$ reveals

$$\begin{align} I&=\frac12 \int_0^\infty \frac{\sin(x)}{x}\,dx\tag3 \end{align}$$

We will evaluate the integral in $(3)$ using contour integration.


We analyze the contour integral $J(\varepsilon,R)$, where $R>0$ and $\varepsilon>0$, as given by

$$\begin{align} J(\varepsilon,R)&=\oint_{C_{\varepsilon,R}}\frac{e^{iz}}{z}\,dz\\\\ &=\int_{-R}^{-\varepsilon} \frac{e^{ix}}{x}\,dx+\int_\pi^0 \frac{e^{i\varepsilon e^{i\phi}}}{\varepsilon e^{i\phi}}\,i\varepsilon e^{i\phi}\,d\phi+\int_{\varepsilon}^R \frac{e^{ix}}{x}\,dx+\int_\pi^0 \frac{e^{iR e^{i\phi}}}{R e^{i\phi}}\,iR e^{i\phi}\,d\phi\tag4 \end{align}$$

Since $\frac{e^{iz}}{z}$ is analytic in and on the contour defined by $C_{\varepsilon,R}$, Cauchy's Integral Theorem guarantees that $J(\varepsilon,R)=0$.

First, note from symmetry that

$$\int_{-R}^{-\varepsilon} \frac{e^{ix}}{x}\,dx+\int_{\varepsilon}^R \frac{e^{ix}}{x}\,dx=i2\int_{\varepsilon}^R \frac{\sin(x)}{x}\,dx$$

Furthermore, we have

$$\lim_{\varepsilon\to 0,R\to \infty}\int_{\varepsilon}^R \frac{\sin(x)}{x}\,dx=\int_0^\infty \frac{\sin(x)}{x}\,dx\tag5$$


Second, it is easy to see that

$$\lim_{\varepsilon\to 0}\int_\pi^0 \frac{e^{i\varepsilon e^{i\phi}}}{\varepsilon e^{i\phi}}\,i\varepsilon e^{i\phi}\,d\phi=-i\pi \tag6$$


Third, noting that $\sin(\phi)\ge \frac{2\phi}{\pi}$ for $\phi\in [0,\pi/2]$, we see that

$$\begin{align} \left|\int_\pi^0 \frac{e^{iR e^{i\phi}}}{R e^{i\phi}}\,iR e^{i\phi}\,d\phi\right|&=\left|\int_0^\pi ie^{iR\sin(\phi)}e^{-R\cos(\phi)}\right|\\\\ &\le\int_0^\pi e^{-R\cos(\phi)}\,d\phi\\\\ &=2\int_0^{\pi/2}e^{-R\sin(\phi)}\,d\phi\\\\ &\le 2\int_0^{\pi/2}e^{-2R\phi/\pi}\,d\phi\\\\ &=\frac{\pi(1-e^{-R})}{R} \end{align}$$

Hence, we see that

$$\lim_{R\to \infty}\int_\pi^0 \frac{e^{iR e^{i\phi}}}{R e^{i\phi}}\,iR e^{i\phi}\,d\phi=0\tag 7$$


Finally, using $(5)-(7)$ in $(4)$ yields

$$\int_0^\infty \frac{\sin(x)}{x}\,dx=\frac{\pi}{2}$$

whence we find that

$$\int_0^\infty \frac{x-\sin(x)}{x^3}\,dx=\frac\pi4$$


Here is a suggestion. Consider the function $f$ defined by $$f(z) = \frac{1+iz-e^{iz}}{z^3}.$$ On the real line, the imaginary part of $f$ will give you the integral you want and with this function the computation with residues will work.


I guess that using the inverse Laplace transform counts as contour integration. In such a case:

$$ \int_{0}^{+\infty}\frac{x-\sin x}{x^3}\,dx = \int_{0}^{+\infty}\mathcal{L}(x-\sin x)(s)\,\mathcal{L}^{-1}\left(\frac{1}{x^3}\right)(s)\,ds$$ by an important property of the Laplace transform. The RHS equals: $$ \int_{0}^{+\infty}\left(\frac{1}{s^2}-\frac{1}{1+s^2}\right)\frac{s^2}{2}\,ds =\frac{1}{2}\int_{0}^{+\infty}\frac{ds}{1+s^2}=\color{blue}{\frac{\pi}{4}}.$$