Once upon a time in a Calculus class, I was trying to evaluate the following integral: \[ \int \frac{x^2 + 8}{x^3 + 9x} \, \mathrm{d}x. \] The obvious way was to do a partial fractions decomposition, but I was feeling lazy and decided to use WolframAlpha to compute it and check the step-by-step solution to make sure I had the correct idea. Instead of using partial fractions, WolframAlpha gave an interesting alternative solution. First, notice that \[ \int \frac{x^2 + 8}{x^3 + 9x} \, \mathrm{d}x = \int \frac{x^{17} + 8x^{15}}{x^{18} + 9x^{16}} \, \mathrm{d}x=\frac{1}{18} \int \frac{18(x^{17} + 8x^{15})}{x^{18} + 9x^{16}} \, \mathrm{d}x. \] Then let \(u = x^{18}+9x^{16}\), which means that \(\mathrm{d}u=(18x^{17}+144x^{15}) \, \mathrm{d}x = 18(x^{17} + 8x^{15}) \, \mathrm{d}x\). Substituting \(u\) gives \[ \frac{1}{18} \int \frac{\mathrm{d}u}{u} = \frac{1}{18} \log \left| u \right|, \] which becomes the correct answer once you substitute \(x\) back in and simplify. Now, what did WolframAlpha do? It multiplied the numerator and denominator of the rational function by a convenient power term (\(x^{15}\)) and added another convenient constant (\(18\)) such that if you set \(u\) equal to the denominator, the substitution just so happens to give you the integrand \(1/u\). My question at the time was how did WolframAlpha know which power and constant to use? I mean, the fifteenth power sure wasn't an obvious one, so there must have been some systematic way of choosing it. This problem has been in the back of my head for about a year now, and I think it's finally time to take a closer look at this. Let \[ f(x)=\frac{A x^{n+k}+B x^n}{C x^{n+k+1}+D x^{n+1}} \] for some constants \(A,B,C,D \in \mathbb{R}\). In order to integrate \(f(x)\) with the same trick as above, we want to do a substitution like \[ u=x^p\left(C x^{n+k+1}+D x^{n+1}\right)=C x^{n+k+p+1}+D x^{n+p+1} \] for some power \(p\). Taking the differential of \(u\) yields \[ \mathrm{d}u=\left(C(n+k+p+1)x^{n+k+p}+D(n+p+1) x^{n+p}\right) \mathrm{d}x. \] But for the trick to work, we must restrict the differential to also equal \[ \mathrm{d}u=\lambda x^p\left(A x^{n+k}+B x^n\right) \mathrm{d}x \] for some constant \(\lambda \in \mathbb{R}\). Thus by comparing the coefficients of the two expressions, we arrive at a pair of equations: \[ \begin{cases} A\lambda = C(n+k+p+1) \\ B\lambda = D(n+p+1). \end{cases} \] Solving this system of equations gives a solution for \(p\) and \(\lambda\): \[ \begin{cases} p=\dfrac{BC}{AD-BC} \, k-n-1 \\[1em] \lambda=\dfrac{CD}{AD-BC} \, k \end{cases}. \] Now let's integrate. I'll show the substitution step-by-step, which leaves some rather unorthodox integrands, but I promise they will cancel out. Using the substitutions defined above, we have \[ \begin{aligned} \int f &=\int \frac{x^p f(x)}{x^p} \, \mathrm{d}x \\ &=\int \frac{A x^{n+k+p}+B x^{n+p}}{C x^{n+k+p+1}+D x^{n+1}} \, \mathrm{d}x \\ &=\int \frac{A x^{n+k+p}+B x^{n+p}}{u} \frac{1}{\lambda x^p\left(A x^{n+k}+B x^n\right)}\, \mathrm{d}u \\ &=\int \frac{\lambda}{u} \, \mathrm{d}u \\ &=\frac{\log\left|u\right|}{\lambda}. \end{aligned} \] Plugging for \(u\) again and simplifying gives the final answer as \[ \begin{aligned} \int f&=\frac{\log\left|u\right|}{\lambda}=\frac{\log\left|x^p\left(C x^{n+k+1}+D x^{n+1}\right)\right|}{\lambda} \\ &=\frac{(n+p+1)\log\left|x\right|+\log\left|C x^k+D\right|}{\lambda}. \end{aligned} \] Let's look at a slightly nicer example than the one I mentioned in the beginning of this post. Suppose \(f(x)=(1+3 x^4)/(x^5-x)\). With this, we have \(A=3, B=C=1, D=-1, n=0, k=4\). We can now calculate that \(p=-2\) and \(\lambda=1\). Thus we have that \[ \int f=\frac{(0-2+1)\log\left|x\right|+\log\left|x^4-1\right|}{1}=\log\left|x^4-1\right|-\log\left|x\right|, \] which, if you take the derivative of, is indeed an integral function of \(f\). Now, was this easier than doing a partial fraction decomposition? I don't know. I suppose it was faster doing it like this since it's just plugging numbers into a formula, instead of decomposing the function and then integrating each piece separately (which there are four in this instance). But that's as far as this goes. This isn't a useful tool for actually computing integrals as it relies on a specific pattern, which partial fractions don't. Nonetheless, it is an interesting little factoid, so here are some further things to consider: can you generalize this to cases where the powers of the terms in the denominator differ by something else than 1? What about to general rational functions?