$$\int \frac{x^2+1}{x^4-x^2+1}dx$$
Dividing both sections by $x^2$ and adding $1$ to the denominator I get: $$\int \frac{1+\frac{1}{x^2}}{(x-\frac{1}{x})^2+1}dx$$
Setting $x-\frac{1}{x}$ as $t$ I get: $$dt=1+\frac{1}{x^2}dx$$
Then I have written it in the following form: $$x-\frac{1}{x}+\int \frac{dt}{t^2}.$$
Then I wrote it like this: $x-\frac{1}{x}-\frac{1}{t}$ , substituting the $x'$ back: $$x-\frac{1}{x}-\frac{1}{x-\frac{1}{x}}.$$ I know the integral I get is wrong because as I substitute some $x$'s in the most upper integral I get different results from those I get when substituting the same values in the final answers. Where is my mistake?
After your hard Work, we have $$\int\dfrac{dt}{t^2+1}=\arctan t+K$$
$$=\arctan(x-1/x)+k$$