Integral with binomial to a power $\int\frac{1}{(x^4+1)^2}dx$ I have to solve the following integral:
$$\int\frac{1}{(x^4+1)^2}dx$$
I tried expanding it and then by partial fractions but I ended with a ton of terms and messed up. I also tried getting the roots of the binomial for the partial fractions but I got complex roots and got stuck. Is there a trick for this kind of integral or some kind of helpful substitution? Thanks. 
EDIT:
I did the following:
Let $x^2=\tan\theta$, then $x = \sqrt{\tan\theta}$ and $dx=\frac{\sec^2\theta}{2x}d\theta$ 
Then:
$$I=\int\frac{1}{(x^4+1)^2}dx = \int\frac{1}{(\tan^2\theta+1)^2} \frac{\sec^2\theta}{2x}d\theta=\int\frac{1}{\sec^4\theta} \frac{\sec^2\theta}{2x}d\theta$$
$$I=\frac{1}{2}\int{\frac{1}{\sec^2\theta \sqrt{\tan\theta}}}d\theta$$.
After this I don't know how to proceed. 
 A: Use $\left(\frac x{x^4+1}\right)' = -\frac3{x^4+1} + \frac 4{(x^4+1)^2} $ to rewrite the integral as
$$I = \int \frac 1{(x^4+1)^2}dx=\frac x{4(x^4+1)}+\frac34\int\frac1{x^4+1} dx$$
where
\begin{align}\int\frac2{x^4+1} dx = &\int\frac{1+x^2}{x^4+1} dx + \int\frac{1-x^2}{x^4+1} dx\\
= &
\int\frac{d(x-\frac1{x})}{(x-\frac1{x})^2+2}  - \int\frac{d(x+\frac1{x})}{(x+\frac1{x})^2-2}\\
=&\ \frac1{\sqrt2} \tan^{-1}\frac{x^2-1}{\sqrt2x} + \frac1{\sqrt2} \coth^{-1}\frac{x^2+1}{\sqrt2x} 
\end{align}
Thus
$$I = \frac x{4(x^4+1)}+\frac3{8\sqrt2} \tan^{-1}\frac{x^2-1}{\sqrt2x} + \frac3{8\sqrt2} \coth^{-1}\frac{x^2+1}{\sqrt2x} + C$$
A: I am not aware of a trick. I would just write $x^4+1$ as $\left(x^2+\sqrt2x+1\right)\left(x^2-\sqrt2x+1\right)$ and then I would write$$\frac1{(x^4+1)^2}$$as$$\frac{Ax+B}{x^2+\sqrt2x+1}+\frac{Cx+D}{\left(x^2+\sqrt2x+1\right)^2}+\frac{Ex+F}{x^2-\sqrt2x+1}+\frac{Gx+H}{\left(x^2-\sqrt2x+1\right)^2}.$$
A: Hints:
$$\frac1{(x^4+1)^2}=\frac{x^4+1-x^4}{(x^4+1)^2}=\frac1{x^4+1}-\frac{x^4}{(x^4+1)^2}$$ and by parts
$$4\int\frac{x^3x}{(x^4+1)^2}dx=-\frac x{x^4+1}+\int\frac{dx}{x^4+1}.$$
This way we can get rid of the square at the denominator, and we are left with
$$\frac1{x^4+1}.$$
Now using the factorization of the quartic binomial,
$$\frac{\sqrt8}{x^4+1}=\frac{x+\sqrt2}{x^2+\sqrt2x+1}-\frac{x-\sqrt2}{x^2-\sqrt2x+1}.$$
Here, by completing the square, we can handle the terms $\sqrt2x$ in the denominators, and solve with terms $\log(x^2\pm\sqrt2x+1)$ and $\arctan(\sqrt2x\pm1)$.
A: We first decrease the power 2 using integration by parts.
$$\begin{aligned} \int \frac{d x}{\left(1+x^{4}\right)^{2}} &=-\frac{1}{4}\int \frac{1}{x^{3}} d\left(\frac{1}{1+x^{4}}\right) \\ &=-\frac{1}{4}\left[\frac{1}{x^{3}\left(1+x^{4}\right)}+3 \int \frac{d x}{x^{4}\left(1+x^{4}\right)}\right] \\ &=-\frac{1}{4}\left[\frac{1}{x^{3}\left(1+x^{4}\right)}-\frac{1}{x^{3}}-3\int \frac{d x}{1+x^{4}}\right] \\ &=\frac{x}{4\left(1+x^{4}\right)}+\frac{3}{4} \int \frac{d x}{1+x^{4}} \end{aligned}$$
By my post,
$$\int \frac { d x } { x ^ { 4 } + 1 }   =  \frac { 1 } { 4 \sqrt { 2 } } \left[ 2 \tan ^ { - 1 } \left( \frac { x ^ { 2 } - 1 } { \sqrt { 2 } x } \right) + \ln \left| \frac { x ^ { 2 } + \sqrt { 2 } x + 1 } { x ^ { 2 } - \sqrt { 2 } x + 1 } \right|\right] + C,$$
we  get$$
\int \frac{d x}{\left(1+x^{4}\right)^{2}}=\frac{x}{4\left(1+x^{4}\right)}+\frac{3}{16 \sqrt{2}}\left[2 \tan ^{-1}\left(\frac{x^{2}-1}{\sqrt{2} x}\right)+\ln \left|\frac{x^{2}+\sqrt{2} x+1}{x^{2}-\sqrt{2} x+1}\right|\right]+C
$$
