<s>[INST] Intriguing Indefinite Integral: $\int ( \frac{x^2-3x+1/3 }{x^3-x+1})^2 \mathrm{d}x$ 
Evaluate
$$\int \left( \frac{x^2-3x+\frac{1}{3}}{x^3-x+1}\right)^2 \mathrm{d}x$$

I tried using partial fractions but the denominator doesn't factor out nicely. I also substituted $x=\dfrac{1}{t}$ to get
$$\frac{-1}{9} \int \left(\frac{t^2-9t+3}{t^3-t^2+1}\right)^2 \, \mathrm{d}t $$
But I don't know how to solve this either.
Please Help.
Thanks in advance.
 [/INST] The goal is to represent
$$\dfrac{dt}{dx} = \dfrac19 \cdot \dfrac{(3x^2-9x+1)^2}{(x^3-x+1)^2} = \dfrac{d(u/v)}{dx} = \dfrac{vdu/dx - u dv/dx}{v^2}$$
Hence, it is tempting to choose $v=(x^3-x+1)$. This means we need $u$ such that
$$(x^3-x+1)u'(x) - (3x^2-1)u = (x^2-3x+1/3)^2$$
Hence, $u(x)$ must be a quadratic as $u(x) = ax^2+bx+c$. This gives us
$$(x^3-x+1)(2ax+b) - (3x^2-1)(ax^2+bx+c) = (x^2-3x+1/3)^2$$
Comparing coefficient of $x^4$, we obtain
$$2a - 3a = 1 \implies a = -1$$
Comparing coefficient of $x^2$, we obtain
$$-2a + a -3c = 9 + 2/3 \implies 3c = -a-29/3= 1-29/3 = -26/3 \implies c = -26/9$$
Comparing the constant term, we obtain
$$b +c = 1/9 \implies b = 3$$
Hence, we have
$$\dfrac{d}{dx}\left(\dfrac{-x^2+3x-26/9}{x^3-x+1}\right) = \dfrac19 \cdot \dfrac{(3x^2-9x+1)^2}{(x^3-x+1)^2}$$
</s>