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$?

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} $$


Notice, substitute $\text{u}=\text{f}\left(\text{x}\right)$ and $\text{d}\text{u}=\text{f}\space'\left(\text{x}\right)\space\text{d}\text{x}$:

$$\int\frac{\text{f}\space'\left(\text{x}\right)}{\text{f}\left(\text{x}\right)}\space\text{d}\text{x}=\int\frac{1}{\text{u}}\space\text{d}\text{u}=\ln\left|\text{u}\right|+\text{C}=\ln\left|\text{f}\left(\text{x}\right)\right|+\text{C}$$

Now, when:

$$\text{f}\left(\text{x}\right)=\arctan\left\{x+\frac{1}{x}\right\}$$

And:

$$\text{f}\space'\left(\text{x}\right)=\frac{x^2-1}{x^4+3x^2+1}$$


So, when you want to prove the result:

$$\int\frac{\frac{x^2-1}{x^4+3x^2+1}}{\arctan\left\{x+\frac{1}{x}\right\}}\space\text{d}\text{x}=\int\frac{x^2-1}{\left(x^4+3x^2+1\right)\arctan\left\{x+\frac{1}{x}\right\}}\space\text{d}\text{x}=\ln\left|\arctan\left\{x+\frac{1}{x}\right\}\right|+\text{C}$$