# Integrating $\int\frac{x^2-1}{(x^2+1)\sqrt{x^4+1}}\,dx$

I came across a question today...

Find $$\displaystyle\int\dfrac{x^2-1}{(x^2+1)\sqrt{x^4+1}}\,dx$$

How to do this? I tried to take $x^4+1=u^2$ but no result. Then I tried to take $x^2+1=\frac{1}{u}$, but even that didn't work. Then I manipulated it to $\int \dfrac{1}{\sqrt{1+x^4}}\,dx+\int\dfrac{2}{(x^2+1)\sqrt{1+x^4}}\,dx$, butI have no idea how to solve it.

Wolframalpha gives some imaginary result...but the answer is $\dfrac{1}{\sqrt2}\arccos\dfrac{x\sqrt2}{x^2+1}+C$

Hint Divide the numerator and denominator by $x^2$, to get: $$\int \frac{(1-\frac{1}{x^2})dx}{(x+\frac{1}{x})(\sqrt {(x+\frac{1}{x})^2-2} )}$$ Then put $x+\frac{1}{x}=t$ $$\int \frac{dt}{t(\sqrt{t^2-2})}$$ Which is easily taken care of by putting $t=\sqrt2 \sec\theta$, $$\int \frac{(\sqrt2 \sec\theta\tan \theta)d\theta}{\sqrt2 \sec\theta \sqrt2 \tan\theta}$$
With (this seem to be some kind of substitution of the day) $$t=\frac{x}{\sqrt{1+x^4}}$$ you get $$\int\frac{1}{1+2t^2}\,dt.$$ I'm sure you can take it from here.