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.

Partial fractions also works, this may be a bit more work than trying to find a clever ad hoc solution, but the advantage is that it is a straightforward method. 
If $\alpha$ is a root of the denominator, then putting $x = \alpha + t$ and performing a so-called Laurent expansion around $t=0$ (which is analogous to a Taylor expansion, except that negative power terms may appear in the expansion) yields:
$$\frac{x^2-3x+\frac{1}{3}}{x^3 - x + 1} = \frac{\alpha^2 - 3\alpha + \frac{1}{3}}{3\alpha^2 -1}\frac{1}{t} +\left[\frac{2\alpha-3}{3\alpha^2-1} -\frac{3\alpha\left(\alpha^2-3\alpha+\frac{1}{3}\right)}{\left(3\alpha^2-1\right)^2}\right]+\mathcal{O}(t)$$
Squaring both sides yields:
$$\left(\frac{x^2-3x+\frac{1}{3}}{x^3 - x + 1}\right)^2 = \left( \frac{\alpha^2 - 3\alpha + \frac{1}{3}}{3\alpha^2 -1}\right)^2\frac{1}{t^2}+\mathcal{O}(1)$$
The $\frac{1}{t}$ term cancels out due to $\alpha$ satisfying the equation $\alpha^3 - \alpha +1 = 0$.
We thus have the partial fraction expansion:
$$\left(\frac{x^2-3x+\frac{1}{3}}{x^3 - x + 1}\right)^2 = \sum_{\alpha}\left( \frac{\alpha^2 - 3\alpha + \frac{1}{3}}{3\alpha^2 -1}\right)^2\frac{1}{(x-\alpha)^2}$$
(Proof: the difference between the l.h.s. and the r.h.s. is a rational function but which by construction has no singularities, so it must be a polynomial. But because the terms all tend to zero for $x\to\infty$, that polynomial must be identical to zero.)
This is obviously trivial to integrate, but how do we sum over the roots $\alpha$? Consider the function:
$$f(\alpha) = \frac{1}{\alpha^3 -\alpha +1}\frac{\left(\alpha^2 - 3\alpha + \frac{1}{3}\right)^2}{3\alpha^2 -1}\frac{1}{\alpha-x}$$
obtained by multiplying the summand of the answer by the logarithmic derivative of the denominator inside the square of the integrand. Then consider doing a partial fraction expansion using the Laurent expansion method as we did above. Since the function tends to zero for $\alpha \to \infty$, faster than $1/\alpha$, the sum of the coefficients of the terms with exponent -1 will sum to zero. By construction, the desired summation is part of this summation.
The answer is thus given by minus the sum of the coefficients the Laurent expansion terms with exponent -1 of $f(\alpha)$ around $\alpha = x$ and $\alpha = \pm \frac{1}{\sqrt{3}}$. Such coefficients are referred to as "residues" in the theory of complex functions.
The residue at $\alpha = x$ is obviously:
$$\frac{1}{x^3 -x +1}\frac{\left(x^2 - 3x + \frac{1}{3}\right)^2}{3x^2 -1}$$
The residue at $\alpha = \pm \frac{1}{\sqrt{3}}$ can be written as:
$$\frac{x+\frac{3}{2}}{1-3 x^2} \mp\frac{\frac{\sqrt{3}}{3}+\frac{3}{2}\sqrt{3}x}{1-3 x^2}$$
The integral, which is minus the sum of these residues, can thus be written as:
$$\frac{x^4+9x^3-\frac{35}{3}x^2+x+\frac{26}{9}}{\left(x^3-x+1\right)\left(3 x^2-1\right)}$$
