Let $p(x)/q(x)$ be a real-valued rational function in $\mathbb{R}(x)$. I am wondering what the complete story is for integration of these functions. I would expect some algorithm to work like this:
1) Factor $q(x)$ into a product $\prod_{i = 1}^n q_i(x)^{n_i}$. This is actually impossible for polynomials $q(x)$ of high enough degree. So suppose we started with this factorization for $q(x)$ so we can expect to have a closed formula at the end.
2) Use the euclidian algorithm to express $p(x) / q(x) = \sum_{i =1}^n p_i(x) / q_i(x)^{n_i}$. Using linearity of the integral, it is enough to calculate the integral of $p_i(x)/q_i(x)^{n_i}$.
3) I would expect an algorithm to reduce to rational functions of the form $1/r_i(x)^{n_i}$ ($r_i$ of degree $2$ or $1$), and then to rational functions of the form $1/r_i(x)$ ($r_i$ of degree $2$ or $1$). I don't actually know how this would be done though.
4) For the integration of $1/r(x)$, where $r(x)$ is irreducible of degree $2$, we may use substitution, shifting, scaling, etc. to put $r(x)$ in the form $x^2 + 1$. This has the known integral $\text{arctan}(x) + C$. For the integration of $1/x$, that is simply $\text{ln}(x) + C$.