<s>[INST] 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?
 [/INST] Write $$\frac{x^2}{(1+x^4)^2} = \frac{4x^3}{(1+x^4)^2} \cdot \frac{1}{4x}.$$  Then integration by parts with the choice $$u = \frac{1}{4x}, \quad du = -\frac{1}{4x^2} \, dx, \\ dv = \frac{4x^3}{(1+x^4)^2} \, dx, \quad v = -\frac{1}{1+x^4},$$ yields $$I_1(x) = \int \frac{x^2}{(1+x^4)^2} \, dx = -\frac{1}{4x(1+x^4)} - \int \frac{1}{4x^2(1+x^4)} \, dx.$$  Now write $$\frac{1}{x^2(1+x^4)} = \frac{1}{x^2} - \frac{x^2}{1+x^4},$$ thus $$I_1(x) = -\frac{1}{4x(1+x^4)} + \frac{1}{4x} + \frac{1}{4} \int \frac{x^2}{1+x^4} \, dx = \frac{x^3}{4(1+x^4)} + \frac{1}{4} I_2(x),$$ where we now seek to evaluate $I_2(x)$.  This is accomplished in a number of ways; one is to perform the factorization $$1+x^4 = (1 + \sqrt{2} x + x^2)(1 - \sqrt{2} x + x^2),$$ and compute the partial fraction decomposition $$\frac{x^2}{1+x^4} = \frac{1}{2\sqrt{2}} \left( \frac{x}{1 - \sqrt{2} x + x^2} - \frac{x}{1 + \sqrt{2} x + x^2} \right).$$  Then each term is integrable in closed form.  This is not the easiest or most elegant approach, but it is perhaps the most elementary, requiring no knowledge beyond AP Calculus BC.
</s>