<s>[INST] prove that $\int_0^\infty \frac{\sin^2 x-x\sin x}{x^3} \, dx= \frac{1}{2} - \ln 2$ 
Prove that
$$ \int_{0}^{\infty} \frac{\sin^2 x-x\sin x}{x^3} \, dx = \frac{1}{2} - \ln 2 .$$

Integration by parts gives
\begin{align*}
&\lim_{R\to \infty} \int_{0}^{R} \frac{\sin^2 x-x\sin x}{x^3} \, dx \\
&= \lim_{R\to \infty} \biggl( \int_{0}^{R} \frac{\sin^2x}{x^3} \, dx - \int_{0}^{R} \frac{\sin x}{x^2} \, dx \biggr)\\
&= \lim_{R\to\infty} \biggl( \frac{\sin^2 x}{-2x^2}\Biggr\rvert_{0}^{R} - \int_{0}^{R} \frac{\sin (2x)}{-2x^2} \, dx - \biggl(-\frac{\sin x}{x} \Biggr\rvert_{0}^{R} + \int_{0}^{R} \frac{\cos x}{x} \,dx \biggr) \biggr) \\
&= \lim_{R\to \infty} \biggl(\frac{1}{2} + \int_{0}^{2R} \frac{\sin u}{u^2/2} \, \Bigl(\frac{1}2 \, du\Bigr) - \biggl( 1 + \int_{0}^{R} \frac{\cos x}{x} \, dx \biggr)\biggr) \\
&\hspace{22em}\text{(using the substitution $u\mapsto 2x$)}\\
&= -\frac{1}{2} + \lim_{R\to \infty} \biggl(\int_{0}^{2R} \frac{\sin u}{u^2} \, du - \int_{0}^{R} \frac{\cos x}{x} \,dx \biggr)\\
&= \frac{1}{2} + \lim_{R\to\infty} \biggl(\int_{R}^{2R} \frac{\cos x}{x} \, dx \biggr)
\end{align*}
Thus it suffices to show that $\lim_{R\to\infty} \int_{R}^{2R} \frac{\cos x}{x} \, dx = \ln 2$. The Taylor series expansion of $\cos x$ is given by $\cos x = \sum_{i=0}^{\infty} \frac{(-1)^i x^{2i}}{(2i)!}$.

(If the step below (the one involving the interchanging of an infinite sum and integral) is valid, why exactly is it valid? For instance, does it use uniform convergence?)

The limit equals
$$
\lim_{R\to\infty} \int_{R}^{2R} \biggl( \frac{1}{x} + \sum_{i=1}^{\infty} \frac{(-1)^i x^{2i-1}}{(2i)!} \biggr) \, dx
= \ln 2 + \lim_{R\to\infty} \sum_{i=1}^{\infty} \biggl[\frac{(-1)^ix^{2i}}{(2i)(2i)!}\biggr]_{R}^{2R} . $$
But I don't know how to show $\lim_{R\to\infty} \lim_{R\to\infty} \sum_{i=1}^{\infty} \Bigl[\frac{(-1)^ix^{2i}}{(2i)(2i)!}\Bigr]_{R}^{2R} = -2 \ln 2$.
 [/INST] $$I=\int \frac{\sin^2 (x)-x\sin (x)}{x^3}\, dx=\int \frac{\sin^2 (x)}{x^3}\, dx-\int \frac{\sin (x)}{x^2}\, dx$$
$$\int \frac{\sin^2 (x)}{x^3}\, dx=\frac 1 2\int \frac{1-\cos(2x)}{x^3}\,dx$$
$$\int \frac{1-\cos(2x)}{x^3}\,dx=-\frac 1{2x^2}-\int \frac{\cos(2x)}{x^3}\,dx$$
$$\int \frac{\cos(2x)}{x^3}\,dx=-\frac{\cos(2x)}{x^2}-\int\frac{\sin(2x)}{x^2}\,dx$$
$$\int\frac{\sin(2x)}{x^2}\,dx=-\frac{\sin(2x)}{x}+2\int \frac{\cos(2x)}x\,dx$$
$$\int \frac{\cos(2x)}x\,dx=\int \frac{\cos(y)}y\,dy=\text{Ci}(y)=\text{Ci}(2x)$$
Combining all the above
$$\color{red}{\int \frac{\sin^2 (x)}{x^3}\, dx=\text{Ci}(2 x)-\frac{\sin (x) (\sin (x)+2 x \cos (x))}{2 x^2}}$$
$$\int \frac{\sin (x)}{x^2}\, dx=-\frac{\sin (x)}{x}+\int \frac{\cos(x)}x\,dx$$
$$\color{red}{\int \frac{\sin (x)}{x^2}\, dx=-\frac{\sin (x)}{x}+\text{Ci}(x)}$$
So,
$$\color{blue}{I=-\text{Ci}(x)+\text{Ci}(2 x)-\frac{1}{4 x^2}+\frac{\cos (2 x)}{4 x^2}+\frac{\sin(x)}{x}-\frac{\sin (2 x)}{2 x}}$$ If $x\to \infty$ its value is $0$.
Now, for $x\to 0$, using expansion we have
$$\left(\log (2)-\frac{1}{2}\right)-\frac{x^2}{12}+\frac{13
   x^4}{1440}+O\left(x^6\right)$$
$$J=\int_\epsilon^\infty \frac{\sin^2 (x)-x\sin (x)}{x^3}\, dx=\left(\frac{1}{2}-\log (2)\right)+\frac{\epsilon^2}{12}+O\left(\epsilon^4\right)$$
</s>