Which solution of this integral $\int{\frac{x^2+1}{x^4-x^2+1}}dx$ is correct? $$\begin{align}
\int{\frac{x^2+1}{x^4-x^2+1}}dx&=\int{\frac{1+\frac{1}{x^2}}{x^2-1+\frac{1}{x^2}}}dx\\
&=\int{\frac{1+\frac{1}{x^2}}{(x-\frac{1}{x})^2+1}}dx\\
&=\int{\frac{1}{u^2+1}}du \quad(u=x-\frac{1}{x})\\
&=\arctan(u)+C\\
&=\arctan(x-\frac{1}{x})+C
\end{align}$$
The image of the integral is:

When I check it using wolfram, the result is $\arctan(\frac{x}{1-x^2})+C$
https://www.wolframalpha.com/input/?i2d=true&i=%5Cint%5C%28%7B%29Divide%5BPower%5Bx%2C2%5D%2B1%2CPower%5Bx%2C4%5D-Power%5Bx%2C2%5D%2B1%5D%5C%28%7D%29
It seems Wolfram calculates this integral like this:
$$\begin{align}
\int{\frac{x^2+1}{x^4-x^2+1}}dx&=\int\frac{x^2+1}{(x^2-1)^2+x^2}dx\\
&=\int\frac{\frac{x^2+1}{(x^2-1)^2}}{1+\frac{x^2}{(x^2-1)^2}}dx\\
&=\int{\frac{1}{1+u^2}}du \quad(u=\frac{x}{1-x^2})\\
&=\arctan(u)+C\\
&=\arctan(\frac{x}{1-x^2})+C
\end{align}$$
Which solution is correct?

Your answer is$$f(x)=\arctan\left(x-\frac1x\right).$$If you differentiate it, you will get indeed$$\dfrac{x^2+1}{x^4-x^2+1}.\tag1$$But $f$ is undefined at $0$. Besides, $\lim_{x\to0^+}f(x)\ne\lim_{x\to0^-}f(x)$.
On the other hand, if$$g(x)=\arctan\left(\frac x{1-x^2}\right),$$then, again, if you differentiate it, you will get indeed $(1)$. But $g$ is undefined at $\pm1$.
A primitive of $(1)$ is$$\begin{array}{rccc}h\colon&\Bbb R&\longrightarrow&\Bbb R\\&x&\mapsto&\begin{cases}\arctan\left(x-\frac1x\right)+\frac\pi2&\text{ if }x>0\\0&\text{ if }x=0\\\arctan\left(x-\frac1x\right)-\frac\pi2&\text{ if }x<0.\end{cases}\end{array}$$You can see its graph below:

