Evaluating an improper integral $\int_{0}^{\infty}\frac{x^2}{(x^4+1)^2}dx$ I tried to solve the integral: $$\int_{0}^{\infty}\frac{x^2}{(x^4+1)^2}dx$$
using $ x = \sqrt{\tan(u)}$ and $dx = \frac{ \sec^2(u)}{2\sqrt{\tan(u)}} du,$
but I ended up with an even worse looking integral $$ \int_{0}^{\frac{\pi}{2}}\frac{\sqrt{\tan(u)}}{\sec^2(u)}du.$$
Wolfram gave an answer of $ \dfrac{\pi}{8\sqrt{2}},$ but how would one get to that answer?

We could do it with contour integration.
take the contour from 0 to R along the real axis.
$\int_0^R \frac {x^2}{(x^4+1)^2} \ dx$
The quater circle.
$\int_0^{\frac \pi 2} \frac {R^2e^2it}{(R^4e^{4it}+1)^2}(iRe^{it}) \ dt$
$\lim_\limits{R\to \infty} \frac {R^2e^2it}{(R^4e^{4it}+1)^2}(iRe^{it}) = 0$
And down the imaginary axis.
$\int_R^0 \frac {(e^{\frac {\pi}{2} i} x)^2}{((e^{\frac {\pi}{2} i} x)^4+1)^2} (e^{\frac {\pi}{2} i})\ dx\\
\int_R^0 \frac {-x^2}{x^4+1)^2} (i)\ dx\\
$
$(1+i)\int_0^\infty \frac {x^2}{(x^4+1)^2} \ dx = (2\pi i) \text{ Res}_{\left(x=e^{\frac\pi4i}\right)}\frac {x^2}{(x^4+1)^2}$
The pole is of order 2.
$\frac {d}{dx}\frac {x^2}{(x^3 + x^2e^{\frac \pi4 i} + xe^{\frac {2\pi}{4} i}+e^{\frac {3\pi}{4} i})^2} = \frac {2x(x^3 + x^2e^{\frac \pi4 i} + xe^{\frac {2\pi}{4} i}+e^{\frac {3\pi}{4} i}) - 2x^2(3x^2 + 2xe^{\frac \pi4 i} + e^{\frac {2\pi}{4} i})}{(x^3 + x^2e^{\frac \pi4 i} + xe^{\frac {2\pi}{4} i}+e^{\frac {3\pi}{4} i})^3}$
Evaluated at $e^{\frac {\pi}{4} i}$
$\frac {4}{(4e^{\frac {3\pi}4 i})^3} = \frac {1}{16e^{\frac {\pi}4 i}}$
$\int_0^\infty \frac {x^2}{(x^4+1)^2} \ dx = \frac {2\pi i}{16\sqrt 2 i} = \frac {\pi}{8\sqrt 2}$
