<s>[INST] Integration Problem: $\int \frac{x^2+1}{x^5-1}dx$ 
$$\int \frac{x^2+1}{x^5-1}dx$$

I am unable to integrate it, nothing works. Yes, I can use partial fraction but who remembers factorization of $x^5-1$, I need a better way of doing this. 
 [/INST] For these cyclotomic denominators, one can get an answer pretty fast by factoring into roots of unity. Let $\omega_k=e^{i\theta_k}=\cos\theta_k+i\sin\theta_k$, where $\theta_k=2\pi k/5$. Then
$$\frac{x^2+1}{x^5-1}=\frac{x^2+1}{\prod_{k=0}^4(x-\omega_k)}=\sum_{k=0}^4\frac{A_k}{x-\omega_k}$$
Obeserving that $\omega_k^{-k}=\omega_k^{5-k}$ and applying L'Hopital's rule a couple of times,
$$\begin{align}\lim_{x\rightarrow\omega_k}\frac{(x^2+1)(x-\omega_k)}{x^5-1} & =\lim_{x\rightarrow\omega_k}\frac{(x^2+1)(1)}{5x^4}=\frac15\left(\omega_k^{-2}+\omega_k\right) \\ & =\lim_{x\rightarrow\omega_k}\sum_{j=0}^4\frac{A_j\left(x-\omega_k\right)}{x-\omega_j}=\sum_{j=0}^4A_j\delta_{kj}=A_k\end{align}$$
Then
$$\begin{align}\int\frac{x^2+1}{x^5-1}dx & =\sum_{k=0}^4A_k\int\frac{dx}{x-\omega_k}=\sum_{k=0}^4\frac15\left(\omega_k^{-2}+\omega_k\right)\ln\left(x-\omega_k\right)+C_1 \\
 & =\sum_{k=0}^4\left(\cos2\theta_k+\cos\theta_k-i\sin2\theta_k+i\sin\theta_k\right)\ln\left(x-\cos\theta_k-i\sin\theta_k\right)+C_1 \\
 & =\sum_{k=0}^4\left(\cos2\theta_k+\cos\theta_k-i\sin2\theta_k+i\sin\theta_k\right)\left\{\frac12\ln\left(x^2-2x\cos\theta_k+1\right)+i\,\text{atan2}\left(-\sin\theta_k,x-\cos\theta_k\right)\right\}+C_1 \\
 & =\sum_{k=0}^4\left(\cos2\theta_k+\cos\theta_k-i\sin2\theta_k+i\sin\theta_k\right)\left\{\frac12\ln\left(x^2-2x\cos\theta_k+1\right)+i\,\text{atan2}\left(x-\cos\theta_k,\sin\theta_k\right)\right\}+C \\
& = \sum_{k=0}^4\left\{\frac12\left(\cos2\theta_k+\cos\theta_k\right)\ln\left(x^2-2x\cos\theta_k+1\right)+\left(\sin2\theta_k-\sin\theta_k\right)\tan^{-1}\left(\frac{x-\cos\theta_k}{\sin\theta_k}\right)\right\}+C\end{align}$$
because the imaginary parts cancel out above. The $k=0$ term is just $\frac25\ln|x-1|$ and the $k=4$ term is a copy of the $k=1$ term, just as the $k=3$ term is a copy of the $k=2$ term. So substituting in the values of the trig functions above and simplifying, we get
$$\begin{align}\int\frac{x^2+1}{x^5-1}dx=\frac25\ln|x-1| & -\frac1{10}\ln\left(x^2+\frac{1-\sqrt5}2x+1\right) \\ & +\frac{\sqrt{10-2\sqrt5}\left(1-\sqrt5\right)}{20}\tan^{-1}\left(\frac{4x-\sqrt5+1}{\sqrt{10+2\sqrt5}}\right) \\& -\frac1{10}\ln\left(x^2+\frac{1+\sqrt5}2x+1\right) \\ & -\frac{\sqrt{10+2\sqrt5}\left(1+\sqrt5\right)}{20}\tan^{-1}\left(\frac{4x+\sqrt5+1}{\sqrt{10-2\sqrt5}}\right)+C\end{align}$$
</s>