Solving the following integral (rational function, cubic over linear) I'm trying to solve the following integral:
$$
\int\frac{x^3}{(x+2)}\mathrm{d}x
$$
It would seem to me to be a classic integration-by-parts problem, but trying to do that (with $u=x^3$ and $dv=1/(x+2)$ I find myself stuck with the integral:
$$
\int 3x^2\ln(x+2)\mathrm{d}x
$$
which I don't find a way to solve. How should I proceed? Or maybe I got it all wrong from the beginning?
 A: If you are trying to compute:
$$\int{\frac{x^3}{x+2}}dx,$$
then you can easily divide $x^3$ by $x + 2$, which yields $x^3 = (x + 2)(x^2 - 2x + 4) - 8$, that is,
$$\frac{x^3}{x+2} = x^2 - 2x + 4 - \frac{8}{x+2};$$
so:
$$\int\frac{x^3}{x+2}dx = \int{(x^2 - 2x + 4)}dx - \int{\frac{8}{x+2}}dx.$$
You solve these integrals and you obtain the solution.
A: You can always use simple substitution i.e.
$$
u = x+2, du = dx
$$
so
$$
\int \frac{x^3}{x+2} \, d x = \int \frac{(u-2)^3}{u} \, du = \int u^2 - 6 u + 12 - \frac{8}{u}
$$
A: $$\frac{x^3}{x+2}=x^2-2x+4-\frac8{x+2}$$
Thus... in some situations, integration by parts is not the solution. :-)
A: In general, an integral has three parts: a polynomial part, a rational part, and a logarithmic part. Depending on the integral, some of these parts may be zero (and hence omitted).
Taking rational functions as our example, consider:
$$\int \frac{x^3}{(x+2)^2} dx = \frac{1}{2} x^2 - 4 x + \frac{8}{x+2} + 12 \log (x+2) + C$$
The logarithmic part is $12 \log (x+2)$, the rational part is $\frac{8}{x+2}$, and the polynomial part is $\frac{1}{2} x^2 - 4x + C$.
In the specific case of rational functions:


*

*The polynomial part is nonzero if and only if the degree of the numerator is greater than or equal to the degree of the denominator. You can find it by doing the polynomial division. The quotient corresponds to the polynomial part and the remainder corresponds to the rest.

*The rational part is nonzero if and only if the denominator is not squarefree. You can determine if a polynomial $p(x)$ is squarefree by calculating $\gcd(p(x), p'(x))$. How to actually calculate this is beyond the scope of this answer; ask your favourite search engine about the Hermite reduction as one example.

*Anything left over is the logarithmic part, and it can be found by partial fraction expansion on the squarefree part of the denominator. (The Rothstein-Trager method is another option.)


Interestingly, it's not just rational functions that this applies to; integrals over fields which involve more interesting functions can be understood along the same lines, except that there's often a "nonelementary" part left over, where the nonelementary part is typically a standard integral or a simple function for which no elementary integral exists. For example, for some constants $\alpha_{p}$, $\alpha_{r}$, $\alpha_{l}$, $A$ and $B$:
$$\int \frac{\tan^4 x}{(\tan x + 2)^2} dx = \alpha_{p} \tan x + \alpha_{r} \frac{\tan x}{\tan x + 2} + \alpha_{l} \log (\tan x + 2) + \int A \tan x + B\,dx$$
(Don't believe me? Take the derivative of both sides and see for yourself. Use the fact that $\frac{d}{dx}\tan x = 1 + \tan^2 x$.)
If you understand this as a polynomial in $\tan x$ (as opposed to $x$ in the first example), there's a clear "polynomial part", "rational part", "logarithmic part" and "nonelementary part" here.
