Why is $\int_0^\infty \frac{2 \cos(x) + x^2 - 2}{x^4}dx = \frac{\pi}{6}$? Wolfram alpha computes that $\int_0^\infty \frac{2 \cos(x) + x^2 - 2}{x^4}dx = \frac{\pi}{6}$.
Why is this true? I thought this looked like something which could be justified with contour integrals, but I wasn't able to find a contour (or at least an easy contour) which gives the result.
What's a technique that can be used to compute this integral?
 A: You can also use a well known property of the Laplace transform $$\int_{0}^{+\infty}f\left(x\right)g\left(x\right)dx=\int_{0}^{+\infty}\left(\mathcal{L}f\right)\left(y\right)\left(\mathcal{L}^{-1}g\right)\left(y\right)dy$$ where $\left(\mathcal{L}f\right),\,\left(\mathcal{L}^{-1}g\right)$ is the Laplace and the inverse Laplace transform, respectively. Hence $$\int_{0}^{+\infty}\frac{2\cos\left(x\right)-x^{2}+2}{x^{4}}dx=\frac{1}{3}\int_{0}^{+\infty}\frac{y^{3}}{y^{5}+y^{3}}dy=\frac{1}{3}\int_{0}^{+\infty}\frac{1}{y^{2}+1}dy=\color{red}{\frac{\pi}{6}}.$$
A: While there is surely a contour integral, one can compute the indefinite integral as
$$\int\frac{2\cos(x) + x^2 - 2}{x^4}dx = \frac{\text{Si}(x)}{3}+\frac{2}{3 x^3}+\frac{\sin (x)}{3 x^2}+\frac{\left(x^2-2\right)
   \cos (x)}{3 x^3}-\frac{1}{x},$$
wherefrom the result follows.
A: Using $2\cos x=e^{ix}+e^{-ix}$ the integral can be represented as:
$$\begin{align}
\int_{-\infty}^\infty f(x)dx,\quad\text{with}\quad f(x)=\frac{e^{ix}-1+\frac{x^2}2}{x^4}.
\end{align}$$
The integrated function $f(x)$ has a singularity (pole of third order) at $x=0$ and we are looking for the principal value of the integral. Completing the integration path in the upper complex half-plane with a semicircle of large radius $R$  and letting the radius tend to infinity we obtain:
$$
\int_{-\infty}^\infty f(x)dx=\oint_C f(z)dz=\frac12\times 2\pi i\operatorname{res}_{z=0}f(z)=\pi i\frac{-i}6=\frac\pi6.
$$
A: Let's consider the function $f(x)=\frac{2 \exp(ix) + x^2 - 2}{x^4}dx$
$I=\int_0^\infty \frac{2 \cos(x) + x^2 - 2}{x^4}dx=\frac{1}{2}\Re\int_{-\infty}^\infty{f}(x)dx$
Lets consider the following contour, which includes integral along a big half-circle of radius $R\to\infty$ counter clockwise and a small half-circle of radius $r\to 0$ around $x=0$ clockkwise.

Integral around this contour $\oint{f}(x)dx=0$, because there are not poles inside the contour. On the other hand $\oint{f}(x)dx=2I+\int_R+\int_r\Rightarrow 2I=-\int_R-\int_r$
Integral along a big half-circle $\to0$ at $R\to\infty$ due to Jordan lemma.
$2I=-\Re\int_r\frac{2 \exp(ix) + x^2 - 2}{x^4}dx\Rightarrow$ $${I}=\frac{1}{2}\Re\lim_{r\to0}\int_0^{\pi}\frac{2 \exp(ire^{it}) + r^2e^{2it} - 2}{r^4e^{4it}}ire^{it}dt$$
Expanding exponent into a series $\exp(ire^{it})=1+ire^{it}-\frac{1}{2}r^2e^{2it}-\frac{i}{3!}r^3e^{3it}$ and noting that $\int_0^{\pi}\frac{r^2e^{2it}}{r^4e^{4it}}dt=0$ we get:
$${I}=\frac{1}{2}\Re\lim_{r\to0}\int_0^{\pi}\frac{ 2\,r^4e^{4it}+O(r^5)}{3!\,r^4e^{4it}}dt=\frac{\pi}{3!}$$
