How to calculate this integral $\int\frac{x^4-1}{x^2\sqrt{x^4+x^2+1}}$? I have to calculate the indefinite integral $$\int\frac{x^4-1}{x^2\sqrt{x^4+x^2+1}}$$
I tried a lot of unsuccessful substitutions and finally decided to try this Integral Calculator.
It did calculate the answer but I can't understand the steps it gave.
Particularly this step below is what I'm unable to get. I am familiar with partial fraction decomposition but I have no idea how to break the expression like this.

Can someone explain it to me or suggest some other way?
 A: let $$I=\int \frac{x^4-1}{x^2\sqrt{x^4+x^2+1}}dx=\int \frac{x-x^{-3}}{\sqrt{x^2+x^{-2}+1}}dx=\frac{1}{2}\int \frac{dt}{\sqrt t}$$ $$=\sqrt{x^2+x^{-2}+1}+C$$
In the last one we use $x^2+x^{-2}+1=t.$
A: This is a super clever integral. We factor out an $x$ from the square root to get
$$I=\int\frac{x^4-1}{x^3\sqrt{x^2+1+1/x^2}}dx$$
If we add and subtract $1$ from within the square root, we can write this as
$$I=\int\frac{x^4-1}{x^3\sqrt{\left(x+\frac{1}{x}\right)^2-1}}dx$$
We will let $x+1/x=\sec\theta$ for our substitution, so $(1-1/x^2)dx=\sec\theta\tan\theta d\theta$. The fun comes into play when we try to replace the rest of the integral. For example, we can write
$$x^4-1=(x^2+1)(x^2-1)=x^3(x+1/x)(1-1/x^2)$$
So the numerator contains our differential term, as well as an extra $\sec\theta$, and the $x^3$ terms go away. Therefore, we have
$$I=\int\frac{\sec\theta}{\sqrt{\sec^2\theta-1}}\sec\theta\tan\theta d\theta=\int\sec^2\theta d\theta=\tan\theta +C$$
The rest can be completed by drawing a triangle and replacing $\tan\theta$ appropriately.
A: The suggested strategy you found works because of two observations.
First, note that the two factors in the denominator of the integrand you start with appears as separate denominators in the second line. If you don't see why the middle equation holds, try to put the two terms on a common denominator: $x^2\sqrt{x^4+x^2+1}$.
Second, the two integrands in the second line arise from differentiating
$$
\frac{d}{dx}\left(\dfrac{\sqrt{x^4+x^2+1}}{x}\right).
$$ 
This means the answer you are seeking is given by
$$
\dfrac{\sqrt{x^4+x^2+1}}{x} + c,
$$ 
where $c$ is an arbitrary constant.
