<s>[INST] Integrating $\frac{1}{(x^4 -1)^2}$ How to solve the the following integral? $$\int{\frac{1}{(x^4 -1)^2}}\, dx$$
 [/INST] In general, the following method will always work. Solve for the roots of the denominator in the complex plane:
$$
\begin{split}
z^4 &= 1 \Longrightarrow\\
z&=z_{n}\equiv\exp\left(\frac{i\pi n}{2}\right)
\end{split}
$$
In this case things are simple, you have $z_0=1$, $z_1=i$, $z_2=-1$, $z_3 = -i$.
Then the trick is to consider the function $\frac{1}{x^4-1}$ instead of its square first. A partial fraction expansion of a rational function that tends to zero at infinity can be obtained by writing down the expansion around all the singularities, keeping only the singular terms and adding them up. This works because the difference between the sum of the terms you obtain and the rational function then only has removable singularities left, it is therefore some polynomial, but it still tends to zero at infinity (because both the rational function and the singular terms from the expansions tend to zero at infinity). But the only polynomial that tends to zero at infinity is identical to zero.
Now, each expansion of $\frac{1}{\left(z^4-1\right)^2}$around each singularity $z_n$, is more easily computed by expanding $\frac{1}{z^4-1}$ instead and the squaring both sides. The expansion around $z_n$ only has one singular term, but because we want to square both sides we need to also compute the constant term. If we put $z = z_n + t$ and expand in powers of $t$ we get:
$$\frac{1}{z^4-1} = \frac{1}{4 z_n^3 t + 6 z_n^2 t^2 +\mathcal{O}(t^3)}=\frac{1}{4 z_n^3 t}-\frac{3}{8} +\mathcal{O}(t)$$  
Squaring both sides and keeping only the singular terms yields:
$$\frac{1}{\left(z^4-1\right)^2} = \frac{1}{64 z_n^6 t^2}-\frac{3}{16 z_n^3 t} +\mathcal{O}(1)$$  
So, the partial fraction expansion is:
$$\frac{1}{\left(x^4-1\right)^2} =\sum_{n=0}^3 \frac{1}{64 z_n^6}\frac{1}{\left(x-z_n\right)^2} - \sum_{n=0}^3 \frac{3}{16 z_n^3}\frac{1}{x-z_n} $$
We thus have:
$$\int \frac{dx}{\left(x^4-1\right)^2} = -\sum_{n=0}^3 \frac{1}{64 z_n^6}\frac{1}{x-z_n} - \sum_{n=0}^3 \frac{3}{16 z_n^3}\log\left(x-z_n\right) $$
Then the fractions with the imaginary terms are easily simplified so that they become manifestly real. You can deal with the logarithms of complex arguments as follows. The sum of the logarithmic terms with the complex arguments in this case is:
$$\frac{3 i}{16}\log\left(\frac{x+i}{x-i}\right)$$
If we write:
$$x + i = r\exp(i\alpha)$$
then since $x-i$ is the complex conjugate, we have:
$$x - i = r\exp(-i\alpha)$$
Therefore:
$$\frac{x+i}{x-i} = \exp(2 i\alpha)$$
Since $\alpha = \arctan\left(\frac{1}{x}\right)$, the sum of the two terms is:
$$-\frac{3}{8}\arctan\left(\frac{1}{x}\right)$$
</s>