<s>[INST] Better way of finding $\int {x^2 + 1 \over x^4 + x^2 + 1} dx$. 
$$\int {x^2 +  1 \over x^4 + x^2 + 1} dx$$


By separating partial fractions, 
$${Ax + B \over x^2 - x + 1}  + {Cx + D \over x^2 + x + 1}  = {x^2 + 1 \over x^4 + x^2 + 1} \\ \implies (Ax + B)(x^2 + x + 1) + (Cx + D)(x^2 - x + 1) = x^2 + 1$$
I get $$\begin{cases} A = -1/2 \\ 
 B = 1/2\\
 C = 1/2 \\
D = 1/2\end{cases}$$
For which the integrand becomes 
$${1 \over 2}\int {1 - x\over x^2 - x + 1} dx + {1\over2} \int {x + 1\over x^2 + x + 1} dx$$
Now these two are easy enough to solve but still very tedious, not to mention that partial fractions was also very tedious.
Is there a  less cumbersome way to solve this ? I tried to change the integrand of form $1 + 1/x^2$ so that I substitute $u = 1 - 1/x$ but was unsuccessful .     
 [/INST] Notice that if you plug $x=i$ into $$(Ax+B)(x^2+x+1)+(Cx+D)(x^2-x+1)=x^2+1$$
You get $$Bi-A+C-Di=(C-A)+(B-D)i=0$$
or $C=A,B=D$ so
$$(Ax+B)(x^2+x+1+x^2-x+1)=2(Ax+B)(x^2+1)=x^2+1$$
From this it's easy to see that $A=C=0$ and $B=D=1/2$
</s>