Calculate integral $ \int_{0}^{+\infty} \frac{x - \sin{\left(x \right)}}{x^{3}}\, dx $ using the Dirichlet integral I try to calculate the integral:
$$ \int_{0}^{+\infty} \frac{x - \sin{\left(x \right)}}{x^{3}}\, dx, $$
using the Dirichlet integral
$$ \int\limits_0^{+\infty} \frac{\sin \alpha x}{x}\,dx = \frac{\pi}{2}\mathrm{sgn}\,\alpha. $$
I integrate this integral in parts, but I can't substitute the limits of integration because the limit is infinity.
 A: Integrating twice by parts gives
$$
\int_0^T {\frac{{x - \sin x}}{{x^3 }}dx} 
 = \frac{1}{2}\frac{{\cos T}}{T} + \frac{1}{2}\frac{{\sin T}}{{T^2 }} - \frac{1}{T} + \frac{1}{2}\int_0^T {\frac{{\sin x}}{x}dx} .
$$
Thus
$$
\int_0^{ + \infty } {\frac{{x - \sin x}}{{x^3 }}dx}  = \frac{1}{2}\int_0^{ + \infty } {\frac{{\sin x}}{x}dx}  = \frac{\pi }{4}.
$$
A: $$\int\frac{x-\sin (x)}{x^3}\,dx=\int\frac{1}{x^2}\,dx-\int\frac{\sin (x)}{x^3}\,dx=$$
$$=-\frac{1}{x}-\int\frac{\sin (x)}{x^3}\,dx$$
by parts
$$\int\frac{\sin (x)}{x^3}\,dx=-\frac{\sin (x)}{2 x^2}-\int -\frac{\cos (x)}{2 x^2} \, dx=$$
again by parts
$$=-\frac{\sin (x)}{2 x^2}-\left(\frac{\cos (x)}{2 x}-\int -\frac{\sin (x)}{2 x} \, dx\right)=$$
$$=-\frac{\sin (x)}{2 x^2}-\frac{\cos (x)}{2 x}-\int \frac{\sin (x)}{2 x} \, dx$$
And finally
$$\int\frac{x-\sin (x)}{x^3}\,dx=-\frac{1}{x}+\frac{\sin (x)}{2 x^2}+\frac{\cos (x)}{2 x}+\int \frac{\sin (x)}{2 x} \, dx$$
the improper integral becomes
$$\int_0^{\infty } \frac{x-\sin (x)}{x^3} \, dx=\left[-\frac{1}{x}+\frac{\sin (x)}{2 x^2}+\frac{\cos (x)}{2 x}\right]_0^{\infty}+\int_0^{\infty } \frac{\sin (x)}{2 x} \, dx=$$
$$=\underset{M\to \infty }{\text{lim}}\left(\frac{\sin (M)}{2 M^2}+\int_0^M \frac{\sin (x)}{2 x} \, dx-\frac{1}{M}+\frac{\cos (M)}{2 M}\right)-\underset{M\to 0}{\text{lim}}\left(\frac{\sin (M)}{2 M^2}+\int_0^M \frac{\sin (x)}{2 x} \, dx-\frac{1}{M}+\frac{\cos (M)}{2 M}\right)$$
first limit gives $\frac{\pi }{4}$.
Second limit is zero because obviously $\int_0^0 \frac{\sin (x)}{2 x} \, dx=0$,
furthermore
$$\underset{M\to 0}{\text{lim}}\frac{-2 M+\sin (M)+M \cos (M)}{2 M^2}=\underset{M\to 0}{\text{lim}}\frac{\frac{\sin (M)}{M}^*+\cos (M)-2}{2 M}=$$
$$=\underset{M\to 0}{\text{lim}}\frac{\cos (M)-1}{2 M}=^{**}\underset{M\to 0}{\text{lim}}-\frac{\sin (M)}{2}=0$$

$^*$ fundamental limit $\frac{\sin (M)}{M}\to 1$ as $M\to 0$
$^{**}$ L'Hopital rule
A: The following lacks justification (I don't know much about swapping integrals). But it sounds like the gist of what you're asking for.
$$\int_{0}^{\beta} \frac{\sin\alpha x}{x}\, d\alpha = \frac{1-\cos \beta x }{x^2}$$
$$\int_{0}^{\gamma} \frac{1-\cos \beta x}{x^2}\, d\beta = \frac{\gamma x - \sin \gamma x}{x^3}$$
So compute
$$\int_{0}^{1}\int_{0}^{\beta}\frac{\pi}{2}\text{sgn}(\alpha)\, d\alpha\, d\beta = \int_{0}^{1}\frac{\pi}{2}\beta\, d\beta = \frac{\pi}{4}$$
