<s>[INST] How do you evaluate the integral $\int\frac{x^2-1}{(x^4+3 x^2+1) \tan^{-1}\left(\frac{x^2+1}{x}\right)}\,dx$? i'm required to evaluate this integral. I've tried factorizing but it doesn't lead me to anywhere. 
$$\int\frac{x^2-1}{(x^4+3 x^2+1) \tan^{-1}\left(\frac{x^2+1}{x}\right)}\,dx$$
I've also tried letting $u = \frac{x^2+1}{x}$, $du/dx$ gets me $1-\frac{1}{x^2}$ but it doesn't seem to be working either.
Hope to receive some advise/ solutions on how to start tackling the question
 [/INST] An useful identity to remember is
$$\frac{dx}{x} = \frac{d(x+x^{-1})}{x-x^{-1}} = \frac{d(x-x^{-1})}{x + x^{-1}}$$
Using the first part of this identity, you can rewrite the integral as
$$\begin{align}
 & \int \frac{x(x^2-1)}{(x^4+3x^2+1)\tan^{-1}\left(x + x^{-1}\right)}\frac{d(x+x^{-1})}{x-x^{-1}}\\
= & \int \frac{x^2 d(x+x^{-1})}{(x^4+3x^2+1)\tan^{-1}\left(x + x^{-1}\right)}\\
= & \int \frac{d(x+x^{-1})}{(x^2+x^{-2}+3)\tan^{-1}\left(x + x^{-1}\right)}\\
= & \int \frac{d(x+x^{-1})}{((x+x^{-1})^2+1)\tan^{-1}\left(x + x^{-1}\right)}\\
= & \int \frac{d\tan^{-1}\left(x + x^{-1}\right)}{\tan^{-1}\left(x + x^{-1}\right)}\\
= &\log\tan^{-1}\left(x + x^{-1}\right) + \text{constant}.
\end{align}
$$
</s>