<s>[INST] Calculating $\int \frac{x^2 - 2x + 3}{x^4 -x^2 +1}dx$ I was calculating
$$\int \frac{x^7 + 3x^6 - x^4 + 6x^3 -1}{x^4 - x^2 + 1}dx$$
I performed Euclidean division and the integral reduced to
$$\frac{x^4}4 + x^3 + \frac{x^2}2 + 2x + \frac32 \ln(x^4 - x^2 + 1) - J(x)$$
with
$$J(x) = \int \frac{x^2 - 2x +3}{x^4 - x^2 + 1}dx$$
How to calculate $J(x)$?
My try:
$$J(x) = \int \frac{x^2 + 3}{x^4 - x^2 + 1}dx - \frac{2}{\sqrt 3} \tan^{-1} \left( \frac{2x^2-1}{\sqrt 3} \right)$$
Now I am stuck
 [/INST] The denominator readily factors into $$x^4 - x^2 + 1 = (x^2 + \sqrt{3}x + 1)(x^2 - \sqrt{3}x + 1),$$ where upon the usual partial fraction decomposition procedure requires us to solve $$x^2-2x+3 = (Ax + B)(x^2 - 3x+1) + (Cx + D)(x^2 + 3x + 1)$$ for suitable coefficients $A, B, C, D$.  I trust that this is something you are able to do.  It may be a bit tedious, but it is the "canonical" method of solution for the indefinite integral.

Perhaps a little additional motivation may be useful.
We could look at the solutions of the general quadric $f(x) = x^4 - x^2 + 1$ as the square roots of the equivalent quadratic $f(x) = g(x^2) = (x^2)^2 - (x^2) + 1$, and multiply together the pairs of linear factors corresponding to complex conjugate roots, but this is not particularly elegant in this case.  Rather, we can use a "naive" approach and presuppose that $f$ factors nicely in the form $$x^4 - x^2 + 1 = (x^2 + ax + 1)(x^2 + bx + 1).$$  Expanding the RHS and comparing the coefficients to those on the LHS, it becomes obvious that we must have $b = -a$, and $2 - a^2 = -1$.  This gives us $a = \pm \sqrt{3}$, and the aforementioned factorization follows.  This sort of trick works in simple cases such as this.
</s>