# Is there a general formula for the antiderivative of rational functions?

Some antiderivatives of rational functions involve inverse trigonometric functions, and some involve logarithms. But inverse trig functions can be expressed in terms of complex logarithms. So is there a general formula for the antiderivative of any rational function that uses complex logarithms to unite the two concepts?

-
You certainly could do that, but it turns out to be a Pyrrhic victory. Getting complex results for an inherently real problem usually obscures the nature of the solution and begs for something simpler. You are much better off factoring the denominator into linear factors for real roots and quadratic factors for complex root. The linear factors become logarithms; the quadratic ones become inverse trig functions and logs, but everything is real. –  Ron Gordon Jan 31 '13 at 20:17

Write the rational function as $$f(z) = \dfrac{p(z)}{q(z)} = \dfrac{p(z)}{\prod_{j=1}^n (z - r_j)}$$ where $r_j$ are the roots of the denominator, and $p(z)$ is a polynomial. I'll assume $p$ has degree less than $n$ and the roots $r_j$ are all distinct.
Then the partial fraction decomposition of $f(z)$ is $$f(z) = \sum_{j=1}^n \frac{p(r_j)}{q'(r_j)(z - r_j)}$$ where $p(r_j)/q'(r_j)$ is the residue of $f(z)$ at $r_j$. An antiderivative is $$\int f(z)\ dz = \sum_{j=1}^n \frac{p(r_j)}{q'(r_j)} \log(z -r_j)$$

-
You can factor that way if you allow complex numbers, but then $\log$ becomes "multiple-valued". Should something be said about that, or should one just say the answer is multiple-valued? –  Michael Hardy Jan 31 '13 at 21:15
Shouldn't $f(z)$ come down to a polynomial plus the sum of $n$ terms that you give here? –  Michael Hardy Jan 31 '13 at 21:57
As I said, I'm assuming $p$ has degree less than $n$, so there is no polynomial part. Yes, the log is multi-valued, and so is the antiderivative. On any simply-connected domain disjoint from the roots, take any analytic branches of the logs and you get an antiderivative. –  Robert Israel Jan 31 '13 at 23:33

If one uses partial fractions allowing complex numbers as coefficients, then the denominator of $p(x)/q(x)$ factors as a constant times a product of terms of form $(x-a_k)^r$ for a set of distinct complex $a_k$. Then partial fractions expresses $p(x)/q(x)$ as the sum of a polynomial and terms of the form $c/(x-a_k)^j$, and so the antiderivative consists of that of the polynomial, and some logarithm terms from integrating any $c/(x-a_k)$ terms , and some rational fractional terms coming from integrating $c/(x-a_k)^i$ terms with $i>1$. So it looks like all the terms are rational functions or log terms.

-
Regarding coffeemath's answer, p. 9 and pp. 12-21 of Hardy's book The Integration of Functions of a Single Variable (2nd edition, 1916) may be of interest. –  Dave L. Renfro Jan 31 '13 at 20:41

In one sense Robert Israel's covers it, in the case of distinct roots. However, may I add a few things:

If the coefficients are in the field $\mathbb C$ of complex numbers, then the factorization of the numerator and denominator into $a(z-r_1)\cdots(z-r_n)$ can be done, where $r_1,\ldots,r_n$ are complex numbers, some of which may be the same as each other. Then you get partial fractions.

If no two of the $r$ are the same as each other, i.e. we have distinct roots, then, as Robert Israel noted, $$\frac{\bullet}{z-r_1}+\cdots+\frac{\bullet}{z-r_n}.$$ If a root does occur more than once, then we get higher powers; for example, if the root $r$ occurs three times, we have $$\frac{\bullet}{z-r}+\frac{\bullet}{(z-r)^2}+\frac{\bullet}{(z-r)^3}.$$

But now suppose the coefficients are real. Then for every complex root $r$, the complex conjugate $\overline r$ is also a root. In that case $$(z-r)(z-\overline r) = z^2 - (r+\overline r)z + r\overline r$$ and the coefficients of this quadratic polynomial are real. Thus we have a factorization in which every factor is either first-degree or second-degree and all coefficients are real. When factoring then like this, it is sometimes convenient to include a coefficient of $z^2$ other than $1$, so we have $az^2+bz+c$. If $a,b,c$ are real, then $az^2+bz+c$ can be factored into first-degree factors only if $b^2-4ac\ge 0$. If $b^2-4ac<0$ and we insist on using only real numbers in the factorization, then the partial fraction expansion includes terms like this: $$\frac{fz+g}{az^2+bz+c}.$$ Here, one can write $$u=az^2+bz+c,$$ $$du = (2az+b)\,dz,$$ $$\left(\frac{f}{2a}\cdot\frac{2a+b}{az^2+bz+c} + \frac{\frac{-fb}{2a}+g}{az^2+bz+c}\right)\,dz = \left(\text{constant}\cdot\frac{du}{u}\right) + \left(\frac{\text{constant}}{az^2+bz+c} \, dz\right).$$ The substitution handles the first term and we get $$\text{constant}\cdot \begin{cases}\log(az^2+bz+c) & \text{if }a>0, \\ \log(-az^2-bz-c) & \text{if }a<0. \end{cases}$$ We don't need an absolute value inside the logarithm, because the fact that $b^2-4ac<0$ means the polynomial never changes signs as long as $z$ is real.

The second term requires completing the square: $$\frac{dz}{az^2+bz+c} = \frac{dz}{a\left(z+\frac{b}{2a}\right)^2 + \left(c-\frac{b^2}{4a}\right)}$$ If $a>0$ then $c-\frac{b^2}{4a}>0$ because $b^2-4ac<0$. Then we divide the top and bottom both by $c-\frac{b^2}{4a}>0$ and get a constant times $$\frac{dz}{\left( \frac{z+\frac{b}{2a}}{\sqrt{A}} \right)^2 + 1} = \frac{dz/\text{something}}{w^2+1} = \text{constant}\cdot\frac{dw}{w^2+1} = \text{constant}\cdot d(\arctan(w)).$$

However: Factoring the polynomial down to linear and quadratic factors may be labor-intensive and in some reasonable sense even non-trivial in some cases.

PS: I haven't said what happens with $\dfrac{\bullet}{(ax^2+bx+c)^2}$ or higher powers when $b^2-4ac<0$. The short answer is trigonometric substitutions.

-